DigiLocker API & SDK
You create a session and send the user to DigiLocker. They log in, pick what to share, and you receive the issued documents (signed files plus parsed fields) by API or webhook.
- Source
- DigiLocker (MeitY), issued documents pulled from the issuing department
- Turnaround
- As fast as the user: usually one to two minutes from link to documents
- Endpoint
- POST /v1/digilocker/session
- Who can use it
- Businesses onboarded as DigiLocker requesters, which we handle through our partner arrangement. The user must consent inside DigiLocker.
Overview
DigiLocker gives you original documents from the department that issued them, not a photo of a card. For most private companies it is the cleanest way to get Aadhaar details with full name and address. The user logs in, ticks what to share, and the signed documents come back to you.
Good to know
Only documents the issuing department has pushed to DigiLocker are available. Users without an Aadhaar-linked mobile may struggle to log in.
What you get
- Issued, signed documentsAadhaar, PAN, DL and others come with the issuer's signature, so tampering shows.
- Hosted consent screenThe user consents on DigiLocker's own pages; you don't build any of the login or OTP UI.
- Parsed fieldsWe parse names, dates and addresses from the documents so you don't need your own parser.
- Webhook on completionYou get a callback when the user finishes, so your flow doesn't have to poll.
Request
POST https://api.ampletrails.com/v1/digilocker/session
| Field | Type | Status | Description |
|---|---|---|---|
redirect_url | string | Required | Where to send the user after they finish the DigiLocker consent flow |
documents | array | Optional | Document types to request, such as AADHAAR, PAN or DRIVING_LICENSE |
reference_id | string | Optional | Your own reference for this user or session |
Response
Fields inside data. Every response also carries status, request_id and, on errors, message. See error codes.
| Field | Meaning | Example |
|---|---|---|
session_id | ID of the DigiLocker session | dl_sess_7c1e2a |
auth_url | Hosted URL where the user logs in and gives consent | https://digilocker.example/auth?s=... |
status | Session status: CREATED, CONSENTED, COMPLETED or EXPIRED | COMPLETED |
documents[].type | Type of each fetched document | AADHAAR |
documents[].issuer | Issuing department | UIDAI |
documents[].data | Parsed fields from the document, such as name, DOB and address | {"name": "Ravi Kumar"} |
documents[].file_url | Short-lived link to download the signed document (PDF/XML) | https://files.example/abc.pdf |
Example
curl -X POST https://api.ampletrails.com/v1/digilocker/session \
-H "Authorization: Bearer $AMPLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"redirect_url": "https://yourapp.com/kyc/done", "documents": ["AADHAAR", "PAN"], "reference_id": "user_10293", "consent": "Y"}'import os, requests
resp = requests.post(
"https://api.ampletrails.com/v1/digilocker/session",
headers={"Authorization": f"Bearer {os.environ['AMPLE_API_KEY']}"},
json={
"redirect_url": "https://yourapp.com/kyc/done",
"documents": [
"AADHAAR",
"PAN"
],
"reference_id": "user_10293",
"consent": "Y"
},
timeout=30,
)
resp.raise_for_status()
print(resp.json()["data"])const resp = await fetch("https://api.ampletrails.com/v1/digilocker/session", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.AMPLE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"redirect_url": "https://yourapp.com/kyc/done",
"documents": [
"AADHAAR",
"PAN"
],
"reference_id": "user_10293",
"consent": "Y"
}),
});
const { data } = await resp.json();$ch = curl_init("https://api.ampletrails.com/v1/digilocker/session");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("AMPLE_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(["redirect_url" => "https://yourapp.com/kyc/done", "documents" => ["AADHAAR", "PAN"], "reference_id" => "user_10293", "consent" => "Y"]),
]);
$data = json_decode(curl_exec($ch), true)["data"];{
"status": "success",
"request_id": "req_7f3a9c21e4",
"data": {
"session_id": "dl_sess_7c1e2a",
"auth_url": "https://digilocker.example/auth?s=...",
"status": "COMPLETED",
"documents": {
"type": "AADHAAR",
"issuer": "UIDAI",
"data": {
"name": "Ravi Kumar"
},
"file_url": "https://files.example/abc.pdf"
}
}
}Example data. The exact field list for your account comes with your sandbox documentation.
Use cases
KYC for non-regulated fintechs
The main Aadhaar route for companies that can't use OTP eKYC.
Education and hiring
Pull marksheets and certificates where boards and universities issue to DigiLocker.
Broking account opening
Fetch Aadhaar and PAN together in one consented step.
Questions about this API
Is DigiLocker Aadhaar accepted for KYC?
For many regulated entities, yes, as officially valid evidence, since it comes signed from UIDAI. Check with your compliance team for your specific regulator.
What if the user doesn't have a DigiLocker account?
They can create one in the same flow with their Aadhaar-linked mobile. It takes a minute or two.
How long can I download the files?
The file links we return are short-lived. Download and store what you need, masked where required, as soon as you get the webhook.
Does it work on mobile apps?
Yes. Open the auth_url in a browser tab or in-app browser and catch the redirect when it comes back.
Try the DigiLocker API & SDK API
Sandbox keys, the full field reference and a Postman collection, usually within a working day.