ABHA SDK - Implementation
This guide provides everything you need to integrate the ABHA SDK into your application.Overview
The ABHA SDK allows you to integrate flows—such as Create ABHA, Login, Profile KYC, Consent Management, and Scan & Share—into your healthcare application, while offering customizable theme options. It provides:- Create ABHA: Create a new ABHA using Mobile or Aadhaar.
- Login with ABHA: Login to your exisiting ABHA using PHR Address, ABHA number, Aadhaar number or Mobile number.
- ABHA Consent Management: Manage Consent requests raised by healthcare providers to share medical records securely.
- ABHA Profile KYC: Get your ABHA address KYC verified.
- ABHA Scan & Share: Get your Appointments Booked through ABHA.
- Customizing the Theme: Customize the ABHA SDK colors to match your application’s branding.
Installation
Prerequisites
- A modern web browser.
- Your domain must be whitelisted with Eka Care to avoid CORS(Cross-Origin Resource Sharing) error. (Contact Eka Care to request API access and domain whitelisting.)
- A valid HTML container element where the SDK will mount.
Setup
Add the following HTML and script tags to your webpage:Core Functions
1. initAbhaApp
Initializes and renders the ABHA SDK in your specified container. Parameters:| Name | Type | Required | Description |
|---|---|---|---|
containerId | string | ✅ | The HTML element ID where the SDK will mount. |
clientId | string | ✅ | Provide clientId as ext. |
data | {accessToken: string;hipId: string;oid?: string;identifier?: string;identifier_type?: string;counter_id?: string;consent_id?: string;flow?: string;orgIconUrl?: string;linkToOrgIcon?: string;skipABHAEnable?: boolean;} | ⚙️ Optional | Configuration data for initializing the ABHA flow. - accessToken: Pass the access token you have generated from Connect Login API without the word Bearer. - hipId: Pass the HFR ID you have. - oid: Pass oid of patient if available / needed in the flow. - identifier: Pass the login identifier value i.e. mobile number / aadhaar number / phr address / abha number. - identifier_type: Pass the type of identifier which you passed in identifier key i.e. “mobile” / “aadhaar_number” / “phr_address” / “abha_number” /. If not known pass undefined.- counter_id: Pass the HIP code of the facility you have. - consent_id: Pass the consent_id of the consent request raised. - flow: Pass the type of flow for which you want to use SDK for i.e. abha-kyc for KYC flow / consent for Consent flow. - orgIconUrl: Public CDN URL of the logo of your organisation url should start with https://. Example - linkToOrgIcon: Public CDN URL of the icon representing “Link ABHA to your organisation” url should start with https://. Example - skipABHAEnable: Pass the boolean as true if you want Skip ABHA button to be enabled on login screen. keys with ? are optional and needs to be passed as per flow requirement. |
theme | object | ⚙️ Optional | Color token overrides to match your organisation’s design system. All keys are optional — only supply the tokens you want to change. Refer here |
onSuccess | (params: TOnAbhaSuccessParams) => void | ✅ | Triggered when the user successfully creates or logs in to ABHA. |
onKYCSuccess | (params: TOnAbhaKycSuccessParams) => void | ⚙️ Optional | Triggered when the user KYC verified successfully. |
onConsentSuccess | (params: TOnAbhaConsentSuccessParams) => void | ⚙️ Optional | Triggered when the consent flow completes successfully. |
onAppointmentBookedSuccess | (params: TOnAbhaSnSAppointmentSuccessParams) => void | ✅ | Triggered when the Appointment is booked and token gets generated successfully. |
onSkipAbha | (params: TOnSkipABHA) => void | ⚙️ Optional | Triggered if the ABHA flow is skipped. |
onAbhaClose | () => void | ✅ | Triggered when SDK closes. |
onError | (params: TOnAbhaFailureParams) => void | ✅ | Triggered when an error occurs during the ABHA flow. |
Callback Parameters
onSuccess Callback
The onSuccess callback is triggered when the ABHA flow completes successfully. It returns verified user details and tokens, which can be used to log in or continue the user’s session. Callback Signature:| Key | Type | Description |
|---|---|---|
response | TAuthVerifyV2Response | The complete ABHA verification response, containing session tokens, user profile, and transaction details. |
onKYCSuccess Callback
The onKYCSuccess callback is triggered when the ABHA KYC flow completes successfully. It returns a confirmation message indicating that the KYC has been verified. Callback Signature:| Type | Description | |
|---|---|---|
TOnAbhaKycSuccess | string | A confirmation message from SDK post KYC verification |
onConsentSuccess Callback
The onConsentSuccess callback is triggered when the ABHA Consent flow completes successfully. It returns a confirmation message indicating that the Consent flow ended successfully. Callback Signature:| Type | Description | |
|---|---|---|
TOnAbhaConsentSuccessParams | string | A confirmation message from SDK post Consent flow completion |
onAppointmentBookedSuccess Callback
The onAppointmentBookedSuccess callback is triggered when the appointment is booked and token gets generated successfully. It returns a confirmation message indicating that the Appointment is booked. Callback Signature:| Type | Description | |
|---|---|---|
onAppointmentBookedSuccess | string | A confirmation message from SDK post Appointment Token generation |
onSkipAbha Callback
The onSkipAbha callback is triggered when the ABHA SDK flow is skipped. The callback is functional when skipABHAEnable is set to true in the data parameter while initializing the SDK. Callback Signature:| Key | Type | Description |
|---|---|---|
identifier | string? | It will be login identifier value filled by user. |
identifier_type | IdentifierType[]? | It will be type of login identifier. |
onAbhaClose Callback
The onAbhaClose callback is triggered when the ABHA SDK flow gets closed. Callback Signature:onError Callback
The onError callback is triggered whenever an ABHA flow fails or is interrupted. It provides details about the failure through structured parameters, allowing you to handle or forward the error appropriately (for example, to native apps or monitoring tools). Callback Signature:| Key | Type | Description |
|---|---|---|
error | string? | Short description of the failure or error message. |
response | TAuthVerifyV2Response? | Partial or full API response object returned from ABHA services. |
- Always log the full error response (params) for debugging.
- Display friendly error messages for known error.code values.
- If params.response is present, inspect response.error.message for more detail.
- If integrating with native apps, forward the serialized error object:
Container Styling
Ensure your container has sufficient space:Troubleshooting
Common Issues
1. SDK Not Rendering
Problem: Nothing appears in the container. Solution:- Ensure containerId matches an existing HTML element.
- Verify the SDK JS and CSS are correctly loaded.
- Check browser console for errors.
2. APIs Not Being Called
Problem: API requests are not triggered after the SDK is mounted. Solution:- Ensure that the accessToken is passed correctly (do not include the Bearer prefix) and that the token has not expired.
- To prevent CORS-related issues, ensure that your domain is whitelisted.
3. Callback Not Triggered
Problem: onSuccess, onError, onKYCSuccess, onConsentSuccess, onAbhaClose isn’t firing. Solution:- Make sure callbacks are passed as valid functions.
- Avoid race conditions (e.g., calling before SDK fully loads).
4. Styling Issues
Problem: SDK content appears misaligned or clipped. Solution:- Give your container a fixed height (e.g., 600px).
- Ensure no parent element uses overflow: hidden.

