CSV to Base64 API¶
Overview¶
The CSV to Base64 API accepts text in body mode or a file supplied by URL or pre-uploaded file reference. Body mode is synchronous; URL and file modes run asynchronously.
Endpoint¶
POST https://api.apidatatools.com/csv-to-base64-api
Authentication¶
Include your API key in the x-api-key header on every request:
x-api-key: YOUR_API_KEY
Input modes¶
| Mode | x-source-type value | Behavior |
|---|---|---|
| Body | body | Synchronous. Send the input as raw text. |
| URL | url | Asynchronous. Send a JSON object containing the input URL. |
| File | file | Asynchronous. Send a JSON object containing the exact storage key returned by the upload workflow. |
Headers¶
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | string | Yes | Your API key | Authenticates the request. |
x-source-type | string | No | body; body, url, or file | Selects the input mode. Header names are case-insensitive. |
Accepted file extensions¶
For URL and file modes, the accepted input extensions are:
.txt.csv.log
Request body¶
Body mode¶
Send the input as raw text. Do not wrap it in a JSON object.
URL mode¶
Send a JSON object with a url string. The URL must use HTTP or HTTPS.
{
"url": "https://example.com/input.csv"
}
File mode¶
Send a JSON object with a file string containing the exact storage key returned by the upload workflow.
{
"file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}
curl examples¶
Body mode¶
curl -X POST 'https://api.apidatatools.com/csv-to-base64-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: body' \
--data-binary 'name,score
Ada,10'
URL mode¶
curl -X POST 'https://api.apidatatools.com/csv-to-base64-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: url' \
-H 'Content-Type: application/json' \
--data '{"url":"https://example.com/input.csv"}'
File mode¶
curl -X POST 'https://api.apidatatools.com/csv-to-base64-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: file' \
-H 'Content-Type: application/json' \
--data '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
A synchronous success has request_id, status, and preview. For data-producing results, preview is serialized JSON. If the result is file-producing, the response also includes file, a temporary download URL.
Data-producing shape:
{
"request_id": "REQUEST_ID",
"status": "success",
"preview": "SERIALIZED_JSON"
}
File-producing shape:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "TEMPORARY_DOWNLOAD_URL",
"preview": "PREVIEW"
}
Download URLs are temporary. Retention depends on your plan.
Asynchronous URL and file modes¶
A successful job submission returns HTTP 202:
{
"status": "accepted",
"job_id": "JOB_ID",
"status_url": "https://api.apidatatools.com/jobs/JOB_ID",
"request_id": "REQUEST_ID"
}
Async job status¶
Check a submitted job with:
GET https://api.apidatatools.com/jobs/{job_id}
Include x-api-key on the status request. The status endpoint returns HTTP 200 for a successful status response.
Queued¶
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "queued",
"created_at": 0,
"updated_at": 0,
"message": "Your job is being processed.",
"retry_after": 2
}
Processing¶
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "processing",
"created_at": 0,
"updated_at": 0,
"message": "Your job is being processed.",
"retry_after": 2
}
Success¶
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 0,
"updated_at": 0,
"result": {
"status": "success",
"file": "TEMPORARY_DOWNLOAD_URL",
"preview": "PREVIEW"
}
}
Failed¶
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 0,
"updated_at": 0,
"error": {
"code": "ERROR_CODE",
"message": "Error message",
"details": {
"message": "Error message"
}
}
}
Error handling¶
Synchronous and request-validation errors use this envelope. Additional fields may appear in details.
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Error message"
}
}
| HTTP status | Error codes | When it applies |
|---|---|---|
| 400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY | Unsupported input mode, invalid body encoding, or empty request body. |
| 400 | INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION | Invalid asynchronous request body or URL/file input. |
| 400 | INVALID_JOB_ID, DDB_ERROR, JOB_NOT_FOUND, FORBIDDEN | Job status request has a missing or inaccessible job ID, or the job cannot be queried. |
| 401 | UNAUTHORIZED | Authentication context is missing or invalid. |
| 404 | USER_NOT_FOUND, UNKNOWN_FUNCTION | The authenticated user or requested API endpoint was not found. |
| 413 | PAYLOAD_TOO_LARGE, FILE_TOO_LARGE | The body or input file exceeds the applicable plan limit. |
| 429 | QUOTA_EXCEEDED, RATE_LIMITED | The plan quota or rate limit has been reached. |
| 500 | PLAN_NOT_FOUND, INTERNAL_ERROR | Plan configuration is unavailable or request processing failed. |
| 500 | CONFIG_ERROR, PLAN_CONFIG_ERROR | Asynchronous job configuration or plan limits are unavailable or invalid. |
Asynchronous jobs can also fail during processing. The status endpoint reports these in its error object; codes can include INVALID_JOB, DOWNLOAD_FAILED, UPLOAD_FAILED, FILE_TOO_LARGE, and INTERNAL_ERROR.
Notes¶
- Body-size and file-size limits, quota, rate limits, and download retention depend on your plan. See tool limits.
- URL and file modes require an accepted file extension.
- The
filevalue must be the exact storage key returned by the upload workflow; do not add a path prefix. - Download URLs are temporary, and their retention period depends on your plan.