Skip to content

Base64 to JSON API

Overview

Decode Base64-encoded JSON text and format the decoded JSON. Body mode processes the request synchronously. URL and file modes submit an asynchronous job.

Endpoint

  • Method: POST
  • URL: https://api.apidatatools.com/base64-to-json-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:

Mode Processing Input
body Synchronous Raw text containing Base64-encoded JSON
url Asynchronous JSON body containing a URL to a Base64 text file
file Asynchronous JSON body containing a pre-uploaded file reference

If x-source-type is omitted, it defaults to body.

Headers

Header names are case-insensitive. The spellings below are lowercase.

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.
x-tab-space integer string No Default: 1; values are clamped to 1–8 Sets the indentation width in the formatted JSON output. Invalid values use 1.
x-record-path string No No default This operation does not use this header.
x-root-name string No No default This operation does not use this header.

Accepted file extensions

URL and file modes accept files with these extensions:

  • .txt
  • .log

Request body

Body mode

Send the Base64-encoded JSON as raw text in the request body. Do not wrap it in JSON.

URL mode

Send a JSON object with a url property:

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

The URL must refer to a file with an accepted extension.

File mode

Send a JSON object with a file property containing 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/base64-to-json-api" \
  -H "x-api-key: YOUR_API_KEY" \
  --data-raw 'eyJoZWxsbyI6IndvcmxkIn0='

URL mode

curl -X POST "https://api.apidatatools.com/base64-to-json-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-source-type: url" \
  --data-raw '{"url":"https://example.com/input.txt"}'

File mode

curl -X POST "https://api.apidatatools.com/base64-to-json-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 response has HTTP 200 and includes a download URL and a preview of the formatted JSON:

{
  "request_id": "REQUEST_ID",
  "status": "success",
  "file": "https://downloads.apidatatools.com/OUTPUT_FILE",
  "preview": "{\n \"hello\": \"world\"\n}"
}

The preview is a string containing serialized JSON. The file URL is temporary; download retention depends on your plan.

Asynchronous URL and file modes

A successfully accepted job returns HTTP 202:

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

Acceptance means the job was queued; check its status endpoint for the result.

Async job status

Poll the status_url, or send an authenticated GET request to:

https://api.apidatatools.com/jobs/{job_id}

For example:

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 retrieved job. Its response includes request_id, job_id, status, created_at, and updated_at.

Queued and processing

Both queued and processing responses include a message and retry_after:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "queued",
  "created_at": 1710000000,
  "updated_at": 1710000000,
  "message": "Your job is being processed.",
  "retry_after": 2
}

The status value is queued or processing, as applicable.

Success

A completed job includes a result object:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "success",
  "created_at": 1710000000,
  "updated_at": 1710000002,
  "result": {
    "status": "success",
    "file": "https://downloads.apidatatools.com/OUTPUT_FILE",
    "preview": "{\n \"hello\": \"world\"\n}"
  }
}

Failed

A failed job includes an error object. Its details contains the job error details, including the message:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "failed",
  "created_at": 1710000000,
  "updated_at": 1710000002,
  "error": {
    "code": "DOWNLOAD_FAILED",
    "message": "Download error message",
    "details": {
      "message": "Download error message"
    }
  }
}

The error code and message vary with the failure. A failed job is reported in the status response; it does not change the HTTP 200 returned for a successful status lookup.

Error handling

API errors use this envelope:

{
  "status": "error",
  "error": "ERROR_CODE",
  "request_id": "REQUEST_ID",
  "details": {
    "message": "Description of the error"
  }
}

Additional fields may appear in details.

Request and processing errors

HTTP status Error code(s) When it applies
400 INVALID_BODY_ENCODING The request body could not be decoded from its transport encoding.
400 EMPTY_BODY The request body is empty.
400 INVALID_JSON, JSON_TOO_DEEP, BASE64_DECODE_FAILED, MISSING_INPUT_FILE The Base64 input could not be decoded or the decoded JSON could not be processed.
400 INVALID_SOURCE_TYPE x-source-type is not body, url, or file.
404 UNKNOWN_FUNCTION The requested endpoint is not supported.
413 PAYLOAD_TOO_LARGE The body exceeds the limit for the plan.
500 INTERNAL_ERROR An unexpected processing error occurred.

Authentication and usage errors

HTTP status Error code(s)
401 UNAUTHORIZED
404 USER_NOT_FOUND
429 QUOTA_EXCEEDED, RATE_LIMITED
500 PLAN_NOT_FOUND

Asynchronous submission errors

These errors can occur when validating or accepting URL and file mode requests.

HTTP status Error code(s)
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 lookup errors

Job-status lookup validation and access errors are returned as HTTP 400; an unexpected server error is returned as HTTP 500.

HTTP status Error code(s)
400 INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR
500 INTERNAL_ERROR

Job execution errors such as DOWNLOAD_FAILED, UPLOAD_FAILED, FILE_TOO_LARGE, and INVALID_JOB appear in the error object of a job with status: "failed".

Notes

  • Body mode accepts raw text, not a JSON wrapper. The text is Base64-decoded and the decoded content must be valid JSON.
  • Body-size and file-size limits, quota, rate limits, and download retention depend on your plan. See tool limits.
  • Download URLs are temporary, and their retention period depends on your plan.