KYC API
One DigiLocker connection for every Laraware portal. Your server starts a session, sends the user to DigiLocker, then reads the result back from this API.
Base URL
https://kyc.laraware.com
Send these headers on every API call. The secret stays on your server. Do not put it in browser JavaScript.
X-Client-Id: kyc_your_portal_id X-Client-Secret: kycs_your_portal_secret Content-Type: application/json
1. Start KYC
POST /api/v1/kyc/sessions
{
"reference": "user-1842",
"returnUrl": "https://domain-name.com/kyc/callback",
"webhookUrl": "https://domain-name.com/kyc/webhook",
"purpose": "kyc"
}
returnUrl and webhookUrl are optional. When omitted, the portal's saved return URL is used. Both must be https URLs on the registered domain. purpose is one of kyc, verification, compliance, availing_services, educational.
{
"success": true,
"data": {
"sessionId": "uuid",
"reference": "user-1842",
"status": "PENDING_USER_CONSENT",
"authorizationUrl": "https://digilocker.meripehchaan.gov.in/...",
"expiresIn": 900
}
}
Redirect the user's browser to authorizationUrl. The user enters Aadhaar details only on DigiLocker.
2. User returns to your portal
DigiLocker returns to this service. This service then redirects the browser to your returnUrl:
https://domain-name.com/kyc/callback?sessionId=uuid&reference=user-1842&status=AADHAAR_AVAILABLE
A refusal or failure uses status=FAILED and an error code. Confirm reference matches the user you started before trusting the redirect.
3. Read the result
GET /api/v1/kyc/sessions/{sessionId}
Call this from your server with the client id and secret. verified becomes true only after DigiLocker returns Aadhaar data (e-Aadhaar file with a passing integrity check, or signed identity claims).
complete is true only when DigiLocker returned the profile, a PAN and a driving licence. Otherwise status is INCOMPLETE and missing lists profile, pan_consent, pan_document, dl_consent or dl_document. Do not treat the user as verified unless complete is true; send them to start again and tick every document on the DigiLocker consent screen.
The response includes kyc (name, date of birth, gender, masked Aadhaar, address), documents (issued PAN and driving licence with masked numbers) and missingScopes. Anything DigiLocker did not share is left empty and listed in missingScopes.
GET /api/v1/kyc/sessions/{sessionId}/profile
GET /api/v1/kyc/sessions/{sessionId}/documents
GET /api/v1/kyc/sessions/{sessionId}/document?uri={uri}&format=file
GET /api/v1/kyc/sessions/{sessionId}/eaadhaar
POST /api/v1/kyc/sessions/{sessionId}/revoke
format is file or xml. Document and e-Aadhaar responses are the file itself, with X-Content-Integrity: verified.
Webhook
If you send webhookUrl, this service POSTs JSON when DigiLocker returns. Verify the signature with your client secret before trusting it.
X-Kyc-Timestamp: 1710000000
X-Kyc-Signature: hex hmac sha256 of "{timestamp}.{rawBody}"
Then call GET /api/v1/kyc/sessions/{sessionId}/eaadhaar when you need the verified Aadhaar record. The status response includes name, date of birth, gender, masked Aadhaar and address after that fetch.
Errors
401 invalid client credentials. 400 the URL is not on your domain or the body is invalid. 404 the session does not belong to your portal. 429 too many requests.
Add another portal
Open the admin panel, add the domain, and copy the client id and secret once. Each portal can only start KYC sessions that return to its own domain.