Skip to content

JSON Formatter API

Overview

Formats JSON input. Body mode processes the request synchronously; URL and file modes submit an asynchronous job.

Endpoint

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

Authentication

Include your API key in the x-api-key header:

x-api-key: YOUR_API_KEY

Input modes

Select a mode with x-source-type:

Mode Behavior
body Sends input in the request body and processes it synchronously. This is the default.
url Submits a URL for asynchronous processing.
file Submits a pre-uploaded file reference for asynchronous processing.

Headers

Header names are case-insensitive. The lowercase spellings shown here are the documented forms.

Header Type Required Default / values Description
x-api-key String Yes Your API key Authenticates the request.
x-source-type String No Defaults to body; body, url, or file Selects the input mode.

Accepted file extensions

For URL and file modes, the input file must have one of these extensions:

  • .txt
  • .json
  • .log

Request body

Body mode

Send the JSON text to format as the raw request body.

URL mode

Send a JSON object with a url field:

{"url":"https://example.com/input.json"}

The URL must use HTTP or HTTPS and point to a file with an accepted extension.

File mode

Send a JSON object with a file field. Its value must be 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/json-formatter-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  --data-raw '{"name":"Ada","active":true}'

URL mode

curl -X POST 'https://api.apidatatools.com/json-formatter-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-formatter-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 response

Body mode returns HTTP 200. The synchronous response includes request_id, status, and preview. If the result is a file, it also includes file.

Data response:

{
  "request_id": "REQUEST_ID",
  "status": "success",
  "preview": "SERIALIZED_JSON"
}

File response:

{
  "request_id": "REQUEST_ID",
  "status": "success",
  "file": "https://downloads.apidatatools.com/OUTPUT_FILE",
  "preview": "OUTPUT_PREVIEW"
}

Asynchronous submission

URL and file modes return HTTP 202:

{
  "status": "accepted",
  "job_id": "JOB_ID",
  "status_url": "https://api.apidatatools.com/jobs/JOB_ID",
  "request_id": "REQUEST_ID"
}

Async job status

Retrieve a job’s status with:

curl -X GET 'https://api.apidatatools.com/jobs/JOB_ID' \
  -H 'x-api-key: YOUR_API_KEY'

The status endpoint returns HTTP 200 for a successful status lookup. Responses include request_id, job_id, status, created_at, and updated_at. The timestamps are Unix timestamps in seconds.

Queued and processing

For either queued or processing status, the response also includes message and retry_after:

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

The status value is queued or processing, as applicable.

Success

{
  "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",
    "preview": "OUTPUT_PREVIEW"
  }
}

Failed

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "failed",
  "created_at": 1730000000,
  "updated_at": 1730000002,
  "error": {
    "code": "ERROR_CODE",
    "message": "Error message",
    "details": {
      "message": "Error message"
    }
  }
}

Error handling

HTTP error responses use this envelope. details may contain additional fields.

{
  "status": "error",
  "error": "ERROR_CODE",
  "request_id": "REQUEST_ID",
  "details": {
    "message": "Error message"
  }
}

The following HTTP statuses and error codes are defined for this endpoint and its asynchronous workflow:

HTTP status Error codes
400 INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY, INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION, INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR
401 UNAUTHORIZED
404 USER_NOT_FOUND, UNKNOWN_FUNCTION
413 PAYLOAD_TOO_LARGE, FILE_TOO_LARGE
429 QUOTA_EXCEEDED, RATE_LIMITED
500 PLAN_NOT_FOUND, INTERNAL_ERROR, CONFIG_ERROR, PLAN_CONFIG_ERROR

Asynchronous jobs can also fail with INVALID_JOB, DOWNLOAD_FAILED, or UPLOAD_FAILED. These are job error codes, not HTTP statuses for the initial submission request.

Notes

  • Request-body and file-size limits, quotas, and rate limits depend on your plan. See tool limits.
  • Download URLs are temporary. File retention depends on your plan.
  • For file mode, use the exact storage key provided by the upload workflow; do not add a prefix.