JSON Escape API¶
Overview¶
Escapes JSON input using the JSON Escape API. Body mode runs synchronously; URL and file modes submit an asynchronous job.
Endpoint¶
| Property | Value |
|---|---|
| Method | POST |
| URL | https://api.apidatatools.com/json-escape-api |
Authentication¶
Send your API key in the x-api-key header:
x-api-key: YOUR_API_KEY
Input modes¶
Select a mode with x-source-type:
body— send raw text for synchronous processing. This is the default.url— submit a URL for asynchronous processing.file— submit a reference to a previously uploaded file for asynchronous processing.
Headers¶
Header names are case-insensitive. The spellings below are the documented lowercase forms.
| 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, json, and log.
Request body¶
Body mode¶
Send the input as raw text. Do not wrap the text in a JSON object.
URL mode¶
Send a JSON object containing the URL:
{
"url": "https://example.com/input.json"
}
File mode¶
Send a JSON object 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/json-escape-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: body" \
--data-raw '{"message":"hello"}'
URL mode¶
curl -X POST "https://api.apidatatools.com/json-escape-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: url" \
--data-raw '{"url":"https://example.com/input.json"}'
File mode¶
curl -X POST "https://api.apidatatools.com/json-escape-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 includes request_id, status, and preview when the operation returns data. The preview is serialized JSON.
{
"request_id": "REQUEST_ID",
"status": "success",
"preview": "..."
}
If the operation returns a file, the response includes request_id, status, file, and preview:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/...",
"preview": "..."
}
Asynchronous URL and file modes¶
A successful job submission 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 your API key on the status request:
curl "https://api.apidatatools.com/jobs/JOB_ID" \
-H "x-api-key: YOUR_API_KEY"
The status response includes request_id, job_id, status, created_at, and updated_at.
For queued and processing jobs, it also includes:
{
"message": "Your job is being processed.",
"retry_after": 2
}
A success response includes a result object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 0,
"updated_at": 0,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/...",
"preview": "..."
}
}
A failed job includes an error object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 0,
"updated_at": 0,
"error": {
"code": "ERROR_CODE",
"message": "Error message",
"details": {
"message": "Error message"
}
}
}
Error handling¶
Error responses use this envelope. Additional fields may appear in details.
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Error message"
}
}
Request and authentication errors¶
| HTTP status | Error codes |
|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY |
401 | UNAUTHORIZED |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION |
413 | PAYLOAD_TOO_LARGE |
429 | QUOTA_EXCEEDED, RATE_LIMITED |
500 | PLAN_NOT_FOUND, INTERNAL_ERROR |
Asynchronous submission errors¶
| HTTP status | Error codes |
|---|---|
400 | INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION |
413 | FILE_TOO_LARGE |
500 | CONFIG_ERROR, PLAN_CONFIG_ERROR |
Job status and processing errors¶
The job-status endpoint reports lookup and access errors with HTTP 400: INVALID_JOB_ID, DDB_ERROR, JOB_NOT_FOUND, and FORBIDDEN.
Processing errors such as INVALID_JOB, FILE_TOO_LARGE, DOWNLOAD_FAILED, UPLOAD_FAILED, and INTERNAL_ERROR are reported in the job’s failed status response.
Notes¶
- Body-size, file-size, quota, and rate limits depend on your plan. See tool limits.
- Download URLs are temporary; file retention depends on your plan.
- URL and file inputs are processed asynchronously. Use the returned
status_urlto check job progress.