Verify DigiLocker
curl --request POST \
--url https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"redirectUrl": "<string>",
"deviceId": "<string>"
}
'import requests
url = "https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init"
payload = {
"redirectUrl": "<string>",
"deviceId": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({redirectUrl: '<string>', deviceId: '<string>'})
};
fetch('https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'redirectUrl' => '<string>',
'deviceId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init"
payload := strings.NewReader("{\n \"redirectUrl\": \"<string>\",\n \"deviceId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"redirectUrl\": \"<string>\",\n \"deviceId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"redirectUrl\": \"<string>\",\n \"deviceId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyKYC
Verify DigiLocker
DigiLocker-based Aadhaar verification
POST
/
v2
/
users
/
{userId}
/
kyc
/
digilocker
/
init
Verify DigiLocker
curl --request POST \
--url https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"redirectUrl": "<string>",
"deviceId": "<string>"
}
'import requests
url = "https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init"
payload = {
"redirectUrl": "<string>",
"deviceId": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({redirectUrl: '<string>', deviceId: '<string>'})
};
fetch('https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'redirectUrl' => '<string>',
'deviceId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init"
payload := strings.NewReader("{\n \"redirectUrl\": \"<string>\",\n \"deviceId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"redirectUrl\": \"<string>\",\n \"deviceId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.stablepay.global/v2/users/{userId}/kyc/digilocker/init")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"redirectUrl\": \"<string>\",\n \"deviceId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyDigiLocker Verification
DigiLocker verification lets users share their Aadhaar directly from the government DigiLocker service. This is a more user-friendly alternative to Aadhaar OTP verification.Flow Overview
- Initialize - Get a DigiLocker consent URL
- User Consent - User opens URL and grants consent in DigiLocker app
- Check Status - Poll status until verification completes
Initialize DigiLocker Session
Optional URL DigiLocker sends the user to after consent. It must be a public
https URL; anything else is ignored and the account’s default applies.Request
curl -X POST https://api.stablepay.global/v2/users/usr_abc123/kyc/digilocker/init \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"redirectUrl": "https://yourapp.com/kyc/callback",
"deviceId": "device-fingerprint-12345"
}'
Response
{
"success": true,
"data": {
"redirectUrl": "https://digilocker-sdk.notbot.in/?gateway=production&type=digilocker&token=...",
"sessionId": "digilocker_abc123xyz",
"expiresAt": "2026-10-30T10:30:00.000Z"
}
}
Send the user to
redirectUrl to complete DigiLocker consent. The session expires at expiresAt. If the user starts again, the new session replaces the old one: status always checks the most recent.Check DigiLocker Status
Poll this endpoint untilstatus is completed, failed or expired. It checks the user’s most recent session, so there is nothing to pass.
Request
curl -X GET https://api.stablepay.global/v2/users/usr_abc123/kyc/digilocker/status \
-H "Authorization: Bearer YOUR_API_KEY"
Response (Completed)
{
"success": true,
"data": {
"status": "completed",
"documentsFetched": ["AADHAAR"],
"aadhaarVerified": true,
"completedAt": "2026-10-30T10:04:12.000Z",
"aadhaar": {
"name": "RAHUL SHARMA",
"dob": "1990-05-15",
"maskedNumber": "XXXX-XXXX-1234"
}
}
}
aadhaar details, so a lost response can be fetched again.
Response (Pending)
{
"success": true,
"data": {
"status": "pending",
"documentsFetched": [],
"aadhaarVerified": false,
"message": "Waiting for user to complete DigiLocker verification"
}
}
pending for a few seconds after the user finishes, until the Aadhaar details can be read.
Response (Expired)
{
"success": true,
"data": {
"status": "expired",
"documentsFetched": [],
"aadhaarVerified": false,
"error": "DigiLocker session has expired. Please generate a new token."
}
}
Status Values
| Status | Description |
|---|---|
not_initiated | No DigiLocker session has been started for this user |
pending | The user hasn’t finished DigiLocker consent, or the Aadhaar details can’t be read yet |
completed | Verification complete; aadhaar carries the name, date of birth and masked number |
failed | User cancelled or verification failed. Start a new session |
expired | Session expired before completion. Start a new session |
Benefits Over Aadhaar OTP
| Feature | DigiLocker | Aadhaar OTP |
|---|---|---|
| User Experience | Single consent flow | Enter OTP manually |
| Security | OAuth 2.0 based | SMS OTP |
| Consent Record | Government maintained | None |
Errors
error | Description |
|---|---|
Not Found | User not found, or not one of your users |
DigiLocker Error | DigiLocker could not be started (init only) |
