XML Formatter API¶
Overview¶
Formats XML input. Body mode runs synchronously; URL and pre-uploaded file modes run asynchronously.
Endpoint¶
POST https://api.apidatatools.com/xml-formatter-api
Authentication¶
Include your API key in the x-api-key header with every request.
Input modes¶
| Mode | Behavior |
|---|---|
body | Synchronous. Send XML as raw text. This is the default mode. |
url | Asynchronous. Provide a URL to an XML file. |
file | Asynchronous. Provide 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¶
URL and file inputs must use one of these extensions:
.txt.xml.log
Request body¶
Body mode¶
Send the XML document as raw text. Do not wrap it in a JSON object.
URL mode¶
Send a JSON object with a url string:
{
"url": "https://example.com/input.xml"
}
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 --request POST 'https://api.apidatatools.com/xml-formatter-api' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: body' \
--data-raw '<root><item>Example</item></root>'
URL mode¶
curl --request POST 'https://api.apidatatools.com/xml-formatter-api' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: url' \
--data-raw '{"url":"https://example.com/input.xml"}'
File mode¶
curl --request POST 'https://api.apidatatools.com/xml-formatter-api' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: file' \
--data-raw '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
A successful file-producing response has HTTP status 200 and includes the request ID, status, download URL, and preview:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/temporary-output.xml",
"preview": "Formatted XML preview"
}
The download URL is temporary; its availability period depends on your plan.
Asynchronous URL and file modes¶
A successfully accepted job has HTTP status 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 job with an authenticated GET request:
GET https://api.apidatatools.com/jobs/{job_id}
For example:
curl --request GET 'https://api.apidatatools.com/jobs/JOB_ID' \
--header 'x-api-key: YOUR_API_KEY'
The status response includes request_id, job_id, status, created_at, and updated_at.
Queued or processing¶
For queued and processing jobs, the response also includes a message and polling interval:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "queued",
"created_at": 1730000000,
"updated_at": 1730000000,
"message": "Your job is being processed.",
"retry_after": 2
}
The status value is queued or processing, depending on the job.
Success¶
A successful job includes its result in result:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1730000000,
"updated_at": 1730000002,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/temporary-output.xml",
"preview": "Formatted XML preview"
}
}
The download URL is temporary; its availability period depends on your plan.
Failed¶
A failed job includes an error code, message, and details:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1730000000,
"updated_at": 1730000002,
"error": {
"code": "DOWNLOAD_FAILED",
"message": "Error message",
"details": {
"message": "Error message"
}
}
}
The code and message depend on the failure.
Error handling¶
Errors use this envelope. Additional fields may appear inside details.
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Description of the error"
}
}
HTTP errors¶
| HTTP status | Error codes | When it applies |
|---|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY | The source type is unsupported, the request 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 or its URL/file input is invalid or unavailable. |
400 | INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR | A job-status request has a missing or unavailable job ID, or access to the job is denied. |
400 | Tool-specific error codes | The formatter rejects the input. The specific code and message depend on the error. |
401 | UNAUTHORIZED | Authentication 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 or rate limit has been reached. |
500 | PLAN_NOT_FOUND, CONFIG_ERROR, PLAN_CONFIG_ERROR, INTERNAL_ERROR | Plan configuration, asynchronous job configuration, or request processing failed. |
Asynchronous jobs can also fail after acceptance with INVALID_JOB, DOWNLOAD_FAILED, UPLOAD_FAILED, FILE_TOO_LARGE, or INTERNAL_ERROR. These appear in the failed job’s status response; they are not necessarily HTTP errors from the original submission.
Notes¶
- Body-size, file-size, quota, rate, and download-retention limits depend on your plan. See Tool limits.
- The
filevalue in file mode must be the exact storage key returned by the upload workflow. - For URL and file modes, the submission response confirms acceptance; use the returned
status_urlto check the job. - Download URLs are temporary, and their retention period depends on your plan.