Skip to content

YAML Formatter API

Overview

Formats YAML input. Body mode processes text synchronously; URL and file modes create an asynchronous job.

Endpoint

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

Authentication

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

Input modes

Mode Processing Description
body Synchronous Submit YAML text directly. This is the default mode.
url Asynchronous Submit a URL to a YAML file.
file Asynchronous Submit a file reference returned by the upload workflow.

Headers

Header names are case-insensitive. The table shows their documented lowercase spelling.

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

Accepted file extensions

For URL and file modes, the accepted extensions are .yml, .yaml, .txt, and .log.

Request body

  • Body mode: Send raw YAML text as the request body.
  • URL mode: Send a JSON object with a url string.
  • File mode: Send a JSON object with a file string containing the exact storage key associated with the uploaded file.

curl examples

Body mode

curl -X POST 'https://api.apidatatools.com/yaml-formatter-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'x-source-type: body' \
  --data-raw 'name: Ada
role: engineer'

URL mode

curl -X POST 'https://api.apidatatools.com/yaml-formatter-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'x-source-type: url' \
  --data-raw '{"url":"https://files.example.com/input.yaml"}'

File mode

curl -X POST 'https://api.apidatatools.com/yaml-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 body mode

A successful file-producing response has HTTP 200 and includes a download URL and preview:

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

Asynchronous URL and file modes

A successfully accepted job has HTTP 202:

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

Async job status

Fetch the job status using the returned job_id. Include your API key.

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

The status response includes request_id, job_id, status, created_at, and updated_at. The timestamps are Unix timestamps.

Queued or processing

For either queued or processing, the response also includes a message and retry delay:

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

Success

A completed job includes its result:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "success",
  "created_at": 1710000000,
  "updated_at": 1710000002,
  "result": {
    "status": "success",
    "file": "TEMPORARY_DOWNLOAD_URL",
    "preview": "FORMATTED_OUTPUT_PREVIEW"
  }
}

Failed

A failed job includes an error code, message, and details object:

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

Error handling

Errors use this envelope. Additional fields may appear inside details.

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

Request and job-creation 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
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

Job-status errors

The job-status endpoint returns HTTP 400 for the following job errors: INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, and DDB_ERROR. Authentication errors can also occur when requesting job status.

Errors encountered while processing an accepted job are reported in the failed job’s error object. These can include DOWNLOAD_FAILED, FILE_TOO_LARGE, UPLOAD_FAILED, or INTERNAL_ERROR.

Notes

  • Request-body and file-size limits, quota, rate limits, and download retention depend on your plan. See tool limits.
  • Download URLs are temporary; retention depends on your plan.