ABHA SDK - Scan & Share Implementation
This guide provides everything you need to integrate the ABHA SDK into your application for ABHA Scan & Share Book Appointment Flow.- ABHA Scan & Share: Get your Appointments Booked through ABHA.
Implementation Example
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 | {oid?: string;hipId?: string;counter_id?: string;identifier: string;identifier_type: string;flow: string; } | ✅ | Configuration data for initializing the ABHA flow. - oid: Pass the OID of the patient if available. - hipId: Pass the HFR ID you have. - counter_id: Pass the HIP code of the facility you have. - identifier: Pass the identifier value i.e. phr address of the patient. - identifier_type: Pass the type of identifier which you passed in identifier key i.e. “phr_address”. - flow: Pass the type of flow for which you want to use SDK for i.e. scan-share for Scan & Share Flow. |
onAppointmentBookedSuccess | (params: TOnAbhaSnSAppointmentSuccessParams) => void | ✅ | Triggered when the Appointment is booked and token gets generated successfully. |
onError | (params: TOnAbhaFailureParams) => void | ✅ | Triggered when an error occurs during the ABHA flow. |
onAbhaClose | () => void | ✅ | Triggered when SDK closes. |
Callback Parameters
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 |
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. |
onAbhaClose Callback
The onAbhaClose callback is triggered when the ABHA SDK flow gets closed. Callback Signature: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, onAppointmentBookedSuccess, 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.

