Skip to content

JSON from Schema API

Overview

Generates example JSON from a valid JSON Schema Draft 2020-12 schema.

Endpoint

POST https://api.apidatatools.com/json-from-schema-api

Authentication and input modes

Include x-api-key: YOUR_API_KEY. Supports body, url, and file; body mode is synchronous. Accepted extensions are .txt, .json, and .log.

Generation behavior

The generator prioritizes const, default, example, examples, the first oneOf or anyOf branch, and the first enum value. It generates primitive defaults otherwise. Remote $ref values are rejected.

curl example

curl -X POST 'https://api.apidatatools.com/json-from-schema-api' \\
  -H 'x-api-key: YOUR_API_KEY' \\
  --data-raw '{"type":"object","properties":{"name":{"type":"string"},"active":{"type":"boolean"}},"required":["name"]}'

URL and file modes

curl --request POST --url https://api.apidatatools.com/json-from-schema-api \
  --header 'x-api-key: YOUR_API_KEY' --header 'x-source-type: url' \
  --header 'Content-Type: application/json' --data '{"url":"https://example.com/schema.json"}'
curl --request POST --url https://api.apidatatools.com/json-from-schema-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"}'

Success and async process

Body mode returns HTTP 200 with generated JSON in file and preview. URL/file submission returns HTTP 202 with job_id, status_url, and request_id. Poll the status URL with the same API key. Queued/processing states include retry_after; success includes result; failure includes error.

Error handling

HTTP status Error codes
400 INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY, INVALID_JSON_SCHEMA, REMOTE_SCHEMA_REF_NOT_ALLOWED, SCHEMA_TOO_DEEP, INVALID_JSON, 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 errors include URL/file validation errors, FILE_TOO_LARGE, CONFIG_ERROR, PLAN_CONFIG_ERROR, DOWNLOAD_FAILED, and UPLOAD_FAILED. Status errors include INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, and DDB_ERROR.

Notes

  • Schema example generation is limited to 32 nested schema levels.
  • Honor retry_after. Plan limits and temporary output retention apply.