Skip to content

REST API from any language

The DevKit’s REST API lets any program use it over HTTP. Start the practice ABDM with node apps/cli/dist/main.js mock; it prints an address and a token. Send the token with every request as Authorization: Bearer <token>.

Anything that sends a request to ABDM takes two calls, so a person always sees what is about to happen:

  1. Prepare. POST .../prepare checks the request and returns a plain-English summary and an approvalId. Show the summary to your user.
  2. Send. If they agree, POST the approvalId with the same request. If the request changed, the approval was already used, or it is over 10 minutes old, you get 409 and nothing is sent.

examples/python/consent_and_fetch.py does the whole flow with only Python’s standard library:

Terminal window
ABDM_DEVKIT_TOKEN=paste-your-token-here python3 examples/python/consent_and_fetch.py

The core of it:

pending = call("POST", "/consent-requests/prepare", consent_request)
print(pending["summary"]) # show this to your user
sent = call("POST", "/consent-requests", {"approvalId": pending["approvalId"], "request": consent_request})
consent = wait_for(f"/consent-requests/{sent['requestId']}", "state", "granted")

See the REST API reference for every endpoint and error.