Recognize a document
POSThttps://pictotext.io/api/v1/ocr
Send one image of one document and get its fields back as a flat JSON object. Each successful call uses one credit; rejected requests are free.
Request
Send the body as multipart/form-data.
- Authorizationheaderrequired
- Bearer followed by an API key from the dashboard. Keys can only be created after you verify your email. Keep them on your server.
- imagefilerequired
- One image of one side of one document. JPEG, PNG, WebP, HEIC or HEIF, up to 10 MB.
- documentTypestringrequired
- One of the 44 document ids, such as passport, cn_id_card or us_drivers_license. The API does not accept auto; automatic detection is only available in the Playground.
Response fields
The response is a flat JSON object whose keys depend on documentType. Every document’s fields are listed on its own page under Documents.
| Field | Type | Notes |
|---|---|---|
| passportNumber | string | — |
| name | string | — |
| gender | string | — |
| birthDay | string | Date as YYYY-MM-DD |
| birthPlace | string | — |
| issueDay | string | Date as YYYY-MM-DD |
| expiryDay | string | Date as YYYY-MM-DD |
| issuePlace | string | — |
| nationality | string | — |
| mrz | string | null | 2 TD3 lines joined with \n, verbatim; null when it cannot be read reliably |
Errors
Errors return an error object; branch on error.details[0].reason. None of them use a credit.
| Status | Reason | What to do |
|---|---|---|
| 400 | MISSING_IMAGE_FILE | Send the file in the image field of a multipart/form-data body. |
| 400 | INVALID_IMAGE_TYPE | Send a JPEG, PNG, WebP, HEIC or HEIF image. |
| 400 | IMAGE_TOO_LARGE | Resize or recompress the image below 10 MB. |
| 400 | INVALID_DOCUMENT_TYPE | Use an id from the supported documents list. auto is not accepted. |
| 401 | INVALID_AUTH_HEADER | Send the header as Authorization: Bearer <key>. |
| 401 | INVALID_API_KEY | The key is wrong or was deleted. Copy it again from the dashboard. |
| 402 | INSUFFICIENT_CREDITS | Buy a credit pack or change plan. |
| 403 | EMAIL_NOT_VERIFIED | Verify the account email, then retry. |
| 429 | API_RATE_LIMITED | Free accounts only: wait for Retry-After, or buy any pack to lift the limit. |
| 429 | API_CONCURRENCY_LIMITED | Free accounts only: wait for a request to finish before sending another. |