Driver License OCR

Our Driver License OCR API provides specialized data extraction for driving permits worldwide. Beyond standard identity data, it accurately parses vehicle classifications, issuing regions (States/Provinces), and validity dates. Streamline car rental, insurance, and gig-economy onboarding with high-precision recognition.


Endpoint

POSThttps://api.structocr.com/v1/driver-license

Request Parameters

Important: This endpoint requires application/json Content-Type. Images must be sent as Base64 strings.

ParameterInRequiredDescription
x-api-keyHeaderRequiredYour unique API key generated from the dashboard.
Content-TypeHeaderRequiredMust be set to application/json.
imgBody (JSON)RequiredThe Base64 encoded string of the driver license image.
  • Supports standard Data URI (e.g., data:image/jpeg;base64,...)
  • Supports raw Base64 strings
  • Max file size: 4.5MB
  • Formats: JPG, PNG, WebP

Response Schema

The following fields are extracted into the data object. All dates are normalized to YYYY-MM-DD.

FieldDescription
typeDocument type indicator (fixed as 'drivers_license').
country_codeISO 3166-1 alpha-3 country code (e.g., 'USA', 'CAN').
regionState, Province, or Region code (e.g., 'CA' for California).
document_numberThe unique license number.
surnameThe holder's family name.
given_namesThe holder's first and middle names.
date_of_birthHolder's birth date in YYYY-MM-DD format.
date_of_expiryThe date when the license validity expires.
date_of_issueThe date when the license was issued.
sexGender of the holder (e.g., 'M', 'F').
addressFull residential address as printed on the card.
vehicle_classAllowed vehicle categories (e.g., 'C', 'B', 'AM').

Code Examples

Request Implementation

curl -X POST https://api.structocr.com/v1/driver-license \
  -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": "drivers_license",
    "country_code": "USA",
    "region": "CALIFORNIA",
    "document_number": "D1234567",
    "surname": "DRIVER",
    "given_names": "JANE MARIE",
    "date_of_birth": "1995-08-15",
    "date_of_expiry": "2025-08-15",
    "date_of_issue": "2020-08-15",
    "sex": "F",
    "address": "1234 ELM ST, SACRAMENTO, CA 95814",
    "vehicle_class": "C"
  }
}

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

CodeError CodeDescription
200SUCCESSRecognition success
400INVALID_JSONInvalid Body or corrupted Base64
402INSUFFICIENT_CREDITSAccount balance too low
413FILE_TOO_LARGEDecoded image exceeds 4.5MB
415INVALID_CONTENT_TYPENot using application/json
422CONTENT_POLICY_VIOLATIONAI safety/policy block
503SYSTEM_BUSYAPI Rate limit reached