#DigiLocker

#What is DigiLocker?

DigiLocker is a document wallet from Government of India. Citizens can use it to store digital versions of various documents which include Aadhaar card, driving license, marks sheets, ration card and lot more.

Documents are fetched into DigiLocker directly from source of the issuer and are deemed to be at par with original physical documents as per Rule 9A of the Information Technology Rules, 2016. Documents can also be uploaded by citizens, for storage on DigiLocker.

Read more about DigiLocker and the various documents supported here.


#What can I do with this product?

Fetch documents of your users instantly and directly from the issuing authority, with user consent. Use the fetched documents to perform KYC without any delay.

DigiLocker has a wide variety of documents—covering a large number of government organisations, educational institutions, banks etc. that can be leveraged to ease the onboarding and verification journeys for your customers.


Was this page helpful?

#DigiLocker integration

(website name) DigiLocker APIs can be used to fetch documents of your users instantly—with their consent.

Here’s a quick run through of the APIs—

  • Create a DigiLocker request—Create a request to start the user journey, with which you can get user consent and then fetch the document from user’s digilocker. You get an id in response, which you can use to track this request throughout the journey.
  • Get DigiLocker request status—Check status of a request that was created by passing the request id, at any point in the journey.
  • Get list of all docs available—Get a global list of all documents that DigiLocker lets you fetch and the identifiers required to fetch a particular document.
  • Fetch a document—Get the document that the user has consented to share with you, made available as a file URL to download. All docs other than Aadhaar, can be fetched with this API.
  • Fetch Aadhaar data—Fetch Aadhaar document data in JSON format as well as an XML file. The API response is consistent with our OKYC APIs, which aids in replacing OKYC with DigiLocker, for carrying out Aadhaar KYC.
  • Revoke access token—Revoke the OAuth user token, once necessary user documents are fetched.

Additionally, here are the URLs you would need for these APIs—

  • Sandbox—https://dg-sandbox.(website name).co
  • Production—https://dg.(website name).co
  • Headers—Contact (website name) for providing the credentials required to successfully call (website name) APIs. This contains:
    • x-client-id
    • x-client-secret
    • x-product-instance-id

#Create a DigiLocker request

Call this API to create a new DigiLocker request. Pass the redirectUrl in the request body.

A DigiLocker account is not mandatory for a user to start this flow. If the user does not have a DigiLocker account, DigiLocker will automatically create an account during the consent journey. User has to sign up by providing their Aadhaar number and authenticate with the OTP sent to Aadhaar registered mobile number.


To sign up for DigiLocker, user should have linked their mobile number with Aadhaar.



Usage of the redirect URL

You have to provide a redirectUrl in the request, which has to be a valid publicly hosted URL—the user gets redirected to this URL after going through DigiLocker Sign in / Sign up and consent screens.

It will also be used by (website name) to send back relevant information about a request. By default (website name) includes the success flag of the user consent and DigiLocker request id.

  • For a failed user consent, we will send back—<redirectUrl>?success={false}&id={Digilocker_request.id}&errCode={code}&errMessage={message}
  • For a successful signature—<redirect_url>?success={true}&id={Digilocker_request.id}

You can also add custom query params such as session id from your end. You would append this to the provided URL, like so—(redirectUrl)?sessionId=XYZ


(website name) has processed your request successfully.


Request
POST /api/digilocker/
{
"redirectUrl": "https://(website name).co"
}

Response

You will get the following details—

  • Unique DigiLocker request id which can be used to manage this request.
  • The status will be unauthenticated for requests that do not have user consent yet and will change to authenticated once the user has provided their consent. You can check the status of a request at any point of time, using the Get DigiLocker request status API.
  • The url from the response should be used to redirect your user to Sign in / Sign up and provide consent to access their DigiLocker.
  • Validity of this request in ISO 8601 format timestamp, after which the request is expired and deleted.
{
"id": "ea31e1e6-96eb-4e56-a355-7bc51de94d24",
"status": "unauthenticated", //ENUM values—unauthenticated | authenticated | revoked
"url": "User login url",
"validUpto": "2021-10-05T19:06:28+05:30"
}

#Get DigiLocker request status

Call this API to get status of a DigiLocker request.


(website name) has processed your request successfully.


Request

Pass the DigiLocker request id as a URL parameter

GET /api/digilocker/:id/status

Response

You will get the following details—

  • DigiLocker request id

  • The status will be unauthenticated for requests that do not have user consent yet and will change to authenticated once the user has provided their consent.

  • The url from the response should be used to redirect your user to Sign in / Sign up and provide consent to access their DigiLocker.

  • Validity of this request in ISO 8601 format timestamp, after which the request is expired and deleted.

{
"id": "477dc21a-fa28-4c7f-9291-f35d63d5bda7",
"status": "authenticated", //ENUM values—unauthenticated | authenticated | revoked
"url": "User login url",
"validUpto": "2021-10-06T08:43:18+05:30"
}

#Get list of all docs available

Call this API to get a global list of all documents that DigiLocker lets you fetch and the corresponding meta data for each document.

This list can be very huge and the response can take a few minutes. It is recommended that you store this list on your end for usage in your application.


Consider updating this list of documents only once every month or as needed, as it does not change very often.


(website name) has processed your request successfully.


Request
GET /api/digilocker/documents

Response

Each document in the response has the following details—

  • availableFormats is an array that specifies the formats in which the document is made available through DigiLocker.
  • description specifies the name of the document, as given by the document issuer.
  • docType is a short code that identifies the type of the document.
  • orgId is the code of the document issuer.
  • orgName is the name of the document issuer

To uniquely identify a document, both docType and orgId are necessary. Multiple issuers, with their unique orgId, can issue documents which can be of the same docType. A quick example would be driving license being issued by different states—the docType is same whereas the orgId differs.

  • parameters is an array that contains key-value pairs, which specifies the user-specific identifiers required to fetch the document. You can use the description to aid your user, to input information on your UI.

A document can require more than one parameter, as specified by the document issuer.


description key-value pair in parameters array, is only for your information and should not to be passed as an identifier to fetch that document


{
"documents": [
{
"availableFormats": [
"pdf"
],
"description": "Pension Certificate",
"docType": "PECER",
"orgId": "002317",
"orgName": "Accountants General, Tripura",
"parameters": [
{
"description": "Account No./PPO No.",
"name": "AC_NO"
}
]
},
{
"availableFormats": [
"pdf"
],
"description": "Provident Fund Member Passbook",
"docType": "PRFND",
"orgId": "002317",
"orgName": "Accountants General, Tripura",
"parameters": [
{
"description": "Account No./PPO No.",
"name": "AC_NO"
},
{
"description": "Name of the member",
"name": "MemberName"
}
]
}
]
}

#Fetch a document

Call this API to fetch document of a user from DigiLocker.


(website name) has processed your request successfully and the document was fetched.


Request

Provide the following details in the request—

  • DigiLocker request id as a URL parameter
  • Refer to the response of Get list of all docs available API for obtaining document specific values explained here—
    • docType of the document
    • orgId of the document issuer
    • The format in which you require the document. This should be one of the formats that the document is actually available in.
    • User consent should be Y to attempt a document fetch
    • parameters is an array that contains key-value pairs, which specifies the identifiers required to fetch the document. Refer to the sample response of Get list of all docs available API for a detailed explanation of parameters array.

Note that for each parameter specified by the document issuer—

The first element has to be the key-value pair specified by the document issuer, like so— "name": "MemberName".
The second element should be the key-value pair with the actual value of the parameter specified, like so— "value":"Ramesh".


POST /api/digilocker/:id/document
{
"docType": "PRFND",
"orgId": "002317",
"format": "pdf",
"consent": "Y",
"parameters": [ {
"name": "AC_NO",
"value": "98432234234"
},
{
"name": "MemberName",
"value": "Ramesh"
}]
}

Response

You will get the following details—

  • fileUrl to download fetched document

  • Validity of the fileUrl in ISO 8601 format timestamp

{
"fileUrl": "s3_url of the file to be downloaded",
"validUpto": "2021-09-21T09:12:12+05:30"
}

#Fetch Aadhaar data

Call this API to fetch the Aadhaar data of a user from DigiLocker. The Aadhaar XML file is signed by DigiLocker.


(website name) has processed your request successfully and Aadhaar data was fetched successfully.


Request

Provide the DigiLocker request id in the request—

GET /api/digilocker/:id/aadhaar

Response

You will get the Aadhaar data of the user as JSON along with thefileUrl to Aadhaar XML.

The shareCode will always be empty for this API and is present to match the JSON response of (website name) OKYC APIs.


{
"aadhaar": {
"address": {
"careOf": "S/O John Doe",
"country": "India",
"district": "district",
"house": "house address",
"landmark": "",
"locality": "locality",
"pin": "123456",
"postOffice": "",
"state": "state",
"street": "",
"subDistrict": "",
"vtc": "vtc"
},
"dateOfBirth": "01-01-1990",
"email": "",
"gender": "M",
"generatedAt": "2021-10-26T17:17:36.342+05:30",
"maskedNumber": "xxxx-xxxx-1234",
"name": "Jack Doe",
"phone": "",
"photo": "",
"verified": {
"email": false,
"phone": false,
"signature": true
},
"xml": {
"fileUrl": "https://s3linkgoeshere.com",
"shareCode": "",
"validUntil": "2021-10-09T06:04:16+05:30"
}
},
"id": "391a45be-d08d-4dd0-b8a8-06e53392d435",
"status": "complete"
}

#Revoke DigiLocker request

Call this API to revoke a DigiLocker request. The request id can no longer be used to interact with user’s DigiLocker.


(website name) has processed your request successfully.


Request

Provide the DigiLocker request id in the request—

GET /api/digilocker/:id/revoke

Response
{
"success": true
}

Was this page helpful?

Data Gateway - Digilocker


Base URL

https://dg-sandbox.(website name).co

Authentication

HTTP authentication - bearer

Description

DigiLocker is a document wallet approved by Government of India, that citizens can use to store digital versions of documents like Aadhaar, driving license, marks sheets, ration card and more. This API works best to get Aadhaar details of your user. Check how to get started here

Create a Digilocker Request

https://dg-sandbox.(website name).co/api/digilocker


Request

Header parameters

x-client-id

string

Required

x-client-secret

string

Required

x-product-instance-id

string

Required


Body

redirectUrl

string

Required

Response

Body

id

string

Required

url

string

Required

validUpto

string

Required

status

string

Required

Language

curl

Node

Python

Go

Request sample


curl --request POST \
--url https://dg-sandbox.(website name).co/api/digilocker \
--header 'content-type: application/json' \
--header 'x-client-id: test-client' \
--header 'x-client-secret: 891707ee-d6cd-4744-a28d-058829e30f12' \
--header 'x-product-instance-id: 891707ee-d6cd-4744-a28d-058829e30f10' \
--data '{
"redirectUrl": "https://(website name).co"
}'
201 CREATED

Response sample


{
"id": "ea31e1e6-96eb-4e56-a355-7bc51de94d24",
"status": "unauthenticated",
"url": "User login url",
"validUpto": "2021-10-05T19:06:28+05:30"
}

Fetch a document

https://dg-sandbox.(website name).co/api/digilocker/{requestId}/document


Request

Path parameters

requestId

string

Required


Header parameters

x-client-id

string

Required

x-client-secret

string

Required

x-product-instance-id

string

Required


Body

docType

string

Required

format

string

Required

consent

string

Required

Response

Body

fileUrl

string

Required

validUpto

string

Required

Language

curl

Node

Python

Go

Request sample


curl --request POST \
--url https://dg-sandbox.(website name).co/api/digilocker/{requestId}/document \
--header 'content-type: application/json' \
--header 'x-client-id: test-client' \
--header 'x-client-secret: 891707ee-d6cd-4744-a28d-058829e30f12' \
--header 'x-product-instance-id: 891707ee-d6cd-4744-a28d-058829e30f10' \
--data '{
"docType": "AADHAAR",
"format": "pdf",
"consent": "Y"
}'
200 OK

Response sample


{
"fileUrl": "s3_url of the file to be downloaded",
"validUpto": "2021-09-21T09:12:12+05:30"
}

Get e-Aadhaar XML

https://dg-sandbox.(website name).co/api/digilocker/{requestId}/aadhaar


Request

Path parameters

requestId

string

Required


Header parameters

x-client-id

string

Required

x-client-secret

string

Required

x-product-instance-id

string

Required


Response

Body

aadhaar

object

Required

id

string

Required

status

string

Required

Language

curl

Node

Python

Go

Request sample


curl --request GET \
--url https://dg-sandbox.(website name).co/api/digilocker/{requestId}/aadhaar \
--header 'x-client-id: test-client' \
--header 'x-client-secret: 891707ee-d6cd-4744-a28d-058829e30f12' \
--header 'x-product-instance-id: 891707ee-d6cd-4744-a28d-058829e30f10'
200 OK

Response sample


{
"aadhaar": {
"address": {
"careOf": "S/O John Doe",
"country": "India",
"district": "district",
"house": "house address",
"landmark": "",
"locality": "locality",
"pin": "123456",
"postOffice": "",
"state": "state",
"street": "",
"subDistrict": "",
"vtc": "vtc"
},
"dateOfBirth": "01-01-1990",
"email": "",
"gender": "M",
"generatedAt": "2021-10-26T17:17:36.342+05:30",
"maskedNumber": "xxxx-xxxx-1234",
"name": "Jack Doe",
"phone": "",
"photo": "",
"verified": {
"email": false,
"phone": false,
"signature": true
},
"xml": {
"fileUrl": "https://s3linkgoeshere.com",
"shareCode": "",
"validUntil": "2021-10-09T06:04:16+05:30"
}
},
"id": "391a45be-d08d-4dd0-b8a8-06e53392d435",
"status": "complete"
}

Get List of all docs available

https://dg-sandbox.(website name).co/api/digilocker/documents


Request

Header parameters

x-client-id

string

Required

x-client-secret

string

Required

x-product-instance-id

string

Required


Response

Body

documents

array

Required

Language

curl

Node

Python

Go

Request sample


curl --request GET \
--url https://dg-sandbox.(website name).co/api/digilocker/documents \
--header 'x-client-id: test-client' \
--header 'x-client-secret: 891707ee-d6cd-4744-a28d-058829e30f12' \
--header 'x-product-instance-id: 891707ee-d6cd-4744-a28d-058829e30f10'
200 OK

Response sample


{
"documents": [
{
"availableFormats": [
"pdf"
],
"description": "Pension Certificate",
"docType": "PECER",
"orgId": "002317",
"orgName": "Accountants General, Tripura",
"parameters": [
{
"description": "Account No./PPO No.",
"name": "AC_NO"
}
]
},
{
"availableFormats": [
"pdf"
],
"description": "Provident Fund Member Passbook",
"docType": "PRFND",
"orgId": "002317",
"orgName": "Accountants General, Tripura",
"parameters": [
{
"description": "Account No./PPO No.",
"name": "AC_NO"
}
]
}
]
}

Revoke access token

https://dg-sandbox.(website name).co/api/digilocker/{requestId}/revoke


Request

Path parameters

requestId

string

Required


Header parameters

x-client-id

string

Required

x-client-secret

string

Required

x-product-instance-id

string

Required


Response

Body

success

boolean

Required

Language

curl

Node

Python

Go

Request sample


curl --request GET \
--url https://dg-sandbox.(website name).co/api/digilocker/{requestId}/revoke \
--header 'x-client-id: test-client' \
--header 'x-client-secret: 891707ee-d6cd-4744-a28d-058829e30f12' \
--header 'x-product-instance-id: 891707ee-d6cd-4744-a28d-058829e30f10'
200 OK

Response sample


{
"success": true
}

Get status API

https://dg-sandbox.(website name).co/api/digilocker/{requestId}/status


Request

Path parameters

requestId

string

Required


Header parameters

x-client-id

string

Required

x-client-secret

string

Required

x-product-instance-id

string

Required


Response

Body

id

string

Required

url

string

Required

validUpto

string

Required

status

string

Required

Language

curl

Node

Python

Go

Request sample


curl --request GET \
--url https://dg-sandbox.(website name).co/api/digilocker/{requestId}/status \
--header 'x-client-id: test-client' \
--header 'x-client-secret: 891707ee-d6cd-4744-a28d-058829e30f12' \
--header 'x-product-instance-id: 891707ee-d6cd-4744-a28d-058829e30f10'
200 OK

Response sample


{
"id": "477dc21a-fa28-4c7f-9291-f35d63d5bda7",
"status": "authenticated",
"url": "User login url",
"validUpto": "2021-10-06T08:43:18+05:30"
}

#Error codes and messages for Digilocker APIs

Below is a table which contains the error codes and corresponding error messages, for errors that may occur during the Digilocker flow.

Error code Error message
invalid_redirect_url Please enter a valid redirect URL.
request_not_found The request id is invalid/expired.
user_not_authenticated User is not authenticated to access this resource
token_revoked The user has revoked the token for the given request.
aadhaar_not_linked The user has not linked his Aadhaar card with Digilocker account.
invalid_token The access token for the user has expired.
invalid_grant Access has not been granted to this document.
bad_request Malformed request. Verify if the docType and search parameters are correct.
get_xml_failed Failed to get user's Aadhaar XML.
unwrap_aadhaar_failed Failed to unwrap user's Aadhaar data.
user_consent_not_given User has not given consent for this document.
upstream_server_error Document Repository Service Error
Partner Service Error
Aadhaar Information not available
Upstream service failure
internal_server_error Internal server error

Was this page helpful?