Aadhaar OTP eKYC API
A two-step API. Step one sends an OTP to the mobile linked with the user's Aadhaar, step two submits that OTP and returns the eKYC record: name, DOB, gender, address and photo.
- Source
- UIDAI eKYC service, via a licensed KUA/AUA arrangement
- Turnaround
- Real time once the user enters the OTP; the OTP itself usually arrives within a minute
- Endpoint
- POST /v1/aadhaar/ekyc/otp
- Who can use it
- Only for entities allowed to use Aadhaar authentication under the Aadhaar Act and its 2019 amendment, such as banks, NBFCs, insurers and others notified by the government.
Overview
The standard Aadhaar eKYC flow most regulated lenders and insurers use. The user enters their Aadhaar number, receives an OTP from UIDAI, and types it into your app. You get their demographic details and photo straight from UIDAI, with the consent tied to that transaction.
Good to know
If the user's mobile is not linked to Aadhaar, the OTP never arrives and the flow cannot finish. Offer DigiLocker or offline Aadhaar as a fallback.
What you get
- Data straight from UIDAIName, DOB and address come from the source record, not from an uploaded card that could have been edited.
- Photo for face matchThe eKYC photo can go straight into a face match against the user's selfie.
- Two calls, clear statesGenerate OTP, then submit OTP. Each step has its own error codes for wrong OTP, expired OTP and too many attempts.
- Consent tied to the callEach request carries the consent text the user saw, so your audit file shows exactly what they agreed to.
Request
POST https://api.ampletrails.com/v1/aadhaar/ekyc/otp
| Field | Type | Status | Description |
|---|---|---|---|
id_number | string | Required | 12-digit Aadhaar number (step 1: generate OTP) |
consent | string | Required | Y if the user has given explicit consent |
request_id | string | Required | Reference returned by the OTP generation step (step 2: submit OTP) |
otp | string | Required | 6-digit OTP the user received on their Aadhaar-linked mobile |
Response
Fields inside data. Every response also carries status, request_id and, on errors, message. See error codes.
| Field | Meaning | Example |
|---|---|---|
full_name | Name as per Aadhaar | Ravi Kumar |
dob | Date of birth | 1990-04-12 |
gender | Gender: M, F or T | M |
address.line | House, street and locality | H.No. 12, Sector 15 |
address.district | District | Gurugram |
address.state | State | Haryana |
address.pincode | PIN code | 122001 |
photo_base64 | Photograph on the Aadhaar record, base64 encoded | /9j/4AAQSkZJRg... |
masked_aadhaar | Aadhaar number with the first 8 digits masked | XXXXXXXX4321 |
otp_verified | Whether the OTP verification succeeded | true |
Example
curl -X POST https://api.ampletrails.com/v1/aadhaar/ekyc/otp \
-H "Authorization: Bearer $AMPLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"id_number": "XXXXXXXX4321", "consent": "Y", "request_id": "ekyc_8f2a1c", "otp": "123456"}'import os, requests
resp = requests.post(
"https://api.ampletrails.com/v1/aadhaar/ekyc/otp",
headers={"Authorization": f"Bearer {os.environ['AMPLE_API_KEY']}"},
json={
"id_number": "XXXXXXXX4321",
"consent": "Y",
"request_id": "ekyc_8f2a1c",
"otp": "123456"
},
timeout=30,
)
resp.raise_for_status()
print(resp.json()["data"])const resp = await fetch("https://api.ampletrails.com/v1/aadhaar/ekyc/otp", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.AMPLE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"id_number": "XXXXXXXX4321",
"consent": "Y",
"request_id": "ekyc_8f2a1c",
"otp": "123456"
}),
});
const { data } = await resp.json();$ch = curl_init("https://api.ampletrails.com/v1/aadhaar/ekyc/otp");
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(["id_number" => "XXXXXXXX4321", "consent" => "Y", "request_id" => "ekyc_8f2a1c", "otp" => "123456"]),
]);
$data = json_decode(curl_exec($ch), true)["data"];{
"status": "success",
"request_id": "req_7f3a9c21e4",
"data": {
"full_name": "Ravi Kumar",
"dob": "1990-04-12",
"gender": "M",
"address": {
"line": "H.No. 12, Sector 15",
"district": "Gurugram",
"state": "Haryana",
"pincode": "122001"
},
"photo_base64": "/9j/4AAQSkZJRg...",
"masked_aadhaar": "XXXXXXXX4321",
"otp_verified": true
}
}Example data. The exact field list for your account comes with your sandbox documentation.
Use cases
NBFC and bank onboarding
Fills the KYC form for the customer and gives you the photo for the face match, in under two minutes.
Insurance proposals
Insurers fill proposer details from eKYC instead of typing them in from a photocopy.
Account re-KYC
Existing customers whose KYC is due can refresh it from their phone without visiting a branch.
Questions about this API
Can any company use Aadhaar OTP eKYC?
No. After the 2018 Supreme Court ruling and the 2019 amendment, only entities permitted by law or notified by the government can do Aadhaar authentication. If you're not one, use DigiLocker or offline Aadhaar instead and we'll help you set that up.
How long is the OTP valid?
A few minutes. If the user takes longer, call the generate step again. We return a clear OTP_EXPIRED error so your app can show a resend button.
Do we get the full Aadhaar number back?
No. You get it masked (last four digits). That is what you should store anyway.
What happens after three wrong OTPs?
UIDAI blocks further attempts for that number for a while. Show the user a clear message and offer another route such as DigiLocker rather than letting them keep trying.
Try the Aadhaar OTP eKYC API
Sandbox keys, the full field reference and a Postman collection, usually within a working day.