DigiLocker Integration Guide

This section explains how to integrate DigiLocker workflows on the client side using the provided API endpoints.

1. Account Verification (Optional, for Dynamic Orchestration)

  • Step 1: Call /digilocker/verify_account with the user's mobile number.
  • Step 2: Based on the response:
    • If the account exists, set redirect_to_signup to false in the next step.
    • If the account does not exist, set redirect_to_signup to true.
  • This step is optional and only required if you want to orchestrate dynamic user journeys.

2. Initiate DigiLocker Session

  • Call /digilocker/initiate_session with required parameters.
  • Pass redirect_url where the user will be redirected after completing DigiLocker authentication.
  • If you want the user to sign up for DigiLocker, set redirect_to_signup to true; otherwise, set it to false.
  • For document consent, use the documents_for_consent array. Document codes can be fetched from /digilocker/doc_master.
  • To maintain state pass state with a valid string. This state will be returned as query parameter in the redirect_url.

3. Handle Redirect and Obtain Reference Key

  • After the user completes the DigiLocker flow, they will be redirected to your specified redirect_url with code and code_verifier as query parameters.
  • Pass these values to /digilocker/get_reference to obtain a reference_key (valid for 1 hour).

4. Fetch User Documents

  • Use the reference_key to fetch documents the user has consented to.
  • For issued documents, call /digilocker/issued_docs to get a list of available documents.
  • To fetch a specific document, use /digilocker/get_issued_docs (for binary files) or /digilocker/get_issued_docs_xml (for XML files). Both require the reference_key and an additional uri parameter, which you can obtain from /digilocker/issued_docs.

Notes

  • Document codes for consent can be retrieved from /digilocker/doc_master.
  • The reference_key expires in 1 hour; ensure document fetch operations are completed within this window.
  • All endpoints require API key and client ID authentication.

This workflow enables seamless DigiLocker integration for document verification and consent management.