Convert File
Upload and convert local files using the Docling for IBM watsonx API
Convert File
Use this endpoint to upload and convert up to 3 local files into different formats. To convert a document from a URL, see Convert Source; to convert larger collections or ingest from cloud storage, see Convert Batch.
Endpoint
POST {SERVICE_URL}/v1/convert/file/asyncRequest Headers
| Header | Required | Description |
|---|---|---|
X-Api-Key | Yes | Your API key for authentication |
Content-Type | Yes | Must be multipart/form-data |
Request Body
The request must be sent as multipart/form-data with the following fields:
| Parameter | Type | Required | Description |
|---|---|---|---|
files | file | Yes | The file(s) to upload and convert, up to 3 (repeat the field; use @ prefix for file paths) |
options | JSON string | Conditional | Conversion options as a JSON string. Required when uploading more than one file (see Options) |
Options
When provided, the options parameter must be a JSON string containing an object with the following parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
to_formats | array | ["md"] | Output formats, any of: "md", "html", "json", "text", "doclang" |
Response
Success Response (200 OK)
Returns a task object that can be used to poll for completion:
{
"task_id": "{TASK_ID}",
"task_type": "convert",
"task_status": "pending",
"task_position": 1,
"task_meta": null,
"failure": null,
"error_message": null
}| Field | Type | Description |
|---|---|---|
task_id | string | Unique identifier for this conversion task (generated by the service) |
task_type | string | Always "convert" for conversion tasks |
task_status | string | Current status: "pending", "processing", "success", or "failure" |
task_position | integer | Position in queue (null when processing or complete) |
task_meta | object | Additional metadata |
failure | object | Failure details if the task failed, otherwise null |
error_message | string | Error description if status is "failure" |
Error Responses
See Error Handling for the full error model. The responses most specific to file upload:
| Status | Description |
|---|---|
400 | Bad request — malformed request |
401 | Unauthorized — missing or invalid API key |
413 | Payload too large — file exceeds the size limit |
415 | Unsupported media type — file format not supported |
422 | Validation error — invalid request shape or unsupported target type |
429 | Too many requests — rate limit exceeded |
500 | Internal server error |
502 | Gateway or upstream error |
Examples
Find examples of using the File Conversion endpoint in the Examples section.
Next Steps
After submitting a conversion request:
- Poll for status - Use the
/v1/status/poll/{task_id}endpoint to check conversion progress - Retrieve results - Once status is
"success", use the/v1/result/{task_id}endpoint to get conversion result artifacts
Best Practices
- Use appropriate output formats - Choose
markdownfor RAG applications,jsonfor structured data extraction - Convert collections with the batch endpoint - For more than 3 files, or to ingest from cloud storage, use Convert Batch
- Handle errors gracefully - Always check the
task_statusanderror_messagefields - Implement retry logic - Use exponential backoff for transient failures
- Validate files locally - Check file format and size before uploading to avoid errors
Common Errors
No file provided — include at least one file with the -F flag (files=@/path/to/file) in curl, or set the file field correctly in your HTTP client. Requests without input should be rejected during request validation.
Unsupported file format — the task can complete with task_status: "success" while the result has num_failed > 0 and a document-level failure status. Check result counters and each document's status. See the FAQ for supported formats.
Invalid options JSON — the options field must contain valid JSON. In bash, wrap it in single quotes: -F 'options={"to_formats":["html"]}'
File Format Support
The Convert File endpoint supports the same formats as Convert Source:
- PDF documents - Including scanned PDFs with OCR
- Images - PNG, JPEG, TIFF, BMP, GIF
- Microsoft Office - DOCX, PPTX, XLSX
- HTML - Web pages and HTML documents
- Markdown - MD files
- Text files - TXT, CSV
For the most up-to-date list, see the FAQ.
Rate Limits
See Rate Limits for the default limits and 429 handling.
Related Endpoints
- Convert Source - Convert a document from a URL
- Convert Batch - Convert multiple documents, including from cloud storage
- Poll Status - Check conversion progress
- Get Results - Retrieve conversion result artifacts