Skip to content

CSV to XML API

Overview

Convert CSV text to XML. The body mode processes the input synchronously. The url and file modes submit an asynchronous job.

Endpoint

Method URL
POST https://api.apidatatools.com/csv-to-xml-api

Authentication

Send your API key in the x-api-key header:

x-api-key: YOUR_API_KEY

Input modes

Set the x-source-type header to choose an input mode:

  • body — Send CSV text as the raw request body. This is the default mode and runs synchronously.
  • url — Submit a URL to a CSV file. The request runs asynchronously.
  • file — Submit the storage key for a previously uploaded file. The request runs asynchronously.

Headers

Header names are case-insensitive. The lowercase spellings below are used in this documentation.

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.

Accepted file extensions

For url and file modes, the accepted extensions are .txt, .csv, and .log.

Request body

body mode

Send the CSV content directly as raw text. The request body must not be empty.

url mode

Send a JSON object with a url field:

{
  "url": "https://example.com/input.csv"
}

file mode

Send a JSON object with a file field. Its value must be the exact storage key returned by the upload workflow.

{
  "file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}

curl examples

Synchronous body mode

curl -X POST 'https://api.apidatatools.com/csv-to-xml-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'x-source-type: body' \
  --data-binary 'name,amount
Alice,12
Bob,34'

Asynchronous url mode

curl -X POST 'https://api.apidatatools.com/csv-to-xml-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'x-source-type: url' \
  -d '{"url":"https://example.com/input.csv"}'

Asynchronous file mode

curl -X POST 'https://api.apidatatools.com/csv-to-xml-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'x-source-type: file' \
  -d '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'

Success responses

Synchronous body mode

A successful file-producing response has HTTP 200 and includes request_id, status, file, and preview. The file value is a temporary download URL.

{
  "request_id": "REQUEST_ID",
  "status": "success",
  "file": "https://downloads.apidatatools.com/OUTPUT_FILE",
  "preview": "XML preview"
}

Asynchronous url and file modes

A successfully accepted job 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 the x-api-key header when checking job status. The response includes request_id, job_id, status, created_at, and updated_at. The timestamps are Unix timestamps.

Queued

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "queued",
  "created_at": 1710000000,
  "updated_at": 1710000000,
  "message": "Your job is being processed.",
  "retry_after": 2
}

Processing

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "processing",
  "created_at": 1710000000,
  "updated_at": 1710000002,
  "message": "Your job is being processed.",
  "retry_after": 2
}

Success

A completed job includes its result under result:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "success",
  "created_at": 1710000000,
  "updated_at": 1710000005,
  "result": {
    "status": "success",
    "file": "https://downloads.apidatatools.com/OUTPUT_FILE",
    "preview": "XML preview"
  }
}

Failed

A failed job includes its error code, message, and details under error:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "failed",
  "created_at": 1710000000,
  "updated_at": 1710000005,
  "error": {
    "code": "DOWNLOAD_FAILED",
    "message": "Error message",
    "details": {
      "message": "Error message"
    }
  }
}

Error handling

Error responses use this envelope. Additional fields may be present in details.

{
  "status": "error",
  "error": "ERROR_CODE",
  "request_id": "REQUEST_ID",
  "details": {
    "message": "Description of the error"
  }
}

The following HTTP statuses are defined by the request handlers:

HTTP status Error codes When it applies
400 INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY The source type is unsupported, the body cannot be decoded, or the 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 has an unsupported extension.
400 INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR A job-status request has a missing or inaccessible job ID, or encounters a job lookup error.
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 A synchronous request body exceeds the body-size limit for the plan.
413 FILE_TOO_LARGE A URL or file input exceeds the file-size limit for the plan.
429 QUOTA_EXCEEDED, RATE_LIMITED The plan’s request quota or rate limit has been reached.
500 PLAN_NOT_FOUND, CONFIG_ERROR, PLAN_CONFIG_ERROR, INTERNAL_ERROR, AUTH_ERROR A plan or configuration is unavailable, or an internal error occurred.

Asynchronous jobs can also end in a failed state with INVALID_JOB, DOWNLOAD_FAILED, or UPLOAD_FAILED. These codes are reported in the job-status response rather than as the HTTP status of the original accepted request.

Notes

  • Body-size, file-size, quota, and rate limits depend on your plan. See tool limits.
  • Download URLs are temporary; retention depends on your plan.