Authentication
Authenticate your API requests by including your secret API key in the x-api-key header. You can generate and manage your API keys in the developer dashboard.
Extract Custom Schema
/v1/extractUpload a document (PDF or Image) and a JSON schema. The API will route the document to the optimal engine and return a strictly typed JSON object matching your schema.
Request Parameters (multipart/form-data)
fileRequiredThe document file to be parsed. Max size 5MB.
schemaRequiredA stringified JSON object defining the exact keys and types you want extracted.
MCP Server (Claude, Cursor & AI Agents)
Streamable HTTPConnect Smart OCR directly to Claude Desktop, Cursor, Windsurf, Cline, or any Model Context Protocol (MCP) client over Streamable HTTP (2025-03-26). Pass your x-api-key header in your MCP client configuration to give your AI agents instant access to custom JSON schema extraction and table parsing.
1-Command Auto-Install & CLI (npm)
# Auto-configure Cursor, Claude Desktop, Antigravity & Windsurf npx -y smartocr-mcp install # Or extract any local PDF/image directly from the terminal npx -y smartocr-mcp extract ./invoice.pdf
MCP Client Configuration (mcp.json)
{
"mcpServers": {
"smartocr": {
"url": "https://api.smartocr.dev/mcp",
"headers": {
"x-api-key": "ocr-tok_...123abc"
}
}
}
}Exposed MCP Tools
extract_document_jsonCustom SchemaExtracts strict, type-safe JSON matching any custom schema object from a file_url or file_base64 (PDF, PNG, JPG, WEBP, TIFF). Works on the free tier (2/day) or deducts 1 credit/page with an API key.
extract_document_tableTable / CSV / MarkdownExtracts flat 2D spreadsheet rows and columns as a Markdown table and RFC-4180 CSV from invoices, bank statements, receipts, and scanned PDF tables.
extract_document_textPlain Text OCRExtracts verbatim plain-text OCR transcription across Native PDF, Google Cloud Vision, and AWS Textract without LLM rewriting.
extract_document_batchBatch (2–5 Docs)Extracts structured JSON matching one shared schema across 2 to 5 document URLs in a single batch call.
submit_document_job / get_document_jobAsync & WebhooksCreates a tracked asynchronous extraction job (jobId) with optional HTTP webhook delivery and retrieves status/results by job_id.
get_smartocr_statusRead-OnlyChecks your remaining Smart OCR API credit balance or daily free-tier status.
Async Extraction & Webhooks
/v1/extract-asyncSubmit large documents for asynchronous processing to prevent HTTP timeouts. Returns a jobId immediately. Once processing completes, the result is sent via POST to your configured Webhook URL.
Request Parameters
This endpoint accepts the same file and schema parameters as the standard extract endpoint, plus one additional optional parameter:
webhookUrlOptionalThe URL where the final extracted JSON should be sent. If no default exists and this is omitted, the request returns a 400 Bad Request.
Dashboard Configuration
You do not need to send the webhook URL in every API request. You can easily set, edit, or remove your default Webhook URL at any time directly from the API Keys section in your SmartOCR dashboard. If a default is set on your dashboard API key, the API will automatically use it whenever you omit the webhookUrl parameter in your request body.
Initial Response (200 OK)
{
"jobId": "uuid-string",
"status": "PROCESSING",
"message": "Document is processing in the background. Webhook will be sent upon completion."
}The Webhook Payload
Our servers will fire a POST request to your resolved webhook URL when processing concludes.
{
"jobId": "uuid-string",
"status": "COMPLETED",
"data": {
"extractedData": { ... },
"confidenceScore": 95,
"processedAt": "2026-06-29T12:00:00.000Z",
"creditsRemaining": 98
}
}{
"jobId": "uuid-string",
"status": "FAILED",
"error": "Reason for failure (e.g., Timeout, Unreadable document)"
}Fallback Polling Endpoint
/v1/job/:idIf your webhook server drops the payload or you prefer to poll manually, you can fetch the job status. Requires the x-api-key header.
{
"jobId": "uuid-string",
"status": "PROCESSING | COMPLETED | FAILED",
"result": { ... },
"createdAt": "2026-06-29T12:00:00.000Z",
"completedAt": "2026-06-29T12:05:00.000Z"
}File Integrity & Safety
To guarantee secure and reliable processing, the SmartOCR API performs strict real-time validation on all uploaded files before sending them to the inference engines.
Magic Byte Signature Verification
To prevent extension-spoofing attacks (e.g. renaming an executable to a .pdf), we verify file headers at the binary level. If the magic bytes do not match the declared MIME type, the request will fail with:
"Invalid [format] file signature. The file may be corrupted or renamed."
PDF Structural Integrity Check
All PDF uploads undergo deep structural analysis. If a PDF is corrupted, lacks a catalog, or has parsing anomalies, the API returns:
"Corrupted or invalid PDF file structure."
Encryption Detection
Password-protected, encrypted, or DRM-locked PDF documents cannot be processed. These will be rejected immediately with:
"Password protected PDFs are not supported."
Status Codes
SmartOCR uses standard HTTP response codes to indicate the success or failure of an API request.
- 200OKSuccessful extraction.
- 400Bad RequestInvalid schema format, missing file, corrupted structures, spoofed file signatures, or password-protected PDFs.
- 401UnauthorizedAPI key is missing, invalid, or inactive.
- 402Payment RequiredOut of credits. Top up required.
- 429Too Many RequestsRate limit exceeded (10 req/min for free, 100 for premium).
- 500Server ErrorAll fallback providers failed to process the document.
curl -X POST https://api.smartocr.dev/v1/extract \
-H "x-api-key: ocr-tok_...123abc" \
-F "file=@/path/to/invoice.pdf" \
-F 'schema={"invoiceNumber": "string", "totalDue": "number"}'{
"extractedData": {
"invoiceNumber": "INV-2847",
"totalDue": 9782.00
},
"confidenceScore": 95,
"processedAt": "2026-05-31T18:00:00.000Z",
"creditsRemaining": 499
}