Skip to content

String Reverse API

Overview

Reverse UTF-8 text synchronously, or submit a text file by URL or uploaded-file reference for asynchronous processing.

The x-reverse-option header selects how the text is reversed:

  • char reverses the text character by character.
  • word-order reverses the order of whitespace-separated words and joins them with single spaces.
  • each-word reverses the characters in each whitespace-separated word and joins the words with single spaces.

Endpoint

Method URL
POST https://api.apidatatools.com/string-reverse-api

Authentication

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

Input modes

Choose a mode with x-source-type:

  • body — synchronous; send text directly in the request body. This is the default.
  • url — asynchronous; provide a URL to a .txt file in a JSON request body.
  • file — asynchronous; provide the exact storage key returned by the upload workflow in a JSON request body.

Headers

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

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-reverse-option string No Default: char; values: char, word-order, each-word Selects the reversal behavior.

Accepted file extensions

URL and file modes accept .txt files.

Request body

Body mode

Send the text as raw request-body text. Do not wrap it in JSON. Empty bodies and text containing only whitespace are rejected.

URL mode

Send a JSON object containing the URL of the input file:

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

File mode

Send a JSON object containing the exact storage key returned by 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/string-reverse-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'x-source-type: body' \
  -H 'x-reverse-option: char' \
  --data-raw 'Hello, world!'

URL mode

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

File mode

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

Success responses

Synchronous body mode

A successful request returns HTTP 200. The preview contains the transformed text.

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

The download URL is temporary; 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"
}

Async job status

Check a job with:

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

Use the same x-api-key authentication header. A successful status lookup returns HTTP 200.

Queued and processing jobs include the following fields:

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

For a processing job, status is "processing"; the other fields have the same shape.

A completed job includes its result:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "success",
  "created_at": 1760000000,
  "updated_at": 1760000001,
  "result": {
    "status": "success",
    "file": "https://downloads.apidatatools.com/OUTPUT_FILE",
    "preview": "!"
  }
}

A failed job includes its error:

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

The error details can include additional fields.

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 grounded in the API handlers:

HTTP status Error codes and circumstances
400 INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY, INVALID_REVERSE_OPTION, INVALID_TEXT, INVALID_UTF8, MISSING_INPUT_FILE, INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION; status lookup errors INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR; and other input/tool errors.
401 UNAUTHORIZED
404 UNKNOWN_FUNCTION, USER_NOT_FOUND
413 PAYLOAD_TOO_LARGE, FILE_TOO_LARGE
429 QUOTA_EXCEEDED, RATE_LIMITED
500 INTERNAL_ERROR, PLAN_NOT_FOUND, CONFIG_ERROR, PLAN_CONFIG_ERROR

Async jobs can also fail with INVALID_JOB, DOWNLOAD_FAILED, or UPLOAD_FAILED. These are reported in the job’s failed status response; they are not HTTP statuses for the status lookup itself.

Notes

  • Body mode is synchronous. URL and file modes are asynchronous.
  • Request-body, file-size, quota, rate, and download-retention limits depend on your plan. See tool limits.
  • A successful result file is available only for a limited time; retention depends on your plan.