Batch Conversion

Process multiple files in parallel with a single request

POST /api/v1/batchPOST

Overview

The batch conversion endpoint allows you to process multiple documents simultaneously, significantly reducing processing time and API calls for bulk operations. Perfect for applications that need to convert large document sets efficiently.

⚡ Parallel Processing

All files are processed simultaneously for maximum speed and efficiency.

🔄 Mixed Sources

Combine Base64 files and URLs in the same batch request.

🛡️ Fault Tolerant

Individual file failures don't stop the processing of other files.

Batch Limits

Request Limits

  • Maximum files per batch:Varies by plan
  • Request timeout:30 minutes

Performance Tips

  • • Use parallel_processing: true for faster results
  • • Group similar file types for optimal processing
  • • Monitor batch status using the batch_id
  • • Consider file size distribution for best performance

Request Format

JSON Request Body

Batch Request Example
{
 "files": [
 {
 "id": "file1",
 "source_type": "file",
 "file": "JVBERi0xLjQKMSAwIG9iago...",
 "filename": "document1.pdf"
 },
 {
 "id": "file2", 
 "source_type": "url",
 "url": "https://example.com/document2.docx",
 "filename": "document2.docx"
 },
 {
 "id": "file3",
 "source_type": "file", 
 "file": "UEsDBBQAAAAIAMF...",
 "filename": "presentation.pptx"
 }
 ],
 "options": {
 "ocr_type": "advanced",
 "parallel_processing": true
 }
}

cURL Example

Command Line
curl -X POST https://api.markdownconverters.com/api/v1/batch \
 -H "X-API-Key: your_api_key_here" \
 -H "Content-Type: application/json" \
 -d '{
 "files": [
 {
 "id": "doc1",
 "source_type": "file",
 "file": "base64_encoded_content",
 "filename": "document.pdf"
 },
 {
 "id": "doc2",
 "source_type": "url", 
 "url": "https://example.com/file.docx",
 "filename": "file.docx"
 }
 ],

 }'

Request Parameters

ParameterTypeRequiredDescription
filesarrayYesArray of file objects to convert
optionsobjectNoBatch processing options

File Object Structure

FieldTypeRequiredDescription
idstringYesUnique identifier for this file in the batch
source_typestringYes"file" or "url"
filenamestringYesOriginal filename for identification
filestringConditionalBase64-encoded content (if source_type is "file")
urlstringConditionalURL to downloadable file (if source_type is "url")

Response Format

Successful Batch Response

Complete Success (200 OK)
{
 "batch_id": "batch_1234567890abcdef",
 "status": "completed",
 "total_files": 3,
 "completed_files": 3,
 "failed_files": 0,
 "results": [
 {
 "id": "file1",
 "job_id": "conv_1111111111111111",
 "status": "completed",
 "filename": "document1.pdf",
 "markdown_content": "# Document 1\n\nContent from the first PDF document...",
 "metadata": {
 "file_size": 2048,
 "pages": 3,
 "processing_time_ms": 1850
 },
 "sas_url": "https://storage.azure.com/converted/conv_1111111111111111.md?sp=r&st=..."
 },
 {
 "id": "file2",
 "job_id": "conv_2222222222222222", 
 "status": "completed",
 "filename": "document2.docx",
 "markdown_content": "# Document 2\n\nContent from the Word document...",
 "metadata": {
 "file_size": 1536,
 "pages": 2,
 "processing_time_ms": 1200
 },
 "sas_url": "https://storage.azure.com/converted/conv_2222222222222222.md?sp=r&st=..."
 },
 {
 "id": "file3",
 "job_id": "conv_3333333333333333",
 "status": "completed", 
 "filename": "presentation.pptx",
 "markdown_content": "# Presentation Title\n\n## Slide 1\n\nContent from slide 1...",
 "metadata": {
 "file_size": 4096,
 "pages": 10,
 "processing_time_ms": 2400
 },
 "sas_url": "https://storage.azure.com/converted/conv_3333333333333333.md?sp=r&st=..."
 }
 ],
 "created_at": "2024-01-01T12:00:00Z",
 "completed_at": "2024-01-01T12:00:05Z",
 "total_processing_time_ms": 5450
}

Partial Failure Response

Partial Success (207 Multi-Status)
{
 "batch_id": "batch_1234567890abcdef",
 "status": "partial_failure",
 "total_files": 3,
 "completed_files": 2,
 "failed_files": 1,
 "results": [
 {
 "id": "file1",
 "job_id": "conv_1111111111111111",
 "status": "completed",
 "filename": "document1.pdf",
 "markdown_content": "# Document 1\n\nContent...",
 "metadata": { "file_size": 2048, "pages": 3 },
 "sas_url": "https://storage.azure.com/..."
 },
 {
 "id": "file2",
 "status": "failed",
 "filename": "corrupted.pdf",
 "error": {
 "code": "CORRUPTED_FILE",
 "message": "The file appears to be corrupted and cannot be processed",
 "suggestion": "Please verify the file integrity and try again"
 }
 },
 {
 "id": "file3", 
 "job_id": "conv_3333333333333333",
 "status": "completed",
 "filename": "presentation.pptx",
 "markdown_content": "# Presentation\n\nContent...",
 "metadata": { "file_size": 4096, "pages": 10 },
 "sas_url": "https://storage.azure.com/..."
 }
 ]
}

Response Status Codes

Success Responses

  • • 200 OK: All files processed successfully
  • • 202 Accepted: Batch processing started (async mode)
  • • 207 Multi-Status: Some files failed, others succeeded

Error Responses

  • • 400: Invalid batch request format
  • • 401: Invalid API key
  • • 413: Batch size too large
  • • 429: Rate limit exceeded

Best Practices

Optimization Tips

  • • Keep batches under 25 files for optimal performance
  • • Use unique, descriptive IDs for each file
  • • Enable parallel_processing for faster results
  • • Group similar file types when possible

Error Handling

  • • Always check individual file status
  • • Retry failed files individually
  • • Monitor processing times for timeout issues
  • • Use batch status endpoint for long-running jobs