> ## Documentation Index
> Fetch the complete documentation index at: https://developer.eka.care/llms.txt
> Use this file to discover all available pages before exploring further.

# Log in to HPR with a mobile OTP

> Verify a returning healthcare professional with an OTP to their mobile and check their HPR ID.

## When to use this

A healthcare professional who has registered before signs in to your HMS with their mobile rather than Aadhaar. You send an OTP to their mobile, verify it, and check the HPR ID. This is the alternative entry for returning professionals.

For a first-time registration, use [Create an HPR ID with Aadhaar OTP](https://developer.eka.care/docs/hie-cm/workflows/create-hpr-id.md).

## Before you start

* A bearer token for the Eka API. See [Authorization](https://developer.eka.care/api-sdk/auth/getting-started.md).
* The headers your integration sends on ABDM Connect calls. Each operation accepts `X-Pt-Id`, `X-Partner-Pt-Id` and `X-Hip-Id`.&#x20;
* The professional's mobile number.
* The professional's HPR ID, which Check If HPR is Available takes as `hprId`.&#x20;

## Sequence

```mermaid theme={null}
sequenceDiagram
  participant App as Your app
  participant Eka
  participant Phone as Professional's phone
  App->>Eka: POST /abdm/nhpr/v1/hpr/aadhaar/mobile/init
  Eka-->>Phone: OTP to the mobile
  App->>Eka: POST /abdm/nhpr/v1/hpr/aadhaar/mobile/verify
  App->>Eka: POST /abdm/nhpr/v1/hpr/aadhaar/check/available
```

## Steps

**1. Send the mobile OTP**

Send `mobile_num` to [Get Mobile OTP](https://developer.eka.care/api-sdk/hie-cm/nhpr-abdm/hpr/get-mobile-otp.md). The body also accepts `txn_id`.  The response carries `txn_id`, `mobile_num` and `hint`. Unlike the other NHPR calls, the spec does not wrap this response in `data`.&#x20;

Keep `txn_id`. The professional receives an OTP.

**2. Verify the mobile OTP**

Send `txnId` (the `txn_id` from step 1, in camel case) and the `otp` the professional reads out to [Verify Mobile OTP](https://developer.eka.care/api-sdk/hie-cm/nhpr-abdm/hpr/verify-mobile-otp.md). The response `data` carries `txn_id`, `mobile_num` and `hint`.

**3. Check the HPR ID**

Send `hprId` to [Check If HPR is Available](https://developer.eka.care/api-sdk/hie-cm/nhpr-abdm/hpr/check-hpr-available.md). Read `available` in the response `data`.&#x20;

## State you must persist

| Field | From | Keep | For |
| - | - | - | - |
| `txn_id` | Get Mobile OTP | Until Verify Mobile OTP returns | Sent as `txnId` to Verify Mobile OTP |
| `mobile_num` | The professional | On the staff record | Next login |
| `hprId` | The staff record, saved by [Create an HPR ID with Aadhaar OTP](https://developer.eka.care/docs/hie-cm/workflows/create-hpr-id.md) | Permanently, on the staff record | Check If HPR is Available |

## When it fails

> [!WARNING]
>
> Which of these codes each call returns is not yet confirmed. The codes come from the [errors page](https://developer.eka.care/docs/hie-cm/errors.md), matched by meaning. Log the code you actually receive.

Errors come back as `4XX` or `5XX` with a body carrying `code`, `error` and `source_error` (`code`, `message`). Read `source_error.code` and look it up on the [errors page](https://developer.eka.care/docs/hie-cm/errors.md).

| Situation | Code | Do |
| - | - | - |
| Malformed body, such as a missing `mobile_num` | `ABDM-1006` | Fix the request; do not retry unchanged |
| Mobile not registered with HPR | | Send the professional to [Create an HPR ID with Aadhaar OTP](https://developer.eka.care/docs/hie-cm/workflows/create-hpr-id.md) |
| Wrong OTP | `MIS-1013` | Let the professional enter it again |
| Too many OTP requests or attempts | `ABDM-1100` | Wait 30 minutes, then restart from Get Mobile OTP |
| Transaction expired or unknown | `ABDM-1017` or `MIS-1026` | Restart from Get Mobile OTP |
| ABDM registry unavailable | `ABDM-1019` or `ABDM-1024` | Retry later |

## Test it

The [testing page](https://developer.eka.care/docs/hie-cm/testing.md) has the sandbox base URL, credentials and the happy path for every journey.

Run against the sandbox base URL `https://api.dev.eka.care`.&#x20;

* [ ] Happy path: Get Mobile OTP, Verify Mobile OTP, Check If HPR is Available returns `available` for the professional's `hprId`
* [ ] Wrong OTP once, then the correct OTP
* [ ] A mobile with no HPR account


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.