Passport OCR
Seamlessly automate identity verification with our enterprise-grade Passport OCR API. We provide high-precision data extraction for passports from over 195 countries and regions, supporting both standard ICAO-compliant Machine-Readable Zones (MRZ) and complex non-standard formats. Transform passport images into clean, structured JSON in seconds to streamline your global onboarding and KYC workflows.
Endpoint
POSThttps://api.structocr.com/v1/passportRequest Parameters
Important: This endpoint requires application/json Content-Type. Images must be sent as Base64 strings.
| Parameter | In | Required | Description |
|---|---|---|---|
| x-api-key | Header | Required | Your unique API key generated from the dashboard. |
| Content-Type | Header | Required | Must be set to application/json. |
| img | Body (JSON) | Required | The Base64 encoded string of the passport image.
|
Response Schema
The following fields are extracted into the data object. All dates are normalized to YYYY-MM-DD.
| Field | Description |
|---|---|
| type | Document type indicator (e.g., 'P' for Passport). |
| country_code | ISO 3166-1 alpha-3 country code (e.g., 'USA', 'CAN'). |
| nationality | The full nationality of the passport holder. |
| passport_number | The unique document number found on the data page. |
| surname | The holder's family name (Last Name). |
| given_names | The holder's first and middle names. |
| sex | Gender of the holder (e.g., 'M', 'F', or 'X'). |
| date_of_birth | Holder's birth date in YYYY-MM-DD format. |
| place_of_birth | The location/city of birth as listed on the passport. |
| date_of_issue | The date when the passport was officially issued. |
| date_of_expiry | The date when the passport validity expires. |
| place_of_issue | The location or authority that issued the document. |
Code Examples
Request Implementation
curl -X POST https://api.structocr.com/v1/passport \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"img": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
}'Success Response (200 OK)
{
"success": true,
"data": {
"type": "passport",
"country_code": "USA",
"nationality": "UNITED STATES",
"passport_number": "E12345678",
"surname": "DOE",
"given_names": "JOHN",
"sex": "M",
"date_of_birth": "1990-01-01",
"place_of_birth": "NEW YORK, USA",
"date_of_issue": "2020-01-01",
"date_of_expiry": "2030-01-01",
"place_of_issue": "PASSPORT AGENCY"
}
}Error Responses
400 Bad Request - Invalid Input
Returned when JSON is invalid or image data is missing/corrupt.
{
"error": "INVALID_JSON"
// or "NO_IMAGE_DATA", "INVALID_BASE64"
}402 Payment Required - Insufficient Credits
{
"success": false,
"error": "INSUFFICIENT_CREDITS",
"message": "Your account balance is insufficient to complete this operation."
}413 Payload Too Large
The Base64 decoded image size exceeds 4.5MB.
{
"error": "FILE_TOO_LARGE"
}415 Unsupported Media Type
{
"error": "INVALID_CONTENT_TYPE_USE_JSON"
}422 Unprocessable Entity - Policy Violation
{
"success": false,
"error": "CONTENT_POLICY_VIOLATION",
"message": "The document content could not be processed due to safety policies."
}500 Internal Server Error
{
"success": false,
"error": "PROCESSING_ERROR",
"message": "An internal error occurred while processing the document..."
}503 Service Unavailable - System Busy
{
"success": false,
"error": "SYSTEM_BUSY",
"message": "StructOCR is currently processing a high volume of requests..."
}Status Code Definitions
| Code | Error Code | Description |
|---|---|---|
| 200 | SUCCESS | Recognition success |
| 400 | INVALID_JSON | Invalid Body or corrupted Base64 |
| 402 | INSUFFICIENT_CREDITS | Account balance too low |
| 413 | FILE_TOO_LARGE | Decoded image exceeds 4.5MB |
| 415 | INVALID_CONTENT_TYPE | Not using application/json |
| 422 | CONTENT_POLICY_VIOLATION | AI safety/policy block |
| 503 | SYSTEM_BUSY | API Rate limit reached |