Skip to content

DigiLocker Verification

Access verified government-issued documents (Aadhaar, PAN, Driving License) through the DigiLocker platform. This is a two-step process: first generate an authorization URL, then fetch the verified documents.

Step 1: Generate authorization URL

POST /vas-api/v1/digilocker-init

Body parameters

FieldTypeRequiredDescriptionExample
pinlessVerificationbooleanYestrue for PIN-less Aadhaar, false for PIN-basedfalse
successWebhookUrlstringNoURL to receive success callbackhttps://yourapp.com/webhook/success
failureWebhookUrlstringNoURL to receive failure callbackhttps://yourapp.com/webhook/failure

Example request

bash
curl -X POST https://api.api4business.com/vas-api/v1/digilocker-init \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "pinlessVerification": false,
    "successWebhookUrl": "https://yourapp.com/webhook/success",
    "failureWebhookUrl": "https://yourapp.com/webhook/failure"
  }'
python
import requests

response = requests.post(
  "https://api.api4business.com/vas-api/v1/digilocker-init",
  headers={
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Content-Type": "application/json"
  },
  json={
    "pinlessVerification": False,
    "successWebhookUrl": "https://yourapp.com/webhook/success",
    "failureWebhookUrl": "https://yourapp.com/webhook/failure"
  }
)
print(response.json())
javascript
const response = await fetch(
  "https://api.api4business.com/vas-api/v1/digilocker-init",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_ACCESS_TOKEN",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      pinlessVerification: false,
      successWebhookUrl: "https://yourapp.com/webhook/success",
      failureWebhookUrl: "https://yourapp.com/webhook/failure"
    })
  }
);
console.log(await response.json());
java
String body = """
  {"pinlessVerification": false,
   "successWebhookUrl": "https://yourapp.com/webhook/success",
   "failureWebhookUrl": "https://yourapp.com/webhook/failure"}""";
HttpRequest request = HttpRequest.newBuilder()
  .uri(URI.create("https://api.api4business.com/vas-api/v1/digilocker-init"))
  .header("Authorization", "Bearer YOUR_ACCESS_TOKEN")
  .header("Content-Type", "application/json")
  .POST(HttpRequest.BodyPublishers.ofString(body))
  .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

Response

json
{
  "ok": true,
  "responseCode": 200,
  "message": "Transmission OK",
  "body": {
    "sessionId": "70f7de1a-426a-4cf9-8e7f-9f83e33333ed",
    "url": "https://api.digitallocker.gov.in/public/oauth2/1/authorize?response_type=code&client_id=..."
  }
}

Redirect the user to the url to complete DigiLocker authorization. After the user completes authorization, use the sessionId to fetch their documents.

Step 2: Fetch documents

POST /vas-api/v1/digilocker-fetch-status

Body parameters

FieldTypeRequiredDescriptionExample
sessionIdstringYesSession ID from the init step70f7de1a-426a-4cf9-8e7f-9f83e33333ed

Response

json
{
  "ok": true,
  "responseCode": 200,
  "message": "Transmission OK",
  "body": {
    "sessionId": "70f7de1a-426a-4cf9-8e7f-9f83e33333ed",
    "status": "Completed",
    "documents": [
      {
        "docType": "aadhaar",
        "idNumber": "xxxxxxxx0000",
        "name": "Sample User",
        "dob": "31121999",
        "gender": "M",
        "pdfUrl": "https://example.com/aadhaar.pdf",
        "xmlUrl": "https://example.com/aadhaar.xml"
      },
      {
        "docType": "pan",
        "idNumber": "ABCDE1234F",
        "name": "Sample User",
        "dob": "31121999",
        "gender": "M",
        "pdfUrl": "https://example.com/pan.pdf",
        "xmlUrl": "https://example.com/pan.xml"
      }
    ]
  }
}

Response headers

HeaderDescription
x-request-idUnique request identifier — log this for debugging and support

Error responses

StatusError CodeMessageResolution
400400failed to read request bodyVerify JSON body is valid
400400sessionId expired or invalidThe session has expired — reinitiate
401401Invalid CredentialsRefresh your access token
429429Quota ViolationRate limit exceeded
500500Internal Server ErrorRetry after delay

Released under the API4Business Terms of Service