Skip to content

JSON Flatten API

Overview

Flattens nested JSON into an object whose keys are RFC 6901 JSON Pointer paths.

Endpoint

POST https://api.apidatatools.com/json-flatten-api

Authentication

Include x-api-key: YOUR_API_KEY.

Input modes

Supports body (default), url, and file; URL and file requests run asynchronously.

Headers

Header Required Default Description
x-api-key Yes — API key.
x-source-type No body Input mode.
x-preserve-empty No true Preserve empty objects and arrays. Boolean values accept 1, true, yes, or on as true.

Accepted file extensions

.txt, .json, and .log.

curl example

curl -X POST 'https://api.apidatatools.com/json-flatten-api' \\
  -H 'x-api-key: YOUR_API_KEY' \\
  --data-raw '{"user":{"name":"Ada","roles":["admin"]}}'

The output is equivalent to:

{"/user/name":"Ada","/user/roles/0":"admin"}

URL and file mode requests

URL mode sends {"url":"https://example.com/input.json"} with x-source-type: url. File mode sends {"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"} with x-source-type: file. Include x-preserve-empty when submitting if required.

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

Body mode returns HTTP 200 with request_id, status, temporary file, and preview. Async 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

Poll GET https://api.apidatatools.com/jobs/JOB_ID with the same x-api-key. Queued and processing states include message and retry_after. Success includes result.file and result.preview; failure includes error.code, error.message, and error.details.

{"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}

Error handling

HTTP status Error codes
400 INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY, 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 submission can return INVALID_BODY, URL/file validation errors, FILE_TOO_LARGE, CONFIG_ERROR, or PLAN_CONFIG_ERROR. Status lookup errors include INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, and DDB_ERROR; worker failures can include INVALID_JOB, DOWNLOAD_FAILED, and UPLOAD_FAILED.

Notes

  • Body mode is synchronous; URL/file modes are asynchronous.
  • Honor retry_after; output URLs are temporary.
  • Limits and retention depend on your plan. See tool limits.