YAML to Base64 API Documentation¶
Overview¶
The YAML to Base64 API converts valid YAML content into a Base64-encoded text representation.
It validates the YAML structure before encoding and returns the Base64 string as a downloadable text file.
This API supports Body, URL, and File input modes.
Base URL: https://api.apidatatools.com/yaml-to-base64-api
Endpoint (POST)¶
POST https://api.apidatatools.com/yaml-to-base64-api
Headers¶
| Header | Type | Required | Description |
|---|---|---|---|
Content-Type | application/json or text/plain | Yes | Defines the content type of the request body. |
x-api-key | string | Yes | Your API key for authentication. |
x-source-type | string | Optional | Defines the input mode. Accepted values: body, url, file. Default is body. |
Accepted File Extensions¶
| Mode | Supported Extensions |
|---|---|
| URL / File | .yml, .yaml, .txt, .log |
Input Example (Body Mode)¶
name: Example
version: 1.0
items:
- id: 1
value: test
Input Example (URL Mode)¶
{
"url": "https://example.com/sample.yaml"
}
Input Example (File Mode)¶
{
"file": "user_uploads/upl_1234567890abcdef/sample.yaml"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/yaml-to-base64-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: text/plain" \
-H "x-source-type: body" \
--data-binary @sample.yaml
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/yaml-to-base64-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: url" \
-d '{"url": "https://example.com/sample.yaml"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/yaml-to-base64-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: file" \
-d '{"file": "user_uploads/upl_1234567890abcdef/sample.yaml"}'
Example Response¶
Successful (Body Mode)¶
{
"status": "success",
"request_id": "c1a2b3d4-5678-90ef-1234-567890abcdef",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abcdef1234567890.txt",
"preview": "bmFtZTogRXhhbXBsZQp2ZXJzaW9uOiAxLjAKaXRlbXM6CiAgLSBpZDogMQogICAgdmFsdWU6IHRlc3QK"
}
Async Job Accepted (URL or File Mode)¶
{
"status": "accepted",
"job_id": "b1234567-89ab-cdef-0123-456789abcdef",
"status_url": "https://api.apidatatools.com/jobs/b1234567-89ab-cdef-0123-456789abcdef",
"request_id": "a1b2c3d4-5678-90ef-1234-567890abcdef"
}
Error Handling¶
| Error Code | HTTP Status | Description | Example |
|---|---|---|---|
INVALID_YAML | 400 | The YAML input is invalid or malformed. | {"status":"error","error":"INVALID_YAML","details":{"message":"YAML validation failed."}} |
BASE64_ENCODING_FAILED | 400 | Failed to encode YAML to Base64. | {"status":"error","error":"BASE64_ENCODING_FAILED","details":{"message":"Failed to encode YAML to Base64."}} |
INVALID_URL | 400 | The provided URL is invalid or missing. | {"status":"error","error":"INVALID_URL","details":{"message":"Missing or invalid 'url'."}} |
URL_UNREACHABLE | 400 | The remote file could not be reached. | {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL."}} |
URL_NOT_OK | 400 | The remote file returned a non-200 HTTP status. | {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404, expected 200."}} |
FILE_TOO_LARGE | 413 | The file exceeds the plan’s maximum allowed size. | {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"Remote file exceeds plan limit."}} |
INVALID_FILE_EXTENSION | 400 | Unsupported file extension for this tool. | {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Invalid or unsupported file extension."}} |
EMPTY_BODY | 400 | The request body is empty. | {"status":"error","error":"EMPTY_BODY","details":{"message":"Request body is empty."}} |
PAYLOAD_TOO_LARGE | 413 | The request body exceeds the plan limit. | {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds limit."}} |
INTERNAL_ERROR | 500 | Unexpected internal server 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.
Endpoint:
GET https://api.apidatatools.com/jobs/{job_id}
Example Status Response for Async¶
Queued / Processing¶
{
"job_id": "b1234567-89ab-cdef-0123-456789abcdef",
"status": "queued",
"created_at": 1712345678,
"updated_at": 1712345678,
"message": "Your job is being processed.",
"retry_after": 2
}
Success¶
{
"job_id": "b1234567-89ab-cdef-0123-456789abcdef",
"status": "success",
"created_at": 1712345678,
"updated_at": 1712345690,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abcdef1234567890.txt",
"request_id": "a1b2c3d4-5678-90ef-1234-567890abcdef",
"preview": "bmFtZTogRXhhbXBsZQp2ZXJzaW9uOiAxLjAKaXRlbXM6CiAgLSBpZDogMQogICAgdmFsdWU6IHRlc3QK"
}
}
Failed¶
{
"job_id": "b1234567-89ab-cdef-0123-456789abcdef",
"status": "failed",
"created_at": 1712345678,
"updated_at": 1712345680,
"error": {
"code": "INVALID_YAML",
"message": "YAML validation failed.",
"details": {
"message": "mapping values are not allowed here",
"line": 3,
"column": 5
}
}
}
Notes for Developers¶
-
The API supports three input modes:
-
Body Mode: Direct YAML text in the request body (synchronous).
- URL Mode: Remote YAML file via public HTTP/HTTPS URL (asynchronous).
-
File Mode: YAML file uploaded to the platform (asynchronous).
-
For asynchronous operations (
urlorfile), ajob_idis returned immediately.
Use the Status API to poll for job completion. -
The response always includes a unique
request_idfor traceability. -
The output file is stored temporarily and accessible via a secure download URL.
-
Ensure that the YAML input is syntactically valid before submission to avoid
INVALID_YAMLerrors.