Skip to content

Base64 Encoder API

Overview

Encodes text input as Base64. The endpoint supports synchronous request-body processing and asynchronous processing from a URL or a pre-uploaded file.

Endpoint

Method Path URL
POST /base64-encoder-api https://api.apidatatools.com/base64-encoder-api

Authentication

Include your API key in the x-api-key header on every request.

Input modes

Select a mode with x-source-type:

  • body — synchronous; sends raw text in the request body. This is the default.
  • url — asynchronous; sends a JSON object containing a URL.
  • file — asynchronous; sends a JSON object containing the exact storage key returned by the upload workflow.

Headers

Header names are case-insensitive. The spellings below are the documented lowercase 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; supported values: body, url, file Selects synchronous body processing or an asynchronous input mode.
x-record-path string No No endpoint-specific default or values documented Recognized header; no Base64-encoder-specific behavior is established by the available source.
x-root-name string No No endpoint-specific default or values documented Recognized header; no Base64-encoder-specific behavior is established by the available source.
x-tab-space string No No endpoint-specific default or values documented Recognized header; no Base64-encoder-specific behavior is established by the available source.

Accepted file extensions

For URL and file modes, the accepted extensions are:

  • .txt
  • .log

Request body

Body mode

Send raw text as the request body. The request body must not be empty. Body-size limits depend on your plan.

URL mode

Send a JSON object with a url property:

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

File mode

Send a JSON object with a file property containing the exact storage key associated with the file uploaded through the upload workflow:

{
  "file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}

Do not add a prefix to the storage key.

curl examples

Body mode

curl -X POST "https://api.apidatatools.com/base64-encoder-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-source-type: body" \
  --data-raw 'Hello, world!'

URL mode

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

File mode

curl -X POST "https://api.apidatatools.com/base64-encoder-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

A successful body-mode request returns HTTP 200 with a serialized JSON response. The preview contains the Base64-encoded output; the file value is a temporary download URL.

{
  "request_id": "REQUEST_ID",
  "status": "success",
  "file": "https://downloads.apidatatools.com/TEMPORARY_FILE",
  "preview": "SGVsbG8sIHdvcmxkIQ=="
}

Asynchronous URL and file modes

A successfully accepted 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

Check an asynchronous job with:

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

The status endpoint returns the job ID, status, request ID, and timestamps. For queued and processing jobs, it also returns a message and retry_after. The status endpoint responds with HTTP 200 for a returned job status.

Queued

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

Processing

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

Success

On success, result contains the worker’s response body:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "success",
  "created_at": 0,
  "updated_at": 0,
  "result": {
    "status": "success",
    "file": "https://downloads.apidatatools.com/TEMPORARY_FILE",
    "preview": "SGVsbG8sIHdvcmxkIQ=="
  }
}

Failed

On failure, error contains the error code, message, and details from the job response:

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

Error handling

Error responses use this envelope. Additional fields may appear in details.

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

The following HTTP statuses are established by the backend:

HTTP status Error codes / cases
400 INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY; synchronous tool-execution errors; asynchronous input and validation errors including INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, and FILE_UNAVAILABLE; job-status errors including INVALID_JOB_ID, JOB_NOT_FOUND, and FORBIDDEN.
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; asynchronous configuration errors CONFIG_ERROR and PLAN_CONFIG_ERROR
Not specified as an HTTP response status DDB_ERROR, DOWNLOAD_FAILED, UPLOAD_FAILED, INVALID_JOB, and the remaining format-specific errors in the backend error catalog

Request-body and file-size limits depend on your plan. See tool limits.

Notes

  • Body mode is synchronous. URL and file modes create asynchronous jobs.
  • Download URLs are temporary. Their retention period depends on your plan.
  • Quota, rate limits, body-size limits, file-size limits, and retention are plan-dependent; no fixed values are stated here.