ABHA SDK - Consent Management Implementation
This guide provides everything you need to integrate the ABHA SDK into your application for ABHA Consent Management.- ABHA Consent Management: Manage Consent requests raised by healthcare providers to share medical records securely.
Implementation Example
Add the following HTML and script tags to your webpage:For staging/dev environments, replace the SDK URLs with:
- JS:
https://unpkg.com/@eka-care/abha-stg/dist/sdk/abha/js/abha.js - CSS:
https://unpkg.com/@eka-care/abha-stg/dist/sdk/abha/css/abha.css
Core Functions
1. initAbhaApp
Initializes and renders the ABHA SDK in your specified container. Parameters:
Example:
Callback Parameters
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:
Example:
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:
Example:
onAbhaClose Callback
The onAbhaClose callback is triggered when the ABHA SDK flow gets closed. Callback Signature:
Suggest Handling
- 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.

