🎉 Unlimited Free KYC - Forever!!

Identity Verification
API Reference
ID Verification

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

ParameterTypeRequired?DescriptionExample Value
front_imagefileYesFront side image of the identity document (JPEG, PNG, or WebP)Binary image file
back_imagefileConditionalBack side image of the identity document (required for dual-sided documents like ID cards)Binary image file
optionsjsonNoCustomization options for document verificationSee options details below

Options Object

The options parameter allows you to customize the ID verification process:

OptionTypeRequired?DescriptionDefault Value
duplicated_user_actionstringNoAction to take when a duplicated user is detected. Valid values: "NO_ACTION", "DECLINE""NO_ACTION"
minimum_agenumberNoMinimum age required. Users under this age will be declined. Must be between 1-120. Set to null for no age restriction.null
expiration_date_not_detected_actionstringNoAction to take when the expiration date is not detected. Valid values: "NO_ACTION", "DECLINE""NO_ACTION"
invalid_code_actionstringNoAction to take when QR/Barcode reading fails. Valid values: "NO_ACTION", "DECLINE""NO_ACTION"
invalid_mrz_actionstringNoAction 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"
documents_allowedobjectNoDocuments 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

FieldTypeDescription
request_idstringUnique identifier for the API request.
id_verification.statusstringOverall ID Verification status (Approved or Declined)
id_verification.document_typestringType of document detected (Passport, Identity Card, Driving License, etc.)
id_verification.document_numberstringIdentification number of the document
id_verification.personal_numberstringPersonal identification number (if available)
id_verification.portrait_imagestringTemporary URL to the extracted portrait image
id_verification.front_imagestringTemporary URL to the processed front side image
id_verification.front_videostringTemporary URL to the front side video (if available)
id_verification.back_imagestringTemporary URL to the processed back side image (if applicable)
id_verification.back_videostringTemporary URL to the back side video (if available)
id_verification.full_front_imagestringTemporary URL to the full front side image
id_verification.full_back_imagestringTemporary URL to the full back side image (if applicable)
id_verification.date_of_birthstringDate of birth in YYYY-MM-DD format
id_verification.expiration_datestringDocument expiration date in YYYY-MM-DD format
id_verification.date_of_issuestringDocument issue date in YYYY-MM-DD format
id_verification.issuing_statestringCountry code of the issuing authority (ISO 3166-1 alpha-3)
id_verification.issuing_state_namestringFull name of the issuing country
id_verification.first_namestringFirst name of the document holder
id_verification.last_namestringLast name of the document holder
id_verification.full_namestringFull name as it appears on the document
id_verification.genderstringGender of the document holder (M, F, or U for unknown)
id_verification.addressstringAddress as it appears on the document (if available)
id_verification.formatted_addressstringStandardized version of the address
id_verification.place_of_birthstringPlace of birth as it appears on the document (if available)
id_verification.marital_statusstringMarital status as it appears on the document (if available)
id_verification.parsed_addressobjectStructured address components and geolocation data
id_verification.nationalitystringNationality code in ISO 3166-1 alpha-3 format
id_verification.warningsarrayList of warnings related to the document verification
created_atstringTimestamp 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 CodeErrorDescription
400Bad RequestInvalid parameters or missing required files
401UnauthorizedInvalid or missing access_token
403ForbiddenNot 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 CodeDescription
INVALID_DOCUMENTDocument could not be recognized or processed
MISSING_REQUIRED_IMAGEBack image required for dual-sided document
INSUFFICIENT_QUALITYImage 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;
  }
}
import requests
import json
 
def submit_document_verification(access_token, front_image_file, back_image_file=None, options=None):
    """
    Submit document images for ID verification.
 
    Args:
        access_token (str): The access token for authentication.
        front_image_file (file): Front side image of the identity document.
        back_image_file (file, optional): Back side image of the identity document.
        options (dict, optional): Customization options for document verification.
 
    Returns:
        dict: The ID verification results.
    """
    url = "https://verification.didit.me/v2/id-verification"
 
    headers = {
        "Authorization": f"Bearer {access_token}"
    }
 
    files = {
        "front_image": front_image_file
    }
 
    # Add back image if provided (required for dual-sided documents)
    if back_image_file:
        files["back_image"] = back_image_file
 
    # Add options if provided
    data = {}
    if options:
        data['options'] = json.dumps(options)
 
    try:
        response = requests.post(url, headers=headers, files=files, data=data)
        response.raise_for_status()
        return response.json()
    except requests.exceptions.RequestException as e:
        print(f"Error in ID Verification: {e}")
        if hasattr(e, 'response') and e.response:
            print(f"Response: {e.response.text}")
        raise
 
# Example usage
def perform_document_verification(document_type):
    try:
        # 1. Get client token (implement based on auth documentation)
        token = get_client_token()
 
        # 2. Get image files (from file input or other source)
        front_image_path = "document_front.jpg"
        back_image_path = None
 
        # Check if back image is required based on document type
        if document_type in ['id_card', 'driving_license']:
            back_image_path = "document_back.jpg"
 
        # 3. Custom options (optional)
        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
        with open(front_image_path, "rb") as front_img:
            back_img = None
            if back_image_path:
                back_img = open(back_image_path, "rb")
 
            try:
                result = submit_document_verification(
                    token["access_token"],
                    front_img,
                    back_img if back_image_path else None,
                    options
                )
            finally:
                if back_img:
                    back_img.close()
 
        print(f"ID Verification status: {result['kyc']['status']}")
        print(f"Document type: {result['kyc']['document_type']}")
        print(f"Full name: {result['kyc']['full_name']}")
 
        return result
    except Exception as e:
        print(f"Error: {e}")
        raise

Best Practices

  1. Document Selection:

    • Choose the clearest and most recent document available.
    • Ensure the document is not expired or damaged.
  2. 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.
  3. 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.
  4. Customization Options:

    • Use the options parameter to configure document verification according to your risk policy.
    • Set appropriate actions (NO_ACTION or DECLINE) 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.
  5. Error Handling:

    • Implement proper error handling in your application.
    • Provide clear guidance to users when verification fails.
    • Consider implementing retry logic with improved instructions.