National Health AuthorityNHA Docs

Command Palette

Search for a command to run...

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

POSThttps://dev.abdm.gov.in/api/hiecm/gateway/v3/sessions

Exchange client credentials for an access token (HIECM gateway v3).

cURL
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"
}'
Request
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"
  }'
Response (200)
{
  "accessToken": "eyJhbGciOiJSUzI1NiIs...",
  "expiresIn": 1200,
  "refreshExpiresIn": 1800,
  "refreshToken": "eyJhbGciOiJIUzUxMiIs...",
  "tokenType": "bearer"
}

Invalid credentials return 400 with an ABDM error envelope:

Response (400)
{
  "error": {
    "code": "ABDM-9999",
    "message": "Invalid user credentials"
  }
}

Required headers

HeaderValueNotes
REQUEST-IDUUID v4Unique per request — regenerate every call
TIMESTAMPISO-8601 UTC, e.g. 2024-07-09T11:25:00.000ZMust be current; stale timestamps are rejected
X-CM-IDsbx (sandbox) / abdm (production)Consent manager ID suffix
Content-Typeapplication/json

Request body

FieldValue
clientIdClient ID issued after sandbox approval
clientSecretClient secret issued with it
grantTypeclient_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
HeaderWhenNotes
AuthorizationAlwaysBearer <accessToken> from the session call
REQUEST-ID, TIMESTAMPAll v3 APIsFresh UUID + current ISO-8601 timestamp per request
X-CM-IDConsent/data APIssbx in sandbox, abdm in production
X-HIP-ID / X-HIU-IDBridge-scoped requests & callbacksWhich facility/bridge role the message targets (HFR ID doubles as HIP ID)

Token management

  • Cache and reuse tokens until near expiry (expiresIn is seconds); don't create a session per request.
  • Clock skew matters — v3 APIs reject stale TIMESTAMP values; 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