XML Minifier API¶
Overview¶
The XML Minifier API minifies XML. Body mode processes XML synchronously; URL and file modes create asynchronous jobs.
Endpoint¶
POST https://api.apidatatools.com/xml-minify-api
Authentication¶
Include your API key in the x-api-key header on every request:
x-api-key: YOUR_API_KEY
Input modes¶
| Mode | Behavior |
|---|---|
body | Synchronous. Send XML as the raw request body. This is the default mode. |
url | Asynchronous. Send a JSON object containing the URL of the input file. |
file | Asynchronous. Send a JSON object containing the exact storage key returned by the upload workflow. |
Headers¶
Header names are case-insensitive. The lowercase spellings below are used in this reference.
| 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¶
URL and file modes accept these input extensions:
txtxmllog
Request body¶
Body mode¶
Send the XML document as raw text in the request body. Do not wrap it in JSON.
URL mode¶
Send a JSON object with a url field:
{
"url": "https://example.com/input.xml"
}
The URL must use HTTP or HTTPS and have an accepted file extension.
File mode¶
Send a JSON object with a file field containing the exact storage key associated with a file uploaded through the upload workflow:
{
"file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}
Do not add a prefix to the storage key.
curl examples¶
Body mode¶
curl -X POST 'https://api.apidatatools.com/xml-minify-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: body' \
--data '<root><item>value</item></root>'
URL mode¶
curl -X POST 'https://api.apidatatools.com/xml-minify-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: url' \
--data '{"url":"https://example.com/input.xml"}'
File mode¶
curl -X POST 'https://api.apidatatools.com/xml-minify-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: file' \
--data '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous response¶
A successful synchronous response has HTTP status 200. File-producing results have this shape:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/temporary-output.xml",
"preview": "MINIFIED_XML_PREVIEW"
}
The file value is a temporary download URL. Its retention period depends on your plan.
For a data-producing result, the response shape is:
{
"request_id": "REQUEST_ID",
"status": "success",
"preview": "SERIALIZED_JSON"
}
Asynchronous acceptance¶
URL and file modes return HTTP 202 when the job is accepted:
{
"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:
GET https://api.apidatatools.com/jobs/{job_id}
Include x-api-key on the status request. The status response includes request_id, job_id, status, created_at, and updated_at. The status implementation returns the following additional fields according to job state.
Queued or processing:
{
"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
}
For a processing job, status is "processing"; the other fields have the same shape.
Success:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1700000000,
"updated_at": 1700000005,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/temporary-output.xml",
"preview": "MINIFIED_XML_PREVIEW"
}
}
Failed:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1700000000,
"updated_at": 1700000005,
"error": {
"code": "ERROR_CODE",
"message": "Description of the failure",
"details": {}
}
}
Example status request:
curl 'https://api.apidatatools.com/jobs/JOB_ID' \
-H 'x-api-key: YOUR_API_KEY'
Error handling¶
Errors use this envelope:
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Description of the error"
}
}
Additional fields may appear in details.
HTTP errors¶
| HTTP status | Error codes | When it applies |
|---|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY | Invalid input mode, 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, URL, file, or extension; or an unreachable/non-successful URL. |
400 | INVALID_JOB_ID, DDB_ERROR, JOB_NOT_FOUND, FORBIDDEN | Errors returned by the job-status endpoint. |
401 | UNAUTHORIZED | Authentication context is missing or invalid. |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION | User or API endpoint was not found. |
413 | PAYLOAD_TOO_LARGE | The synchronous request body exceeds the limit for your plan. |
413 | FILE_TOO_LARGE | The URL or uploaded file exceeds the applicable file-size limit. |
429 | QUOTA_EXCEEDED, RATE_LIMITED | Monthly quota or request rate limit was reached. |
500 | PLAN_NOT_FOUND, INTERNAL_ERROR | Plan configuration or request processing failed. |
500 | CONFIG_ERROR, PLAN_CONFIG_ERROR | Asynchronous job configuration or plan limits could not be used. |
Asynchronous jobs can also finish with INVALID_JOB, DOWNLOAD_FAILED, or UPLOAD_FAILED. These are job failure codes, not HTTP statuses for the initial submission.
Notes¶
- Body mode is synchronous. URL and file modes are asynchronous.
- Body-size, file-size, quota, rate, and output-retention limits depend on your plan. See API tool limits.
- Download URLs are temporary; retention is plan-dependent.