Skip to content

JSON to Base64 API

Overview

Converts JSON input to Base64. Body mode processes the request synchronously. URL and file modes submit an asynchronous job.

Endpoint

POST https://api.apidatatools.com/json-to-base64-api

Authentication

Send your API key in the x-api-key header.

Input modes

Mode Behavior
body Synchronous. Send the JSON text as the raw request body.
url Asynchronous. Send a JSON object containing the URL of the input file.
file Asynchronous. Send a JSON object containing the file key returned by the upload workflow.

Headers

Header Type Required Default / values Description
x-api-key string Yes — API key used to authenticate the request.
x-source-type string No body; body, url, or file Selects the input mode. Header names are case-insensitive.

Accepted file extensions

For URL and file modes, the input file extension must be one of:

  • .txt
  • .json
  • .log

Request body

Body mode

Send the JSON document as raw text. Do not wrap it in a JSON object.

URL mode

Send a JSON object with a url string containing an HTTP or HTTPS URL:

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

File mode

Send a JSON object with a file string containing the exact storage key returned by the upload workflow:

{
  "file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}

Examples

Synchronous body mode

curl -X POST "https://api.apidatatools.com/json-to-base64-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-source-type: body" \
  --data-raw '{"message":"hello"}'

Asynchronous URL mode

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

Asynchronous file mode

curl -X POST "https://api.apidatatools.com/json-to-base64-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-source-type: file" \
  -H "Content-Type: application/json" \
  --data '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'

Success responses

Synchronous body mode

The synchronous response includes request_id, status, and preview. The preview is a string containing serialized JSON. Depending on the result type, a successful response may also include a file field with a temporary download URL.

Data-producing response shape:

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

File-producing response shape:

{
  "request_id": "REQUEST_ID",
  "status": "success",
  "file": "TEMPORARY_DOWNLOAD_URL",
  "preview": "PREVIEW"
}

URL and file modes

A successfully submitted asynchronous request 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 the returned status_url using GET. The status endpoint requires the same API key.

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

The response includes request_id, job_id, status, created_at, and updated_at.

Queued or processing

For statuses other than success and failed, the response also includes message and retry_after:

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

The status value is the job’s current status, such as queued or processing.

Success

A successful job response includes result, which contains the worker’s success response:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "success",
  "created_at": 1700000000,
  "updated_at": 1700000002,
  "result": {
    "status": "success",
    "file": "TEMPORARY_DOWNLOAD_URL",
    "preview": "PREVIEW"
  }
}

Failed

A failed job response includes error with code, message, and details:

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

Error handling

Error responses use this envelope; details may include additional fields:

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

The following HTTP statuses are established for request errors:

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; tool execution errors
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

INVALID_JOB, DOWNLOAD_FAILED, and UPLOAD_FAILED can appear as errors in the asynchronous job’s failed status; they do not indicate the HTTP status of the status-polling response.

Notes

  • Body mode is synchronous; URL and file modes are asynchronous.
  • Body-size and file-size limits, quota, rate limits, and download retention depend on your plan. See tool limits.
  • Download URLs are temporary. Their retention period depends on your plan.