Skip to content

YAML Minify API Documentation

Overview

The YAML Minify API provides a way to reduce YAML file size by removing unnecessary whitespace, indentation, and line breaks while preserving the structure and data integrity.
It supports single and multi-document YAML inputs and returns a compact version suitable for storage or transmission.

This API supports three input modes:

  • Body Mode – Direct YAML content in the request body.
  • URL Mode – Remote YAML file accessible via HTTP/HTTPS.
  • File Mode – Previously uploaded YAML file stored in S3.

The output is a downloadable YAML file link along with a preview snippet.


Endpoint (POST)

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

Headers

Header Description Required Example
Content-Type MIME type of the request body Yes application/x-yaml
x-source-type Input source type: body, url, or file Yes body
x-api-key Your API key for authentication Yes abcd1234xyz

Accepted File Extensions

The following file extensions are supported for this tool:

yml, yaml, txt, log


Input Example (Body Mode)

name: Example
items:
  - id: 1
    value: "A"
  - id: 2
    value: "B"

Input Example (URL Mode)

{
  "url": "https://example.com/sample.yaml"
}

Input Example (File Mode)

{
  "file": "user_uploads/abc123/sample.yaml"
}

Example Request

Synchronous (Body Input)

curl -X POST "https://api.apidatatools.com/yaml-minify-api" \
  -H "Content-Type: application/x-yaml" \
  -H "x-source-type: body" \
  -H "x-api-key: YOUR_API_KEY" \
  -d 'name: Example
items:
  - id: 1
    value: "A"
  - id: 2
    value: "B"'

Asynchronous (Remote File URL)

curl -X POST "https://api.apidatatools.com/yaml-minify-api" \
  -H "Content-Type: application/json" \
  -H "x-source-type: url" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{"url": "https://example.com/sample.yaml"}'

Asynchronous (Input File)

curl -X POST "https://api.apidatatools.com/yaml-minify-api" \
  -H "Content-Type: application/json" \
  -H "x-source-type: file" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{"file": "user_uploads/abc123/sample.yaml"}'

Example Response

Successful (Body Mode)

{
  "status": "success",
  "request_id": "b7f1a2e4-9c3d-4b6a-8f5a-2f7d9b1c3a11",
  "file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.yaml",
  "preview": "{name: Example, items: [{id: 1, value: A}, {id: 2, value: B}]}"
}

Async Job Accepted

{
  "status": "accepted",
  "job_id": "job-8a9b2c3d-4e5f-6789-0abc-def123456789",
  "status_url": "https://api.apidatatools.com/jobs/job-8a9b2c3d-4e5f-6789-0abc-def123456789",
  "request_id": "b7f1a2e4-9c3d-4b6a-8f5a-2f7d9b1c3a11"
}

Error Handling

Error Code HTTP Status Description Example
INVALID_YAML 400 YAML validation failed due to syntax error {"status":"error","error":"INVALID_YAML","details":{"message":"YAML validation failed."}}
YAML_MINIFY_FAILED 400 Failed to minify YAML due to internal serialization issue {"status":"error","error":"YAML_MINIFY_FAILED","details":{"message":"Failed to minify YAML."}}
INVALID_BODY_ENCODING 400 Request body could not be decoded from Base64 {"status":"error","error":"INVALID_BODY_ENCODING","details":{"message":"Failed to base64-decode request body."}}
EMPTY_BODY 400 Request body is empty {"status":"error","error":"EMPTY_BODY","details":{"message":"Request body is empty."}}
FILE_TOO_LARGE 413 File exceeds plan limit {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"File exceeds plan limit."}}
INVALID_URL 400 Provided URL is invalid or unreachable {"status":"error","error":"INVALID_URL","details":{"message":"URL must be valid http/https."}}
URL_NOT_OK 400 Remote file returned non-200 HTTP status {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404, expected 200."}}
INVALID_FILE_EXTENSION 400 File extension not supported for this tool {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Extension '.zip' is not allowed for 'yaml-minify-api'."}}
INTERNAL_ERROR 500 Unexpected server-side error {"status":"error","error":"INTERNAL_ERROR","details":{"message":"Failed to process your request"}}

Async Job Status

To check the status of an asynchronous job (URL or File mode), use the Status API:

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

Example Status Response for Async

Queued

{
  "job_id": "job-8a9b2c3d-4e5f-6789-0abc-def123456789",
  "status": "queued",
  "message": "Your job is being processed.",
  "retry_after": 2
}

Success

{
  "job_id": "job-8a9b2c3d-4e5f-6789-0abc-def123456789",
  "status": "success",
  "created_at": 1712345678,
  "updated_at": 1712345690,
  "result": {
    "status": "success",
    "request_id": "b7f1a2e4-9c3d-4b6a-8f5a-2f7d9b1c3a11",
    "file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.yaml",
    "preview": "{name: Example, items: [{id: 1, value: A}, {id: 2, value: B}]}"
  }
}

Failed

{
  "job_id": "job-8a9b2c3d-4e5f-6789-0abc-def123456789",
  "status": "failed",
  "error": {
    "code": "INVALID_YAML",
    "message": "YAML validation failed.",
    "details": {"line": 3, "column": 5}
  }
}

Notes for Developers

  • The API automatically validates YAML syntax before minification.
  • Multi-document YAML files are supported and preserved in output.
  • The preview field contains the first 100 KB of the minified YAML for quick inspection.
  • For large files or remote sources, use URL or File mode to create asynchronous jobs.
  • Each response includes a unique request_id for traceability.
  • Async jobs can be monitored using the Status API endpoint.
  • Output files are stored securely and expire based on the plan’s retention policy.
  • Ensure proper file extension validation when using URL or File mode.