API Documentation
Async OCR jobs over REST. Create an API key in your dashboard.
Authentication
Authorization: Bearer <api_key>
POST /ocr
Submit a file for OCR. Returns 202 with a job id. Credits are reserved up front (1 per page) and refunded automatically on engine failure.
Optional Idempotency-Key header: repeating the same key within 24 hours returns the original job without re-charging.
curl -X POST https://imgtotxt.app/ocr \ -H "Authorization: Bearer itk_..." \ -H "Idempotency-Key: $(uuidgen)" \ -F "file=@invoice.pdf"
Response:
{
"job_id": "6f1c2a...",
"status": "queued",
"pages": 12,
"credits_reserved": 12,
"credits_remaining": 238
}
GET /ocr/{job_id}
Poll for status: queued, processing, succeeded, or failed.
{
"job_id": "6f1c2a...",
"status": "succeeded",
"text": "Extracted text...",
"markdown": "# Invoice\n\n| Item | Qty |...",
"pages": 12,
"engine": "mistral-ocr",
"credits_used": 12,
"credits_remaining": 238
}
Supported formats
PNG, JPEG, WebP, TIFF (multi-page), PDF. Files are validated by magic bytes; results are retained for 24 hours, then purged.
Error codes
| Code | Meaning |
|---|---|
400 | Invalid request, unsupported or malformed file |
401 | Missing or invalid API key |
402 | Insufficient credits — buy more |
413 | File exceeds size limit |
415 | MIME type failed magic-byte validation |
422 | Page count exceeds per-job cap (200) |
429 | Rate limit, free monthly allowance exhausted, or too many jobs in flight (10 at once) — wait |
502 | Engine unreachable after retries (credits refunded) |