Document Reader
This service is used to read information from a document image using FacePhi OCR technology and organize the information into fields.
The service can handle different document types, including identity cards, foreign resident cards, invoices, and PDFs. You must specify the document type and the model to process the document correctly.
For a complete list of supported document types and models, see Documents Supported by OCR.
Documents Supported by OCR
Document Types
The OCR service can process different document types. Use the type parameter to specify the document type to process:
Identity Card
id_card
National identity cards
Foreign Resident Card
foreign_card
Identification cards for foreign nationals
pdf
PDF documents that require OCR processing
Invoice
invoice
Billing documents
Supported Models by Document Type
Identity Cards (ID Cards)
For identity cards, use the country code ISO 3166-1 alpha-3 as the model:
Argentina
ARG
Mexico
MEX
Foreign Resident Cards (Foreign Cards)
For foreign resident cards, use the following codes as the model:
Mexico
MEX
Invoices
For invoices, use the provider code as the model:
TELMEX
TELMEX
CFE
CFE
PDF Documents
For PDF documents, use the document type code as the parameter model:
VAT: El Salvador
IVA
INCOME TAX: El Salvador
RENTA
Endpoint
Headers
x-api-key
string
Yes
Authorization API key for access.
family
string
No
Value: OnBoarding. Required with the Tracking service.
Request body
Content-Type: application/json
Parameters
type
string
Yes
Document type to process. Only types allowed in the tenant configuration can be used. Possible values: id_card, passport, driver_license, foreign_card, invoice, pdf
model
string
Yes
Identifier of the document model to process. For identity documents, use the country code ISO 3166-1 alpha-3. For invoices or PDF documents, use the specific codes provided by FacePhi.
files
string[]
Yes
Document images encoded in Base64 (RFC4648). Maximum of two images per request. The first image is treated as the front side.
isCropped
boolean
No
Indicates whether the provided images are already cropped. Default value: false
forceDetection
boolean
No
Forces OCR detection even if automatic document detection fails. Default value: false
retrieveImages
boolean
No
Returns cropped images in the response when supported for the configured tenant. Default value: false
tracking
object
No
Object representing the required tracking information.
tracking.extraData
string
No
Token generated by the SDK Mobile/Web. Contains tracking information tokenized with the Platform.
tracking.operationId
string
No
Operation identifier generated by the SDK Mobile/Web.
Example Request
Responses
200 Success
Response Parameters
serviceResultCode
integer
Code indicating the overall result of the service execution.
serviceResultLog
string
Descriptive field for the result of the service execution.
timestamp
string
Time when the service finished processing.
serviceTransactionId
string
Transaction identifier associated with the request processed by the API.
serviceResult
object
Object containing the OCR result with the extracted fields.
serviceTime
string
Total service execution time (milliseconds).
Service Result Code
The serviceResultCode indicates the overall result of the service execution:
0
The service execution was successful; the module processed the request correctly.
200
Response example
400 Bad Request
401 Unauthorized
403 Forbidden
413 Payload Too Large
The request exceeds the maximum allowed size. The gateway rejects it without processing it: the response does not include serviceResultCode or serviceTransactionId. See Request size limit.
Request larger than 6 MB and up to 10 MB (Content-Type: application/json):
Request larger than 10 MB (10,485,760 bytes) (Content-Type: text; charset=utf-8, plain text, not JSON):
502 Bad Gateway
504 Gateway Timeout
Last updated