PicToText

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.

Passport response fields
FieldTypeNotes
passportNumberstring—
namestring—
genderstring—
birthDaystringDate as YYYY-MM-DD
birthPlacestring—
issueDaystringDate as YYYY-MM-DD
expiryDaystringDate as YYYY-MM-DD
issuePlacestring—
nationalitystring—
mrzstring | null2 TD3 lines joined with \n, verbatim; null when it cannot be read reliably
Passport reference →

Errors

Errors return an error object; branch on error.details[0].reason. None of them use a credit.

StatusReasonWhat to do
400MISSING_IMAGE_FILESend the file in the image field of a multipart/form-data body.
400INVALID_IMAGE_TYPESend a JPEG, PNG, WebP, HEIC or HEIF image.
400IMAGE_TOO_LARGEResize or recompress the image below 10 MB.
400INVALID_DOCUMENT_TYPEUse an id from the supported documents list. auto is not accepted.
401INVALID_AUTH_HEADERSend the header as Authorization: Bearer <key>.
401INVALID_API_KEYThe key is wrong or was deleted. Copy it again from the dashboard.
402INSUFFICIENT_CREDITSBuy a credit pack or change plan.
403EMAIL_NOT_VERIFIEDVerify the account email, then retry.
429API_RATE_LIMITEDFree accounts only: wait for Retry-After, or buy any pack to lift the limit.
429API_CONCURRENCY_LIMITEDFree accounts only: wait for a request to finish before sending another.
All error codes →