> ## Documentation Index
> Fetch the complete documentation index at: https://docs.deepidv.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Lookup an identity

> Query a government registry and optionally compare a selfie with the registry portrait

Send JSON with the ID type, number, and the holder's consent. Add names or date of birth for a field-by-field comparison. The request and response selector shows examples for each ID type, starting with BVN and a selfie. Ghana Card, CURP, and South African ID examples illustrate the contract. See [live availability](https://docs.deepidv.com/api-reference/identity-lookup/overview.md#identity-types-and-consent).

The reference examples use snake\_case. The API also accepts camelCase equivalents such as `idType`, `dateOfBirth`, and `externalId`.

## Add a selfie

Use a JPEG or PNG up to 5 MB. Send it as raw base64 or an image data URI in `selfie_base64`. For an uploaded selfie, call `POST /v1/upload/presign`, upload the image to the presigned URL, then pass the returned `fileKey` in `selfie_upload_key` using an API key for the same organization. Send one selfie input per request.

Set `face_match_threshold` between 70 and 95 to override the default of 80. See [face match results](https://docs.deepidv.com/api-reference/identity-lookup/results.md#face-match).

## Retry a lookup

When your backend may retry the same lookup, send a unique `Idempotency-Key` for that attempt and keep it with the original JSON body. See [retry behavior](https://docs.deepidv.com/api-reference/identity-lookup/errors.md#retry-with-an-idempotency-key).


## OpenAPI

````yaml assets/openapi.yaml POST /v1/identity/lookup
openapi: 3.1.0
info:
  title: deepidv Public API
  version: 0.1.0
  description: >-
    Server-to-server endpoints for the deepidv identity verification platform.
    Authenticate with a per-organization API key via the `x-api-key` header.
servers:
  - url: https://api.deepidv.com
    description: Production
security: []
paths:
  /v1/identity/lookup:
    post:
      tags:
        - Identity Lookup
      summary: Lookup an identity
      description: >-
        Query a government registry using an identity number and the holder's
        consent. Optionally compare names, date of birth, or a selfie. Use
        snake_case as shown here or the corresponding camelCase field names.
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            Reuse with the same body to replay a lookup for up to 24 hours
            within your organization.
          schema:
            type: string
            minLength: 1
            maxLength: 128
            pattern: ^[!-~]+$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IdentityLookupRequest'
            examples:
              bvnWithSelfie:
                summary: BVN sandbox fixture with a test selfie
                value:
                  id_type: bvn-ng
                  number: '00000000001'
                  consent: true
                  first_name: Ada
                  last_name: Okafor
                  date_of_birth: '1990-01-01'
                  selfie_base64: >-
                    iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+aK9sAAAAASUVORK5CYII=
                  face_match_threshold: 80
                  external_id: signup-example
              nin:
                summary: NIN sandbox fixture
                value:
                  id_type: nin-ng
                  number: '00000000001'
                  consent: true
                  return_full_number: true
              ghanaCard:
                summary: Ghana Card request format
                value:
                  id_type: ghana-card-gh
                  number: GHA-000000000-0
                  consent: true
              curp:
                summary: CURP request format
                value:
                  id_type: curp-mx
                  number: XEXX010101HNEXXXA4
                  consent: true
              southAfricanId:
                summary: South African ID request format
                value:
                  id_type: said-za
                  number: '9001015009086'
                  consent: true
      responses:
        '200':
          description: >-
            Lookup completed or replayed. Read status to determine whether the
            registry returned a record.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IdentityLookupResponse'
              examples:
                bvnWithSelfie:
                  summary: BVN sandbox fixture with a completed face match
                  value:
                    id: lookup_example_bvn
                    id_type: bvn-ng
                    status: verified
                    external_id: signup-example
                    number:
                      last4: '0001'
                      verified: true
                    record:
                      first_name: Ada
                      middle_name: Ngozi
                      last_name: Okafor
                      date_of_birth: '1990-01-01'
                      gender: female
                      phone_numbers:
                        - '+2348000000000'
                        - '+2348000000001'
                      address:
                        formatted: 1 Example Street, Example Town, Lagos
                        street: 1 Example Street
                        town: Example Town
                        lga: Example Town
                        state: Lagos
                      linked_ids:
                        nin: '00000000001'
                      enrollment:
                        bank: Example Bank
                        branch: Example Branch
                        registration_date: '2020-01-01'
                        level_of_account: null
                        watch_listed: null
                    matches:
                      first_name:
                        result: exact
                        score: 1
                      last_name:
                        result: exact
                        score: 1
                      date_of_birth:
                        result: exact
                        score: 1
                    face_match:
                      status: completed
                      match: true
                      similarity: 98
                      threshold: 80
                    created_at: '2026-11-20T10:00:00Z'
                nin:
                  summary: NIN with the full number requested
                  value:
                    id: lookup_example_nin
                    id_type: nin-ng
                    status: verified
                    number:
                      last4: '0001'
                      verified: true
                      full: '00000000001'
                    record:
                      first_name: Ada
                      last_name: Okafor
                    matches: {}
                    face_match: null
                    created_at: '2026-11-20T10:00:00Z'
                ghanaCard:
                  summary: Ghana Card response format
                  value:
                    id: lookup_example_ghana_card
                    id_type: ghana-card-gh
                    status: verified
                    number:
                      last4: 00-0
                      verified: true
                    record:
                      first_name: Ama
                      last_name: Mensah
                    matches: {}
                    face_match: null
                    created_at: '2026-11-20T10:00:00Z'
                curp:
                  summary: CURP response format
                  value:
                    id: lookup_example_curp
                    id_type: curp-mx
                    status: verified
                    number:
                      last4: XXA4
                      verified: true
                    record:
                      first_name: Juan
                      last_name: Perez
                      nationality: Mexican
                    matches: {}
                    face_match: null
                    created_at: '2026-11-20T10:00:00Z'
                southAfricanId:
                  summary: South African ID response format
                  value:
                    id: lookup_example_said
                    id_type: said-za
                    status: verified
                    number:
                      last4: '9086'
                      verified: true
                    record:
                      first_name: Thandi
                      last_name: Dlamini
                      nationality: South African
                    matches: {}
                    face_match: null
                    created_at: '2026-11-20T10:00:00Z'
                notFound:
                  summary: Registry record not found
                  value:
                    id: lookup_example_not_found
                    id_type: bvn-ng
                    status: not_found
                    number:
                      last4: '0002'
                      verified: false
                    record: null
                    matches: {}
                    face_match: null
                    created_at: '2026-11-20T10:00:00Z'
                replay:
                  summary: Replay with the same key and body
                  value:
                    id: lookup_example_bvn
                    id_type: bvn-ng
                    status: verified
                    external_id: signup-example
                    number:
                      last4: '0001'
                    matches:
                      first_name:
                        result: exact
                        score: 1
                      last_name:
                        result: exact
                        score: 1
                      date_of_birth:
                        result: exact
                        score: 1
                    face_match:
                      status: completed
                      match: true
                      similarity: 98
                      threshold: 80
                    replayed: true
                    created_at: '2026-11-20T10:00:00Z'
        '400':
          description: Invalid number, consent, selfie input, threshold, or request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Insufficient token balance.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: >-
            The x-api-key header is missing or invalid (the gateway returns
            {"message": "Forbidden"}), the organization, region, or ID type
            lacks live lookup access, or the upload key belongs to another
            organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                organizationAccess:
                  summary: Identity Lookup access required
                  value:
                    error: Identity lookup is not enabled
                    code: identity_lookup_not_enabled
                idTypeAccess:
                  summary: Live lookup unavailable for this ID type
                  value:
                    error: This identity type is not enabled
                    code: id_type_not_enabled
        '422':
          description: The idempotency key was already used with a different request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: A lookup rate limit was reached.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
                minimum: 1
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IdentityLookupRateLimitError'
              example:
                error: Lookup rate limit reached.
                limit: org_per_second
        '502':
          description: The registry provider returned an error or timed out.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Lookup is temporarily unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    IdentityLookupRequest:
      type: object
      required:
        - id_type
        - number
        - consent
      additionalProperties: false
      not:
        required:
          - selfie_base64
          - selfie_upload_key
      properties:
        id_type:
          $ref: '#/components/schemas/IdentityLookupIdType'
        number:
          type: string
          minLength: 1
          maxLength: 128
          description: >-
            Identity number as a string, including leading zeros. BVN and NIN
            use 11 digits. Ghana Card uses GHA-#########-#. CURP uses 18
            characters and South African ID uses 13 digits. The service
            validates the number for the selected registry.
        consent:
          type: boolean
          const: true
          description: The holder gave consent to query the registry.
        first_name:
          type: string
          maxLength: 256
          description: First name to compare with the registry record.
        middle_name:
          type: string
          maxLength: 256
          description: Middle name to compare with the registry record.
        last_name:
          type: string
          maxLength: 256
          description: Last name to compare with the registry record.
        date_of_birth:
          type: string
          maxLength: 40
          description: Date of birth to compare. Use YYYY-MM-DD.
          example: '1990-01-01'
        selfie_base64:
          type: string
          minLength: 1
          description: >-
            JPEG or PNG selfie up to 5 MB as raw base64 or an image data URI.
            Send only one selfie input.
        selfie_upload_key:
          type: string
          minLength: 1
          maxLength: 1024
          description: >-
            The fileKey returned by POST /v1/upload/presign for an uploaded
            selfie in your organization. Send only one selfie input.
        face_match_threshold:
          type: number
          minimum: 70
          maximum: 95
          default: 80
          description: Similarity threshold for a positive face match.
        return_full_number:
          type: boolean
          default: false
          description: Include the full number on the initial lookup response.
        external_id:
          type: string
          maxLength: 256
          description: Your reference for the lookup. The response echoes it when supplied.
    IdentityLookupResponse:
      type: object
      required:
        - id
        - id_type
        - status
        - number
        - matches
        - face_match
        - created_at
      properties:
        id:
          type: string
          description: Unique lookup ID.
        id_type:
          $ref: '#/components/schemas/IdentityLookupIdType'
        status:
          type: string
          enum:
            - verified
            - not_found
          description: >-
            Whether the registry returned a record. Field and face comparisons
            are separate.
        external_id:
          type: string
          description: Your reference for the lookup, echoed when supplied.
        number:
          $ref: '#/components/schemas/IdentityLookupNumber'
        record:
          $ref: '#/components/schemas/IdentityLookupRecord'
        matches:
          $ref: '#/components/schemas/IdentityLookupMatches'
        face_match:
          description: >-
            Selfie comparison result. Null when the request did not include a
            selfie.
          oneOf:
            - $ref: '#/components/schemas/IdentityLookupFaceMatchCompleted'
            - $ref: '#/components/schemas/IdentityLookupFaceMatchUnavailable'
            - type: 'null'
        replayed:
          type: boolean
          const: true
          description: >-
            True when the response replays a prior request using the same
            idempotency key.
        created_at:
          type: string
          format: date-time
          description: Lookup creation time.
    ErrorResponse:
      anyOf:
        - $ref: '#/components/schemas/SimpleErrorResponse'
        - $ref: '#/components/schemas/ValidationErrorResponse'
      description: >-
        Shared error envelope returned by all server-to-server endpoints. The
        shape depends on the failure mode: validation failures include `message`
        + `hints`; all other failures return a single `error` string.
    IdentityLookupRateLimitError:
      allOf:
        - $ref: '#/components/schemas/SimpleErrorResponse'
        - type: object
          required:
            - limit
          properties:
            limit:
              type: string
              description: Name of the limit reached.
              example: org_per_second
    IdentityLookupIdType:
      type: string
      enum:
        - bvn-ng
        - nin-ng
        - ghana-card-gh
        - curp-mx
        - said-za
      description: Government ID type. BVN and NIN are enabled for live lookups.
    IdentityLookupNumber:
      type: object
      required:
        - last4
      properties:
        last4:
          type: string
          minLength: 4
          maxLength: 4
          description: Last four characters of the identity number.
        verified:
          type: boolean
          description: Whether the registry found the number.
        full:
          type: string
          description: Full identity number when requested on the initial lookup.
    IdentityLookupRecord:
      type:
        - object
        - 'null'
      description: >-
        Registry fields available to this organization. Sensitive groups require
        approval.
      properties:
        first_name:
          type:
            - string
            - 'null'
        middle_name:
          type:
            - string
            - 'null'
        last_name:
          type:
            - string
            - 'null'
        date_of_birth:
          type:
            - string
            - 'null'
          description: Date of birth returned by the registry.
        gender:
          type:
            - string
            - 'null'
        nationality:
          type:
            - string
            - 'null'
        phone_numbers:
          type: array
          description: >-
            Approved phone numbers. Nigerian mobile numbers use E.164 format
            (+234XXXXXXXXXX); other numbers are returned as on file. An empty
            array means no phone is on file.
          items:
            type: string
        address:
          type: object
          description: >-
            Approved registry address. `formatted` is always present; the other
            parts appear when the registry supplies them.
          required:
            - formatted
          properties:
            formatted:
              type: string
              description: The address as one line.
            street:
              type: string
            town:
              type: string
            lga:
              type: string
              description: Local government area (Nigeria).
            state:
              type: string
        photo:
          type: string
          description: Approved registry portrait as an image data URI.
        linked_ids:
          type: object
          description: Approved linked ID numbers.
          additionalProperties:
            type: string
          properties:
            nin:
              type: string
              description: NIN linked to a BVN record.
        enrollment:
          type: object
          description: Approved registry enrollment details.
          required:
            - bank
            - branch
            - registration_date
            - level_of_account
            - watch_listed
          properties:
            bank:
              type:
                - string
                - 'null'
            branch:
              type:
                - string
                - 'null'
            registration_date:
              type:
                - string
                - 'null'
            level_of_account:
              type:
                - string
                - number
                - 'null'
            watch_listed:
              type:
                - boolean
                - 'null'
    IdentityLookupMatches:
      type: object
      description: Comparisons for the fields supplied on the request.
      properties:
        first_name:
          $ref: '#/components/schemas/IdentityLookupFieldMatch'
        middle_name:
          $ref: '#/components/schemas/IdentityLookupFieldMatch'
        last_name:
          $ref: '#/components/schemas/IdentityLookupFieldMatch'
        date_of_birth:
          $ref: '#/components/schemas/IdentityLookupFieldMatch'
    IdentityLookupFaceMatchCompleted:
      type: object
      required:
        - status
        - match
        - similarity
        - threshold
      properties:
        status:
          type: string
          const: completed
        match:
          type: boolean
          description: Whether the score met the threshold.
        similarity:
          type: number
          minimum: 0
          maximum: 100
          description: Best face similarity score.
        threshold:
          type: number
          minimum: 70
          maximum: 95
          description: Threshold used for this comparison.
    IdentityLookupFaceMatchUnavailable:
      type: object
      required:
        - status
        - reason
      properties:
        status:
          type: string
          const: unavailable
        reason:
          type: string
          enum:
            - no_registry_photo
            - no_face_in_selfie
    SimpleErrorResponse:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
          description: >-
            Machine-readable error code, when the failure has one. Unexpected
            server errors carry `INTERNAL_ERROR`.
          example: INTERNAL_ERROR
      required:
        - error
      description: >-
        Error returned for authentication failures, image format errors, and
        other terminal failures with a single human-readable message.
    ValidationErrorResponse:
      type: object
      properties:
        message:
          type: string
        hints:
          type: array
          items: {}
      required:
        - message
        - hints
      description: >-
        Error returned when the request body fails schema validation. `hints`
        contains the underlying Zod issues.
    IdentityLookupFieldMatch:
      type: object
      required:
        - result
        - score
      properties:
        result:
          type: string
          enum:
            - exact
            - partial
            - mismatch
        score:
          type: number
          minimum: 0
          maximum: 1
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Per-organization API key. Issued via the deepidv dashboard. Send on
        every request.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.