JSON Schema Validator API¶
Overview¶
Validates JSON data against a JSON Schema Draft 2020-12 schema and returns a validation report.
Endpoint¶
POST https://api.apidatatools.com/json-schema-validator-api
Authentication¶
Include x-api-key: YOUR_API_KEY.
Input modes¶
| Mode | Behavior |
|---|---|
body | Validates the request body synchronously. This is the default. |
url | Queues a public input file for asynchronous validation. |
file | Queues a previously uploaded file for asynchronous validation. |
Headers¶
| Header | Required | Default / values | Description |
|---|---|---|---|
x-api-key | Yes | — | API key. |
x-source-type | No | body; body, url, file | Input mode. |
Accepted file extensions¶
.txt, .json, and .log.
Request body¶
Send an object containing both data and schema:
{"data":{"age":21},"schema":{"type":"object","properties":{"age":{"type":"integer"}},"required":["age"]}}
Remote schema references are not allowed; $ref values must be local references beginning with #.
URL and file bodies¶
URL mode uses {"url":"https://example.com/input.json"}. File mode uses {"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}. The URL must be public; the file value must be the exact upload key.
cURL examples¶
Body mode¶
curl -X POST 'https://api.apidatatools.com/json-schema-validator-api' \\
-H 'x-api-key: YOUR_API_KEY' \\
--data-raw '{"data":{"age":21},"schema":{"type":"object","properties":{"age":{"type":"integer"}},"required":["age"]}}'
URL mode¶
curl --request POST \
--url https://api.apidatatools.com/json-schema-validator-api \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: url' \
--header 'Content-Type: application/json' \
--data '{"url":"https://example.com/input.json"}'
File mode¶
curl --request POST \
--url https://api.apidatatools.com/json-schema-validator-api \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-source-type: file' \
--header 'Content-Type: application/json' \
--data '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Result¶
The generated JSON report contains valid and errors. Each error includes message, path, schema_path, and validator. At most 100 errors are returned; truncated is set when more exist.
Success responses¶
Body mode returns HTTP 200 with request_id, status, a temporary file URL, and preview. URL/file 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¶
curl --request GET \
--url https://api.apidatatools.com/jobs/JOB_ID \
--header 'x-api-key: YOUR_API_KEY'
Queued and processing responses include created_at, updated_at, message, and retry_after. A successful response has status: "success" and a result object containing file and preview. A failed response has status: "failed" and an error object containing code, message, and details.
Error handling¶
{"status":"error","error":"ERROR_CODE","request_id":"REQUEST_ID","details":{"message":"Description of the error."}}
| HTTP status | Error codes |
|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY, INVALID_SCHEMA_BODY, INVALID_JSON_SCHEMA, REMOTE_SCHEMA_REF_NOT_ALLOWED, INVALID_JSON, INVALID_JSON_ENCODING, JSON_TOO_DEEP |
401 | UNAUTHORIZED |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION |
413 | PAYLOAD_TOO_LARGE |
429 | QUOTA_EXCEEDED, RATE_LIMITED |
500 | PLAN_NOT_FOUND, AUTH_ERROR, INTERNAL_ERROR |
Async submissions can return INVALID_BODY, URL/file validation errors, FILE_TOO_LARGE, CONFIG_ERROR, or PLAN_CONFIG_ERROR. Processing can fail with INVALID_JOB, DOWNLOAD_FAILED, UPLOAD_FAILED, or a schema-validation error. Status lookups can return INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, or DDB_ERROR.
Notes¶
- Body mode is synchronous; URL and file modes are asynchronous.
- Honor
retry_afterwhen polling. - Plan limits control body/file sizes, quotas, rates, and output retention. See tool limits.
- Output URLs are temporary.