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
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
| pinlessVerification | boolean | Yes | true for PIN-less Aadhaar, false for PIN-based | false |
| successWebhookUrl | string | No | URL to receive success callback | https://yourapp.com/webhook/success |
| failureWebhookUrl | string | No | URL to receive failure callback | https://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
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
| sessionId | string | Yes | Session ID from the init step | 70f7de1a-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
| Header | Description |
|---|---|
| x-request-id | Unique request identifier — log this for debugging and support |
Error responses
| Status | Error Code | Message | Resolution |
|---|---|---|---|
| 400 | 400 | failed to read request body | Verify JSON body is valid |
| 400 | 400 | sessionId expired or invalid | The session has expired — reinitiate |
| 401 | 401 | Invalid Credentials | Refresh your access token |
| 429 | 429 | Quota Violation | Rate limit exceeded |
| 500 | 500 | Internal Server Error | Retry after delay |
Related
- PAN Verification — Direct PAN check without DigiLocker
- KYC Overview