` on every other gateway call. Renew before `expiresIn` runs out rather than on a fixed timer.
### How you know it worked
The response carries `accessToken` and `expiresIn`, and the next gateway call with that token is not refused as unauthorised.
### When it goes wrong
Every call returns 401: see [everything returns 401](/docs/hiecm/v3/troubleshooting/everything-returns-401). A profile call is refused while the session token is fresh: the `X-token` is missing, or it holds the short lived token from login verify, which the verify user call exchanges for the user token. `ABDM-1094` reads X-token expired, and the token sent is often the wrong kind rather than an old one.
## Encrypting sensitive inputs, Aadhaar, mobile, OTP and passwords
### In plain words
Six kinds of value never travel raw in an M1 request body.
| Value | Where it appears |
| --- | --- |
| Aadhaar number | Enrolment and login by Aadhaar |
| ABHA number | Login and search by ABHA number |
| Mobile number | Login, search and mobile update |
| Email address | Email verification |
| One time password ([OTP](/docs/hiecm/v3/getting-started/glossary#otp)) value | Every call that verifies a challenge |
| Password | Password based login |
Each is encrypted with RSA using the ABDM public certificate, and the base64 of the ciphertext goes in the field.
The padding belongs to the certificate. M1 and PHR calls use RSA OAEP with SHA-1 for both the digest and the mask generation function, which the certificate names as `RSA/ECB/OAEPWithSHA-1AndMGF1Padding`. The [M4](/docs/hiecm/v3/milestones/m4) registries use `RSA/ECB/PKCS1Padding` under a certificate of their own. An integration that calls both holds both keys and never crosses them.
### What happens
Encrypt each value in the table in your own process and send the standard base64 of the ciphertext. In most libraries OAEP defaults to SHA-256, so pass SHA-1 explicitly: in Node, the OAEP padding constant with the OAEP hash set to sha1; in Java, the transformation the certificate names. The certificate arrives as base64 DER with no PEM armour, so add the armour before your library loads it. Cache the certificate with a validity window, not forever.
### How you know it worked
A value your code encrypted is accepted by a real M1 call: the OTP request returns a `txnId` instead of a validation refusal.
### When it goes wrong
A wrong padding or digest does not fail when you encrypt. It fails at the API as a validation refusal that names the business field, which reads as a wrong Aadhaar or mobile number. Check the padding, the digest and the key before you doubt the plaintext. A stale cached certificate fails every encrypted call at once.
## The terms and conditions a person agrees to before an ABHA is created
### In plain words
Before your system sends a person's Aadhaar number, show them the terms and
conditions below and collect their agreement, through an "I agree" checkbox or
another form of signature. Keep a record that they agreed. Every journey that
creates an ABHA from Aadhaar starts here, and functional testing checks it in
[CRT_ABHA_102](/docs/hiecm/v3/resources/test-cases/m1#crt_abha_102).
Show the text exactly as written:
**Terms and Conditions**
I, hereby declare that I am voluntarily sharing my Aadhaar number and demographic information issued by UIDAI, with National Health Authority (NHA) for the sole purpose of creation of ABHA number. I understand that my ABHA number can be used and shared for purposes as may be notified by ABDM from time to time including provision of healthcare services. Further, I am aware that my personal identifiable information (Name, Address, Age, Date of Birth, Gender and Photograph) may be made available to the entities working in the National Digital Health Ecosystem (NDHE) which inter alia includes stakeholders and entities such as healthcare professionals (e.g. doctors), facilities (e.g. hospitals, laboratories) and data fiduciaries (e.g. health programmes), which are registered with or linked to the Ayushman Bharat Digital Mission (ABDM), and various processes there under. I authorize NHA to use my Aadhaar number for performing Aadhaar based authentication with UIDAI as per the provisions of the Aadhaar (Targeted Delivery of Financial and other Subsidies, Benefits and Services) Act, 2016 for the aforesaid purpose. I understand that UIDAI will share my e-KYC details, or response of “Yes” with NHA upon successful authentication. I have been duly informed about the option of using other IDs apart from Aadhaar; however, I consciously choose to use Aadhaar number for the purpose of availing benefits across the NDHE. I am aware that my personal identifiable information excluding Aadhaar number / VID number can be used and shared for purposes as mentioned above. I reserve the right to revoke the given consent at any point of time as per provisions of Aadhaar Act and Regulations.
The `consent` block in the `enrol/byAadhaar` request records the agreement:
`code` is `abha-enrollment` and `version` is `1.4`. Offering the text in other
languages is optional.
### What happens
Display the text verbatim, require an explicit "I agree" before the OTP request is sent, and store who agreed and when. Send the `consent` block with `code` `abha-enrollment` and `version` `1.4` in `enrol/byAadhaar`.
### How you know it worked
The OTP request cannot be sent until the person has agreed, and your records show the agreement for every ABHA your system created.
### When it goes wrong
A creation flow that sends the Aadhaar number before consent is collected fails functional testing at CRT_ABHA_102, whatever the API returns.
## A suggested ABHA journey, and what holds if you design your own
### In plain words
A front desk adopts ABHA because the receptionist stops typing. A verified ABHA
profile already carries the name, date of birth, gender, mobile, address and
photograph. So the ABHA step comes before your registration form, and fills it.
The suggested journey, in five steps:
1. **Start registering the patient** in your own system, under your own number.
2. **Ask whether they have an ABHA.** No means the form is typed by hand, and
the patient is treated exactly the same.
3. **Take one identifier.** Aadhaar is the one to recommend, because it is the
only route that ends in a KYC verified ABHA number. Mobile sits beside it.
Under Aadhaar only, ask how they prove it: an OTP, a face scan, or a
fingerprint or iris reader.
4. **Log in or create, decided by the answer.** Every identifier starts on the
login path. One account signs the person in. Several need a chooser. None
offers creation.
5. **Fill your form from what came back,** and let the receptionist confirm it
rather than type it.
Whatever journey you build, these hold:
- **Look before you create.** Creating an ABHA for a person who already holds
one leaves them with two ABHA numbers, and nothing in M1 merges them.
- **The login token is not the profile token.** Login verify returns a short
lived token, which the verify user call exchanges for the `X-token` that
profile calls accept.
- **An ABHA is optional to your record.** ABDM does not require a person to
hold an ABHA to be treated. A journey that cannot finish without one blocks
care.
- **The profile is what ABDM holds**, not what is in front of your clinician.
Present the filled form for confirmation rather than saving it unseen.
### What happens
Send every identifier, Aadhaar included, to the login OTP request first, never straight to enrolment. Read `accounts` on the verify response: one account, call verify user with its `ABHANumber` and the same `txnId`; several, show a chooser and do the same with the chosen one; none, offer creation. Then read the profile at `/abha/api/v3/profile/account` with the `X-token` and fill the form.
### How you know it worked
A person with an ABHA registers with their details arriving from the profile and the receptionist correcting at most one field. A person who declines is still registered, with no error, and can be offered ABHA again from their chart. A person who already holds an ABHA, run through the path a new patient takes, ends signed in to the account they had.
### When it goes wrong
Two ABHA numbers for one person: the journey branched into creation without reading `accounts`. The desk types everything and then links an ABHA: the order is wrong, fetch the profile first. A refused encrypted field shown to the person as a wrong number: check the padding before you blame the number, see [encryption](/docs/hiecm/v3/concepts/encryption).
## The counter QR code for scan and register
### In plain words
The QR code at each counter holds this URL. Your system can generate it and
print one per counter:
```text
https://phrsbx.abdm.gov.in/share-profile?hip-id=&counter-id=
```
| Parameter | What it holds |
| --- | --- |
| `hip-id` | Your facility's HIP id, the facility ID it holds in the [HFR](/docs/hiecm/v3/getting-started/glossary#hfr). The share arrives with the same value in `X-HIP-ID` and `metaData.hipId`. |
| `counter-id` | The counter, such as `OPD1`: 1 to 20 alphanumeric characters that you choose. It arrives as `metaData.context`. Never use the facility ID, the HIP id or the HIP name. |
`phrsbx.abdm.gov.in` is the sandbox host. Use one code per counter, so the
token you hand back belongs to that counter's queue.
### What happens
Build the URL from the facility ID and a counter id of your own, render it as a QR code, and print or display it at the counter. Keep the counter id stable: a reprinted code with a new counter id starts a new queue. `phrsbx.abdm.gov.in` is the sandbox host; confirm the production host at onboarding.
### How you know it worked
A PHR app scans the code, the patient agrees to share, and a POST arrives on your bridge at `/api/v3/hip/patient/share` whose `metaData.context` is the counter id in the code.
### When it goes wrong
The app scans the code but nothing arrives: the bridge URL for that facility points somewhere else. See [the callback never arrives](/docs/hiecm/v3/troubleshooting/callback-never-arrives).
## Where these came from
- `hiecm.concept.m1-operations-not-a-journey`
- `hiecm.concept.m1-counter-journey-order`
- `hiecm.concept.m1-two-routes-to-the-profile`
- `hiecm.concept.m1-journey-completes-without-abha`
- `hiecm.concept.m1-never-ask-twice`
- `hiecm.concept.m1-deployment-interview`
- `hiecm.concept.m1-identifier-and-auth-method`
- `hiecm.concept.m1-screen-contract`
- `hiecm.concept.m1-confirm-the-filled-form`
- `hiecm.concept.m1-avoiding-duplicate-abha`
- `hiecm.concept.m1-honest-screen-states`
- `hiecm.concept.m1-the-whole-surface`
- `hiecm.concept.abha-address-policy`
- `hiecm.concept.abha-number-and-address`
- `hiecm.concept.encrypted-identifiers`
- `hiecm.concept.gateway-session`
- `hiecm.concept.input-encryption`
- `hiecm.concept.m1-abha-consent`
- `hiecm.concept.m1-journey-design`
- `hiecm.concept.scan-and-register-qr`