ID Verification API
The ID Verification API allows you to verify identity documents by submitting images of the document's front and back sides (when applicable). This API extracts and validates document information, performs authenticity checks, and returns structured data from the document.
- Base URL:
https://verification.didit.me
- Endpoint:
/v2/id-verification/
- Authentication:
Client Token (Bearer Token)
The authentication endpoint uses a different base URL than the API endpoints. Ensure you use the correct URLs to avoid connectivity issues.
This API requires a Pro Plan subscription and has an associated cost per call. Results won't be saved in your console. For pricing details, visit our API Pricing page.
Process Overview
Follow these steps to submit document images for verification:
Step 1: Authenticate
Obtain a valid access_token
by following the Authentication documentation. This token is required in the Authorization
header of your request.
The access_token
is valid for 24 hours. You only need to re-authenticate once it expires.
Step 2: Prepare Request Parameters
Parameter | Type | Required? | Description | Example Value |
---|---|---|---|---|
|
| Yes | Front side image of the identity document (JPEG, PNG, or WebP) | Binary image file |
|
| Conditional | Back side image of the identity document (required for dual-sided documents like ID cards) | Binary image file |
|
| No | Customization options for document verification | See options details below |
Options Object
The options
parameter allows you to customize the ID verification process:
Option | Type | Required? | Description | Default Value |
---|---|---|---|---|
|
| No | Action to take when a duplicated user is detected. Valid values: "NO_ACTION", "DECLINE" | "NO_ACTION" |
|
| No | Minimum age required. Users under this age will be declined. Must be between 1-120. Set to null for no age restriction. | null |
|
| No | Action to take when the expiration date is not detected. Valid values: "NO_ACTION", "DECLINE" | "NO_ACTION" |
|
| No | Action to take when QR/Barcode reading fails. Valid values: "NO_ACTION", "DECLINE" | "NO_ACTION" |
|
| No | Action to take when MRZ reading fails, or the extracted data in viz is not consistent with the MRZ data. Valid values: "NO_ACTION", "DECLINE" | "DECLINE" |
|
| No | Documents allowed by country, in a format of country codes (ISO 3166-1 alpha-3) mapped to document types. For each document type, set 1 to allow or 0 to disallow: "p" (passport), "id" (identity card), "dl" (driving license), "rp" (residence permit) | See example below |
Example of documents_allowed object:
{
"documents_allowed": {
"USA": {"p": 1, "id": 1, "dl": 1, "rp": 0},
"GBR": {"p": 1, "id": 0, "dl": 1, "rp": 1},
"CAN": {"p": 1, "id": 1, "dl": 1, "rp": 0}
}
}
For dual-sided documents (like ID cards or driving licenses), you must provide both front_image
and back_image
in the same request. For single-sided documents (like passports), only front_image
is required. The API will return an error if you submit only the front image for a document that requires both sides. If you submit a back image for a single-sided document, it will be ignored.
Document requirements vary by country and document type. Consult our Supported Documents by Country documentation to determine whether a specific document requires one or two sides.
Image Requirements
- Images must be in JPEG, PNG, or WebP format
- Minimum resolution: 1280x720 pixels
- Maximum file size: 10MB per image
- Document must be clearly visible, well-lit, and unobstructed
- All four corners of the document must be visible
- Text must be clearly legible
- No glare or reflections on document surface
Step 3: Send the Request
Make a POST
request to /v2/id-verification/
with the prepared parameters and include the access_token obtained in step 1 in the header.
Example Request
POST /v2/id-verification/ HTTP/1.1
Host: verification.didit.me
Content-Type: multipart/form-data
Authorization: Bearer {access_token}
--boundary
Content-Disposition: form-data; name="front_image"; filename="document_front.jpg"
Content-Type: image/jpeg
[Binary image data]
--boundary
Content-Disposition: form-data; name="back_image"; filename="document_back.jpg"
Content-Type: image/jpeg
[Binary image data]
--boundary
Content-Disposition: form-data; name="options"
Content-Type: application/json
{
"duplicated_user_action": "NO_ACTION",
"minimum_age": 18,
"expiration_date_not_detected_action": "NO_ACTION",
"invalid_code_action": "NO_ACTION",
"invalid_mrz_action": "DECLINE",
"documents_allowed": {
"USA": {"p": 1, "id": 1, "dl": 1, "rp": 0},
"GBR": {"p": 1, "id": 0, "dl": 1, "rp": 1},
"CAN": {"p": 1, "id": 1, "dl": 1, "rp": 0}
}
}
--boundary--
Response
The response provides detailed information about the ID verification results, including extracted document information and verification status.
Example Response
{
"request_id": "11111111-2222-3333-4444-555555555555",
"id_verification": {
"status": "Approved",
"document_type": "Identity Card",
"document_number": "CAA000000",
"personal_number": "99999999R",
"portrait_image": "https://example.com/portrait.jpg",
"front_image": "https://example.com/front.jpg",
"front_video": "https://example.com/front.mp4",
"back_image": "https://example.com/back.jpg",
"back_video": "https://example.com/back.mp4",
"full_front_image": "https://example.com/full_front.jpg",
"full_back_image": "https://example.com/full_back.jpg",
"date_of_birth": "1980-01-01",
"age": 45,
"expiration_date": "2031-06-02",
"date_of_issue": "2021-06-02",
"issuing_state": "ESP",
"issuing_state_name": "Spain",
"first_name": "Carmen",
"last_name": "Española Española",
"full_name": "Carmen Española Española",
"gender": "F",
"address": "Avda de Madrid 34, Madrid, Madrid",
"formatted_address": "Avda de Madrid 34, Madrid, Madrid 28822, Spain",
"place_of_birth": "Madrid",
"marital_status": "Single",
"nationality": "ESP",
"parsed_address": {
"id": "7c6280a2-fb6a-4258-93d5-2ac987cbc6ba",
"city": "Madrid",
"label": "Spain ID Card Address",
"region": "Madrid",
"street_1": "Avda de Madrid 34",
"street_2": null,
"postal_code": "28822",
"raw_results": {
"geometry": {
"location": {
"lat": 37.4222804,
"lng": -122.0843428
},
"location_type": "ROOFTOP",
"viewport": {
"northeast": {
"lat": 37.4237349802915,
"lng": -122.083183169709
},
"southwest": {
"lat": 37.4210370197085,
"lng": -122.085881130292
}
}
},
},
},
"extra_files": [],
"warnings": [
{
"risk": "QR_NOT_DETECTED",
"additional_data": null,
"log_type": "information",
"short_description": "QR not detected",
"long_description": "The system couldn't find or read the QR code on the document, which is necessary for document verification. This could be due to poor image quality or an unsupported document type.",
}
],
},
"created_at": "2024-07-30T08:45:12.345678Z"
}
Response Fields
Field | Type | Description |
---|---|---|
|
| Unique identifier for the API request. |
|
| Overall ID Verification status (Approved or Declined) |
|
| Type of document detected (Passport, Identity Card, Driving License, etc.) |
|
| Identification number of the document |
|
| Personal identification number (if available) |
|
| Temporary URL to the extracted portrait image |
|
| Temporary URL to the processed front side image |
|
| Temporary URL to the front side video (if available) |
|
| Temporary URL to the processed back side image (if applicable) |
|
| Temporary URL to the back side video (if available) |
|
| Temporary URL to the full front side image |
|
| Temporary URL to the full back side image (if applicable) |
|
| Date of birth in YYYY-MM-DD format |
|
| Document expiration date in YYYY-MM-DD format |
|
| Document issue date in YYYY-MM-DD format |
|
| Country code of the issuing authority (ISO 3166-1 alpha-3) |
|
| Full name of the issuing country |
|
| First name of the document holder |
|
| Last name of the document holder |
|
| Full name as it appears on the document |
|
| Gender of the document holder (M, F, or U for unknown) |
|
| Address as it appears on the document (if available) |
|
| Standardized version of the address |
|
| Place of birth as it appears on the document (if available) |
|
| Marital status as it appears on the document (if available) |
|
| Structured address components and geolocation data |
|
| Nationality code in ISO 3166-1 alpha-3 format |
|
| List of warnings related to the document verification |
|
| Timestamp when the request was created (ISO 8601 format). |
The image URLs in the response are temporary and will expire after 60 minutes.
Error Handling
Status Code | Error | Description |
---|---|---|
400 | Bad Request | Invalid parameters or missing required files |
401 | Unauthorized | Invalid or missing access_token |
403 | Forbidden | Not authorized to access this API or insufficient subscription plan. |
Example Error Response
{
"error": {
"code": "INVALID_DOCUMENT",
"message": "Document could not be processed. Please ensure it is clearly visible and retry."
}
}
Common Error Codes
Error Code | Description |
---|---|
INVALID_DOCUMENT | Document could not be recognized or processed |
MISSING_REQUIRED_IMAGE | Back image required for dual-sided document |
INSUFFICIENT_QUALITY | Image quality is too low for accurate analysis |
Code Examples
async function submitDocumentVerification(accessToken, frontImageFile, backImageFile = null, options = null) {
const url = `https://verification.didit.me/v2/id-verification`;
// Create a FormData instance
const formData = new FormData();
formData.append('front_image', frontImageFile);
// Add back image if provided (required for dual-sided documents)
if (backImageFile) {
formData.append('back_image', backImageFile);
}
// Add options if provided
if (options) {
formData.append('options', JSON.stringify(options));
}
const requestOptions = {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`
},
body: formData
};
try {
const response = await fetch(url, requestOptions);
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.error?.message || errorData.detail || 'Unknown error occurred');
}
return await response.json();
} catch (error) {
console.error('Error in ID Verification:', error);
throw error;
}
}
// Example usage
async function performDocumentVerification(documentType) {
try {
// 1. Get client token (implement based on auth documentation)
const token = await getClientToken();
// 2. Get image files (from file input or other source)
const frontImageFile = document.getElementById('front-image-input').files[0];
let backImageFile = null;
// Check if back image is required based on document type
if (['id_card', 'driving_license'].includes(documentType)) {
backImageFile = document.getElementById('back-image-input').files[0];
if (!backImageFile) {
throw new Error('Back image is required for ID cards and driving licenses');
}
}
// 3. Custom options (optional)
const options = {
duplicated_user_action: "NO_ACTION",
minimum_age: 18,
expiration_date_not_detected_action: "NO_ACTION",
invalid_code_action: "NO_ACTION",
invalid_mrz_action: "DECLINE",
documents_allowed: {
"USA": {"p": 1, "id": 1, "dl": 1, "rp": 0},
"GBR": {"p": 1, "id": 0, "dl": 1, "rp": 1}
}
};
// 4. Submit document verification
const result = await submitDocumentVerification(
token.access_token,
frontImageFile,
backImageFile,
options
);
console.log('ID Verification result:', result);
console.log(`Document type: ${result.id_verification.document_type}`);
console.log(`Full name: ${result.id_verification.full_name}`);
return result;
} catch (error) {
console.error('Error:', error);
throw error;
}
}
Best Practices
-
Document Selection:
- Choose the clearest and most recent document available.
- Ensure the document is not expired or damaged.
-
Image Capture:
- Use high-resolution camera with good lighting.
- Capture the entire document with all corners visible.
- Avoid glare, shadows, or reflections on the document.
- Place document against a contrasting, solid background.
-
Image Validation:
- Check that all text is clearly legible.
- Ensure all security features are visible.
- Verify that both sides are submitted for dual-sided documents.
-
Customization Options:
- Use the
options
parameter to configure document verification according to your risk policy. - Set appropriate actions (
NO_ACTION
orDECLINE
) for different validation failures based on your security requirements. - Configure
minimum_age
when age verification is critical for your application. - Restrict allowed document types by country using the
documents_allowed
parameter to accept only document types that meet your security standards. - For high-security applications, set stricter actions for data inconsistencies and validation failures.
- Use the
-
Error Handling:
- Implement proper error handling in your application.
- Provide clear guidance to users when verification fails.
- Consider implementing retry logic with improved instructions.