YAML to JSON API¶
Overview¶
Convert YAML input to JSON using the API at https://api.apidatatools.com/yaml-to-json-api.
Body mode processes raw YAML synchronously. URL and file modes submit an asynchronous job.
Endpoint¶
| Method | URL |
|---|---|
POST | https://api.apidatatools.com/yaml-to-json-api |
Authentication¶
Include your API key in the x-api-key header on every request:
x-api-key: YOUR_API_KEY
Input modes¶
Select a mode with the x-source-type header:
body— Send YAML text in the request body. This is the default mode and runs synchronously.url— Send a JSON body containing a URL to a YAML file. This mode runs asynchronously.file— Send a JSON body containing a pre-uploaded file reference. This mode runs asynchronously. Use the exact storage key returned by the upload workflow.
Headers¶
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | string | Yes | — | API key used to authenticate 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¶
URL and file modes accept these extensions:
.yml.yaml.txt.log
Request body¶
Body mode¶
Send raw YAML text as the request body. The body must not be empty.
URL mode¶
Send a JSON object with a url string:
{
"url": "https://example.com/input.yaml"
}
The URL must be a reachable HTTP or HTTPS URL, and the file extension must be accepted.
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/yaml-to-json-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: body' \
--data-raw $'name: Ada\nactive: true\n'
URL mode¶
curl -X POST 'https://api.apidatatools.com/yaml-to-json-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: url' \
--data-raw '{"url":"https://example.com/input.yaml"}'
File mode¶
curl -X POST 'https://api.apidatatools.com/yaml-to-json-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 data-producing response has HTTP 200 and includes the request ID, status, and preview. The preview contains serialized JSON.
{
"request_id": "REQUEST_ID",
"status": "success",
"preview": "{\n \"name\": \"Ada\",\n \"active\": true\n}"
}
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 job with:
GET https://api.apidatatools.com/jobs/{job_id}
x-api-key: YOUR_API_KEY
The status response includes request_id, job_id, status, created_at, and updated_at. Timestamps are Unix timestamps.
Queued¶
{
"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
}
Processing¶
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "processing",
"created_at": 1730000000,
"updated_at": 1730000001,
"message": "Your job is being processed.",
"retry_after": 2
}
Success¶
A successful job response includes a result object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1730000000,
"updated_at": 1730000002,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE.json",
"preview": "..."
}
}
Failed¶
A failed job response includes an error object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1730000000,
"updated_at": 1730000002,
"error": {
"code": "DOWNLOAD_FAILED",
"message": "Unable to download input.",
"details": {
"message": "Unable to download input."
}
}
}
The error code, message, and details depend on the failure.
Error handling¶
API errors use this envelope:
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Error description."
}
}
Additional fields may appear in details.
HTTP errors¶
| HTTP status | Error codes | Description |
|---|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY | Invalid source type, 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 input, unreachable or unsuccessful URL, unavailable file, or unsupported extension. |
400 | INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR | Job status request errors. |
401 | UNAUTHORIZED | Authentication is missing or invalid. |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION | User or requested API endpoint was not found. |
413 | PAYLOAD_TOO_LARGE, FILE_TOO_LARGE | Request body or input file exceeds the applicable limit. |
429 | QUOTA_EXCEEDED, RATE_LIMITED | Request quota or rate limit was reached. |
500 | PLAN_NOT_FOUND, CONFIG_ERROR, PLAN_CONFIG_ERROR, INTERNAL_ERROR | Plan configuration, service configuration, or processing error. |
Asynchronous processing failures, including DOWNLOAD_FAILED, UPLOAD_FAILED, and INVALID_JOB, are reported in the job’s failed status response. They are job error codes rather than HTTP statuses for the original 202 response.
Notes¶
- Body-size, file-size, quota, rate, and download-retention limits depend on your plan. See API tool limits.
- Download URLs are temporary; retention depends on your plan.