CSV Whitespace Trim API¶
Overview¶
The CSV Whitespace Trim API processes CSV text synchronously or accepts a URL or uploaded-file reference for asynchronous processing.
Endpoint¶
| Property | Value |
|---|---|
| Method | POST |
| URL | https://api.apidatatools.com/csv-whitespace-trim-api |
Authentication¶
Include your API key in the x-api-key header on every request.
Input modes¶
Choose a mode with the x-source-type header:
body— send CSV text directly. This is the default and runs synchronously.url— send a JSON object containing a URL. Processing runs asynchronously.file— send a JSON object containing a pre-uploaded file reference. Processing runs asynchronously.
Headers¶
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | String | Yes | Your API key | Authenticates the request. |
x-source-type | String | No | Default: body. Values: body, url, file | Selects the input mode. Header names are case-insensitive. |
Accepted file extensions¶
For URL and file modes, the supported input extensions are .txt, .csv, and .log.
Request body¶
Body mode¶
Send the CSV content as raw text. Do not wrap it in JSON.
URL mode¶
Send a JSON object with a url property:
{
"url": "https://example.com/input.csv"
}
The URL must use HTTP or HTTPS and point to a file with a supported extension.
File mode¶
Send a JSON object with a file property. Its value must be 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-whitespace-trim-api" \
-H "x-api-key: YOUR_API_KEY" \
--data-raw $'name,city\n Ada , London \n'
URL mode¶
curl -X POST "https://api.apidatatools.com/csv-whitespace-trim-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: url" \
--data-raw '{"url":"https://example.com/input.csv"}'
File mode¶
curl -X POST "https://api.apidatatools.com/csv-whitespace-trim-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: file" \
--data-raw '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
A successful synchronous response has HTTP status 200. File-producing results include request_id, status, file, and preview:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "OUTPUT_PREVIEW"
}
If the result is data-producing rather than file-producing, the response has request_id, status, and preview. In that response, preview is serialized JSON text.
Asynchronous URL and file modes¶
Accepted jobs return HTTP status 202:
{
"status": "accepted",
"job_id": "JOB_ID",
"status_url": "https://api.apidatatools.com/jobs/JOB_ID",
"request_id": "REQUEST_ID"
}
Poll the status_url to retrieve the job state and result.
Async job status¶
Retrieve a job with:
curl -X GET "https://api.apidatatools.com/jobs/JOB_ID" \
-H "x-api-key: YOUR_API_KEY"
The status endpoint returns HTTP 200 for a successfully retrieved job. Each response includes request_id, job_id, status, created_at, and updated_at.
Queued and processing¶
For jobs in queued or processing status, the response also includes message and retry_after:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "queued",
"created_at": 1700000000,
"updated_at": 1700000000,
"message": "Your job is being processed.",
"retry_after": 2
}
The status value is queued or processing, depending on the job state.
Success¶
A successful job response includes result:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1700000000,
"updated_at": 1700000002,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "OUTPUT_PREVIEW"
}
}
Failed¶
A failed job response includes an error object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1700000000,
"updated_at": 1700000002,
"error": {
"code": "DOWNLOAD_FAILED",
"message": "Download failed.",
"details": {
"attempt": 3,
"retries_exhausted": true
}
}
}
The error code, message, and details depend on the failure.
Error handling¶
HTTP error responses use this envelope. Additional properties may appear inside details.
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Error description."
}
}
| HTTP status | Error codes | When it applies |
|---|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY | The source type is unsupported, body decoding fails, or the request body is empty. |
400 | INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION | An asynchronous request body, URL, or file reference is invalid, unavailable, unreachable, or uses an unsupported extension. |
400 | INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR | The job-status request has a missing or unavailable job ID, the job belongs to another user, or the job lookup fails. |
400 | Tool-specific error codes | A tool execution error occurs. The code and message depend on the error. |
401 | UNAUTHORIZED | Authentication context is missing or invalid. |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION | The authenticated user or requested API endpoint is not found. |
413 | PAYLOAD_TOO_LARGE, FILE_TOO_LARGE | The request body or input file exceeds the applicable plan limit. |
429 | QUOTA_EXCEEDED, RATE_LIMITED | The plan quota is exhausted or the request rate limit is exceeded. |
500 | PLAN_NOT_FOUND, CONFIG_ERROR, PLAN_CONFIG_ERROR, INTERNAL_ERROR | Plan configuration is missing, asynchronous job configuration is unavailable or invalid, or an unexpected processing error occurs. |
Asynchronous jobs can also fail with INVALID_JOB, DOWNLOAD_FAILED, or UPLOAD_FAILED. These are job failure codes reported through the status endpoint; they are not HTTP statuses for the initial request. A terminal failed job is returned by the status endpoint in the failed shape above.
Notes¶
- Body-size, file-size, quota, rate, and output-retention limits depend on your plan. See tool limits.
- Output download URLs are temporary. Their availability depends on plan-based retention.