Authentication
The v3 gateway sessions API — client-credential tokens and the headers that authenticate every ABDM call.
All ABDM services use client-credential sessions: exchange your
clientId + clientSecret for a short-lived JWT bearer token, then send it
as Authorization: Bearer <token> on every call.
Use v3 — v1/v2 are deprecated
The older /gateway/v0.5/sessions and v1/v2 gateway APIs are deprecated.
NHA required existing Milestone 1 integrators to migrate to the v3 API
family by 31 January 2025. New integrations should use v3 only.
Getting a session token
https://dev.abdm.gov.in/api/hiecm/gateway/v3/sessionsExchange client credentials for an access token (HIECM gateway v3).
curl -X POST "https://dev.abdm.gov.in/api/hiecm/gateway/v3/sessions" \
-H "Content-Type: application/json" \
-H "REQUEST-ID: $(uuidgen | tr 'A-Z' 'a-z')" \
-H "TIMESTAMP: $(date -u +%Y-%m-%dT%H:%M:%S.000Z)" \
-H "X-CM-ID: sbx" \
-d '{
"clientId": "YOUR_CLIENT_ID",
"clientSecret": "YOUR_CLIENT_SECRET",
"grantType": "client_credentials"
}'curl -X POST "https://dev.abdm.gov.in/api/hiecm/gateway/v3/sessions" \
-H "Content-Type: application/json" \
-H "REQUEST-ID: $(uuidgen | tr 'A-Z' 'a-z')" \
-H "TIMESTAMP: $(date -u +%Y-%m-%dT%H:%M:%S.000Z)" \
-H "X-CM-ID: sbx" \
-d '{
"clientId": "YOUR_CLIENT_ID",
"clientSecret": "YOUR_CLIENT_SECRET",
"grantType": "client_credentials"
}'{
"accessToken": "eyJhbGciOiJSUzI1NiIs...",
"expiresIn": 1200,
"refreshExpiresIn": 1800,
"refreshToken": "eyJhbGciOiJIUzUxMiIs...",
"tokenType": "bearer"
}Invalid credentials return 400 with an ABDM error envelope:
{
"error": {
"code": "ABDM-9999",
"message": "Invalid user credentials"
}
}Required headers
| Header | Value | Notes |
|---|---|---|
REQUEST-ID | UUID v4 | Unique per request — regenerate every call |
TIMESTAMP | ISO-8601 UTC, e.g. 2024-07-09T11:25:00.000Z | Must be current; stale timestamps are rejected |
X-CM-ID | sbx (sandbox) / abdm (production) | Consent manager ID suffix |
Content-Type | application/json |
Request body
| Field | Value |
|---|---|
clientId | Client ID issued after sandbox approval |
clientSecret | Client secret issued with it |
grantType | client_credentials |
Using the token
Authorization: Bearer <accessToken>
REQUEST-ID: 4c3197c0-1e3a-4a92-a319-a25d17e6f0c2
TIMESTAMP: 2024-07-09T11:25:00.000Z
X-CM-ID: sbx| Header | When | Notes |
|---|---|---|
Authorization | Always | Bearer <accessToken> from the session call |
REQUEST-ID, TIMESTAMP | All v3 APIs | Fresh UUID + current ISO-8601 timestamp per request |
X-CM-ID | Consent/data APIs | sbx in sandbox, abdm in production |
X-HIP-ID / X-HIU-ID | Bridge-scoped requests & callbacks | Which facility/bridge role the message targets (HFR ID doubles as HIP ID) |
Token management
- Cache and reuse tokens until near expiry (
expiresInis seconds); don't create a session per request. - Clock skew matters — v3 APIs reject stale
TIMESTAMPvalues; sync with NTP. - Callback authenticity — validate JWTs on inbound gateway callbacks against the gateway's published certificates instead of trusting the network.
HPR / HFR (NHPR) tokens
The Milestone 4 HealthCare Professional and
Facility Registry APIs run on a separate host
(https://apihspsbx.abdm.gov.in/v4/int in sandbox) and use the same
client-credential pattern, but note that several registration flows also
involve user-level tokens (e.g. an hprToken from Aadhaar/OTP
authentication) in addition to your gateway session. See the
M4 guide for the full sequence.
Aadhaar / OTP payload encryption
Separate from transport auth, sensitive values (Aadhaar number, OTPs, and some
mobile numbers) sent to ABHA and HPR APIs must be RSA-encrypted with the
service's public certificate before being placed in the request body — TLS
alone is not sufficient. Fetch the certificate once, encrypt with
RSA/ECB/OAEPWithSHA-1AndMGF1Padding, and Base64-encode the result.
→ Full walkthrough with Node.js / Python / Java examples: Data Encryption.
Secret hygiene
Client secrets grant your entire bridge identity. Store them in a secret manager, rotate on personnel changes, and never ship them to browsers or mobile apps — all ABDM calls belong on your backend.
Sources
- ABDM Sandbox V3 Documentation (sandbox.abdm.gov.in/sandbox/v3)
- Verified live against https://dev.abdm.gov.in/api/hiecm/gateway/v3/sessions