curl --request POST \
--url https://api.casparser.in/v1/kyc/digilocker/session \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"consent": true,
"consent_purpose": "KYC for loan account opening",
"redirect_url": "https://yourapp.com/digilocker/callback",
"state": "investor_42",
"documents": [
"aadhaar",
"pan"
],
"user_flow": "signin",
"prefill_mobile": "9999999999"
}
'import requests
url = "https://api.casparser.in/v1/kyc/digilocker/session"
payload = {
"consent": True,
"consent_purpose": "KYC for loan account opening",
"redirect_url": "https://yourapp.com/digilocker/callback",
"state": "investor_42",
"documents": ["aadhaar", "pan"],
"user_flow": "signin",
"prefill_mobile": "9999999999"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
consent: true,
consent_purpose: 'KYC for loan account opening',
redirect_url: 'https://yourapp.com/digilocker/callback',
state: 'investor_42',
documents: ['aadhaar', 'pan'],
user_flow: 'signin',
prefill_mobile: '9999999999'
})
};
fetch('https://api.casparser.in/v1/kyc/digilocker/session', 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.casparser.in/v1/kyc/digilocker/session",
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([
'consent' => true,
'consent_purpose' => 'KYC for loan account opening',
'redirect_url' => 'https://yourapp.com/digilocker/callback',
'state' => 'investor_42',
'documents' => [
'aadhaar',
'pan'
],
'user_flow' => 'signin',
'prefill_mobile' => '9999999999'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.casparser.in/v1/kyc/digilocker/session"
payload := strings.NewReader("{\n \"consent\": true,\n \"consent_purpose\": \"KYC for loan account opening\",\n \"redirect_url\": \"https://yourapp.com/digilocker/callback\",\n \"state\": \"investor_42\",\n \"documents\": [\n \"aadhaar\",\n \"pan\"\n ],\n \"user_flow\": \"signin\",\n \"prefill_mobile\": \"9999999999\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.casparser.in/v1/kyc/digilocker/session")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"consent\": true,\n \"consent_purpose\": \"KYC for loan account opening\",\n \"redirect_url\": \"https://yourapp.com/digilocker/callback\",\n \"state\": \"investor_42\",\n \"documents\": [\n \"aadhaar\",\n \"pan\"\n ],\n \"user_flow\": \"signin\",\n \"prefill_mobile\": \"9999999999\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.casparser.in/v1/kyc/digilocker/session")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"consent\": true,\n \"consent_purpose\": \"KYC for loan account opening\",\n \"redirect_url\": \"https://yourapp.com/digilocker/callback\",\n \"state\": \"investor_42\",\n \"documents\": [\n \"aadhaar\",\n \"pan\"\n ],\n \"user_flow\": \"signin\",\n \"prefill_mobile\": \"9999999999\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"session_id": "3f9a2c1e8b7d4e6fa1c2d3e4f5a6b7c8",
"authorization_url": "<string>",
"expires_in": 600
}Start DigiLocker session
Start a DigiLocker session to fetch the investor’s government-issued documents (Aadhaar, PAN, etc.) with their consent.
How it works:
- Call this endpoint — you get back an
authorization_urland asession_id. Thesession_idis the single identifier you use for everything else. - Redirect the investor to
authorization_urlto log in to DigiLocker and grant consent. - After consent, the investor is redirected back to your
redirect_urlwith query parameters appended (see the table below). - Use the
session_id(path parameter) on thePOST /v1/kyc/digilocker/result/{session_id}endpoint to read the consented data — identity, documents, and parsed document content.
Redirect parameters appended to your redirect_url:
| Outcome | Appended query parameters |
|---|---|
| Consent granted | ?success=true&id={session_id}&state={state}&documents=pan+driving_licence&has_verified_data=1 |
| Partial consent (e.g. PAN only) | ?success=true&id={session_id}&state={state}&documents=pan |
| Consent denied / failed | ?success=false&id={session_id}&state={state}&error={error} |
documents lists the documents the investor agreed to share;
has_verified_data=1 appears only when verified identity is available.
Credits: Free. Billing happens when documents/identity are returned.
curl --request POST \
--url https://api.casparser.in/v1/kyc/digilocker/session \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"consent": true,
"consent_purpose": "KYC for loan account opening",
"redirect_url": "https://yourapp.com/digilocker/callback",
"state": "investor_42",
"documents": [
"aadhaar",
"pan"
],
"user_flow": "signin",
"prefill_mobile": "9999999999"
}
'import requests
url = "https://api.casparser.in/v1/kyc/digilocker/session"
payload = {
"consent": True,
"consent_purpose": "KYC for loan account opening",
"redirect_url": "https://yourapp.com/digilocker/callback",
"state": "investor_42",
"documents": ["aadhaar", "pan"],
"user_flow": "signin",
"prefill_mobile": "9999999999"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
consent: true,
consent_purpose: 'KYC for loan account opening',
redirect_url: 'https://yourapp.com/digilocker/callback',
state: 'investor_42',
documents: ['aadhaar', 'pan'],
user_flow: 'signin',
prefill_mobile: '9999999999'
})
};
fetch('https://api.casparser.in/v1/kyc/digilocker/session', 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.casparser.in/v1/kyc/digilocker/session",
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([
'consent' => true,
'consent_purpose' => 'KYC for loan account opening',
'redirect_url' => 'https://yourapp.com/digilocker/callback',
'state' => 'investor_42',
'documents' => [
'aadhaar',
'pan'
],
'user_flow' => 'signin',
'prefill_mobile' => '9999999999'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.casparser.in/v1/kyc/digilocker/session"
payload := strings.NewReader("{\n \"consent\": true,\n \"consent_purpose\": \"KYC for loan account opening\",\n \"redirect_url\": \"https://yourapp.com/digilocker/callback\",\n \"state\": \"investor_42\",\n \"documents\": [\n \"aadhaar\",\n \"pan\"\n ],\n \"user_flow\": \"signin\",\n \"prefill_mobile\": \"9999999999\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.casparser.in/v1/kyc/digilocker/session")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"consent\": true,\n \"consent_purpose\": \"KYC for loan account opening\",\n \"redirect_url\": \"https://yourapp.com/digilocker/callback\",\n \"state\": \"investor_42\",\n \"documents\": [\n \"aadhaar\",\n \"pan\"\n ],\n \"user_flow\": \"signin\",\n \"prefill_mobile\": \"9999999999\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.casparser.in/v1/kyc/digilocker/session")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"consent\": true,\n \"consent_purpose\": \"KYC for loan account opening\",\n \"redirect_url\": \"https://yourapp.com/digilocker/callback\",\n \"state\": \"investor_42\",\n \"documents\": [\n \"aadhaar\",\n \"pan\"\n ],\n \"user_flow\": \"signin\",\n \"prefill_mobile\": \"9999999999\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"session_id": "3f9a2c1e8b7d4e6fa1c2d3e4f5a6b7c8",
"authorization_url": "<string>",
"expires_in": 600
}Authorizations
Your API key for authentication.
Use sandbox-with-json-responses as Sandbox key.
Body
Explicit end-user consent. Must be true to proceed
(regulatory requirement under DPDP / RBI). Captured for audit.
true
Specific purpose for which consent is taken (min 20 chars). Stored in the session and returned as a consent receipt.
20"KYC for loan account opening"
Where to redirect the user after consent. Must be a valid http/https URL.
"https://yourapp.com/digilocker/callback"
Opaque value echoed back to your redirect_url unchanged.
"investor_42"
Identities to verify and return in the response.
aadhaar, pan, driving_licence, email, mobile ["aadhaar", "pan"]
Use "signin" for users with an existing DigiLocker account, "signup" for account-on-the-fly.
signin, signup "signin"
Pre-verified mobile to skip the signup OTP step (only applies with user_flow=signup).
"9999999999"
Response
Session started; redirect the user to authorization_url
"success"
The single identifier for this verification. Use it as the
path parameter in POST /v1/kyc/digilocker/result/{session_id}
to retrieve identity + documents.
"3f9a2c1e8b7d4e6fa1c2d3e4f5a6b7c8"
DigiLocker consent URL to redirect the investor to.
Seconds the authorization_url is valid for.
600
Was this page helpful?

