File Conversion API
Convert images (resize and reformat), CSV files (to structured JSON), HTML pages (to PDF), and DOCX documents (to PDF). Supports four conversion types controlled by the type discriminator field.
Endpoints
Section titled “Endpoints”Free test endpoint: GET /convert/test at https://x402-conversion-api-production.up.railway.app — returns fixture data, no wallet required.
Paid endpoint: POST /convert — $0.02 USDC on Base per call.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
type | string | Yes | — | Conversion type: "image", "csv", "html_pdf", or "docx" |
url | string | Yes | — | Source file URL (http/https, max 2048 chars, max 10MB) |
format | string | No (image only) | "jpeg" | Output format: "jpeg", "png", "webp", "gif" |
width | integer | No (image only) | — | Target width in pixels (1–8000) |
height | integer | No (image only) | — | Target height in pixels (1–8000) |
format, width, and height are only used when type is "image". They are ignored for "csv", "html_pdf", and "docx".
Example — curl
Section titled “Example — curl”# Free test (no wallet required)curl https://x402-conversion-api-production.up.railway.app/convert/test
# Paid call — image conversion (requires x402-fetch or x402-mcp-server)curl -X POST https://x402-conversion-api-production.up.railway.app/convert \ -H "Content-Type: application/json" \ -d '{"type": "image", "url": "https://example.com/photo.jpg", "format": "png", "width": 800}'
# Paid call — DOCX to PDF conversioncurl -X POST https://x402-conversion-api-production.up.railway.app/convert \ -H "Content-Type: application/json" \ -d '{"type": "docx", "url": "https://example.com/document.docx"}'Example — MCP Tool Call
Section titled “Example — MCP Tool Call”“Convert this image to PNG at 800px wide: https://example.com/photo.jpg”
{ "tool": "x402_convert_file", "arguments": { "type": "image", "url": "https://example.com/photo.jpg", "format": "png", "width": 800 }}Returns
Section titled “Returns”All conversion types return a data field containing base64-encoded output:
type: "image"— base64-decodedatato get image bytes in the requested formattype: "csv"— base64-decodedatato get a JSON array of objects (one object per row)type: "html_pdf"— base64-decodedatato get PDF binarytype: "docx"— base64-decodedatato get PDF binary (content-document fidelity; layout, fonts, and formatting are not preserved)
Error Codes
Section titled “Error Codes”| Code | Meaning |
|---|---|
| 400 | SSRF blocked — URL targets a private/reserved IP range |
| 402 | Payment required — x402 handshake (handled automatically by MCP server) |
| 422 | Invalid URL, unsupported type, or parameter validation failed |
| 429 | Rate limit exceeded (free test: 100/hour per IP) |
HTTP 200 with success: false indicates download or conversion failure. Check the error field for: download_error, http_error, conversion_error, output_too_large.