Skip to main content

M4 operations and fields

Every Milestone 4 call for the HPR and the HFR, with its parameters, its codes and the rules that apply to it. Two operations carry a published path and have their own pages under APIs. The rest are here.

Where do I get the paths this page does not give?

Method and path are not yet published for most calls below. Take them from the sandbox documentation, and use this page for the fields, codes and rules.

Session token

The first call you make. Same session pattern as M1, issued by the HIE-CM gateway.

MethodPOST
URLhttps://dev.abdm.gov.in/api/hiecm/gateway/v3/sessions
URL, second hosthttps://live.abdm.gov.in/api/hiecm/gateway/v3/sessions

Both hosts are listed under Base URLs.

Headers:

HeaderValue
REQUEST-IDA fresh UUID for each call, for end to end tracing
TIMESTAMPThe time the request was made, ISO 8601
X-CM-IDsbx in sandbox, abdm in production

Request body:

{
"clientId": "<CLIENT_ID_FROM_SANDBOX_SIGNUP>",
"clientSecret": "<CLIENT_SECRET_FROM_SANDBOX_SIGNUP>",
"grantType": "client_credentials"
}

Response shape:

{
"accessToken": "<JWT>",
"expiresIn": 1200,
"refreshExpiresIn": 1800,
"refreshToken": "<JWT>",
"tokenType": "bearer"
}

Read expiresIn from your own response rather than hard coding a value.

Every later call carries this token. The Authorization header value is the word Bearer, one space, then the access token.

Encryption

Three fields below are sent encrypted: the mobile number in mobile match, the OTP in the HPR mobile login, and the email and password in create HPID. All use the same public certificate, so fetch it once.

MethodGET
Sandbox URLhttps://apihspsbx.abdm.gov.in/v4/int/api/v1/auth/cert
Production URLhttps://apinhpr.abdm.gov.in/v4/int/api/v1/auth/cert

The cipher is RSA/ECB/PKCS1Padding, under this certificate and no other. M1 uses RSA-OAEP with SHA-1 under the ABHA certificate, so an M1 encryption path reused here produces a value the NHPR cannot read.

Check the response format before you parse it. Where it arrives as bare base64 rather than beginning -----BEGIN PUBLIC KEY-----, add the PEM armour yourself, wrapping at 64 characters per line, as the ABHA certificate call requires.

HPID creation

Nine calls, in order. Method and path are not yet published for these.

StepCallWhat it doesDetail we have
1Generate Aadhaar linkReturns a txnId and a temporary URL for the professional to complete Aadhaar authentication on. The URL expires after 5 minutesBehaviour only
2Check Aadhaar authentication statusOptional polling. Takes the txnId. Returns a bare boolean, not an objectBehaviour only
3Verify OTP and fetch user detailsTakes the txnId. Returns demographic and address details from Aadhaar, with the mobile number maskedBehaviour only
4Check HPID exists by AadhaarReturns the HPID already registered for this Aadhaar, if there is oneBehaviour only
5Mobile matchChecks whether the mobile number is the one on the Aadhaar record. The mobile number is encrypted. The response field is demographicAuthViaMobileBehaviour only
6Generate mobile OTPOnly if demographicAuthViaMobile is false. Takes the mobile number and the txnIdBehaviour only
7Verify mobile OTPTakes the OTP and the txnIdBehaviour only
8Username suggestionsTakes the txnId. Returns suggested HPR usernamesBehaviour only
9Create HPIDTakes the professional's details. Email and password are encrypted with the public certificate. Returns the HPID and an hprTokenCode tables below

Codes for create HPID

Category:

CodeName
1Doctor
2Nurse
6Pharmacist

Subcategory, as used by create HPID:

CodeNameHPR type
1Modern Medicinedoctor
2Dentistdoctor
3Ayurvedadoctor
4Unanidoctor
5Siddhadoctor
6Homoeopathydoctor
89Sowa-Rigpadoctor
220Yoga and Naturopathydoctor
7Registered Auxiliary Nurse Midwife (RANM)nurse
8Registered Nurse (RN)nurse
9Registered Nurse and Registered Midwife (RN and RM)nurse
10Registered Lady Health Visitor (RLHV)nurse
33Pharmacistpharmacist

Role:

CodeName
1Healthcare Professional
2Facility Manager
3Healthcare Professional and Facility Manager
The subcategory codes differ between calls

Register professional and update professional use a second subcategory table, and its codes differ from the create HPID table above.

SubcategoryCode
Dentistry2
Homoeopathy3
Ayurveda4
Unani5
Siddha6
Sowa-Rigpa7
Nurse categories8 to 11
Pharmacist13
Yoga and Naturopathy14

Fetch the codes from the HPRID subcategories master API rather than hard coding either table. See HPR master data.

Getting an HPR token

The HPR token is not the gateway access token: it represents the professional, not your client. There are three ways to get one, and all three carry the gateway access token in the Authorization header as well.

Login by password

One call. The professional supplies their HPR ID and password.

MethodPOST
Path/v4/int/api/v1/auth/authPassword
{
"idType": "hpr_id",
"domainName": "@hpr.abdm",
"hprId": "<USERNAME_CHOSEN_AT_CREATE_HPID>@hpr.abdm",
"password": "<PASSWORD_THE_PROFESSIONAL_SET>"
}

The token in the response is the HPR token. The HPR Swagger page at https://apihspsbx.abdm.gov.in/v4/int/swagger-ui/index.html?urls.primaryName=HPR lets you try the call in a browser.

The sample expiresIn is 1739710198, which reads as a Unix timestamp rather than seconds. The other two login flows return 1800. The call has not been run, so which reading is right is unknown.

Login by mobile OTP

Four calls.

StepMethod and pathBody
1. Send OTPPOST /v4/int/api/v2/auth/loginViaMobileSendOTP{ "mobile": "9999999999" }
2. Get public certificateGET /v4/int/api/v1/auth/certNone
3. Verify OTPPath not confirmed, see below{ "txnId": "<TXN_ID_FROM_STEP_1>", "otp": "<OTP_ENCRYPTED_WITH_THE_PUBLIC_CERT>", "mobile": "<MOBILE_NUMBER>" }
4. Login with HPR IDPOST /v4/int/api/v2/auth/login/userAuthorizedToken{ "hpId": "<HPR_ID_FROM_STEP_3>", "txnId": "<TXN_ID_FROM_STEP_3>" }

The verify OTP path is not yet published: the published value repeats the send OTP path, loginViaMobileSendOTP. Take the verify endpoint from the HPR Swagger page.

Step 1 response:

{
"txnId": "061c660d-8752-4639-945d-e77a7ea6f564",
"mobileNumber": null
}

Step 3 response, listing the HPR IDs linked to that mobile number:

{
"txnId": "fc6d879c-e535-4ff1-9443-5dc6031efcc1",
"mobileLinkedHpIdDTO": [
{
"hprIdNumber": "**-****-0326-3829",
"name": "Test",
"hprId": "*****@hpr.abdm"
}
]
}

Step 4 response, which is the HPR token:

{
"token": "<HPR_TOKEN_JWT>",
"expiresIn": 1800,
"refreshToken": "<REFRESH_JWT>",
"refreshExpiresIn": 10800
}

Login by Aadhaar OTP

Two calls.

StepMethod and pathBody
1. Send OTPPOST /v4/int/api/v1/auth/init{ "idType": "hpr_id", "domainName": "@hpr.abdm", "authMethod": "AADHAAR_OTP", "hprId": "<HPR_ID>" }
2. Verify OTPPOST /v4/int/api/v1/auth/confirmWithAadhaarOtp{ "otp": "<OTP>", "txnId": "<TXN_ID_FROM_STEP_1>" }

Step 1 returns { "txnId": "..." }. Step 2 returns the same token object as step 4 of the mobile flow.

Register professional

The one HPR write call with a published path.

MethodPOST
Sandbox URLhttps://apihspsbx.abdm.gov.in/v4/int/apis/v1/doctors/register-professional-new

The hprToken from create HPID goes in the payload, not the header. The gateway access token goes in the Authorization header.

The payload is grouped into personal information, communication address, registration data, qualification data and current work details. Selected fields and their rules:

FieldMandatoryNotes
hprTokenYesFrom create HPID, or from a login call
healthProfessionalTypeYesdoctor, nurse or pharmacist. An empty or wrong value makes the whole request invalid
salutation, firstNameYesmiddleName and lastName are optional
nationalityYesID from the countries master
languagesSpokenYesComma separated master codes, for example 1,5
isCommunicationAddressAsPerKYCNo0 means the communication address fields below become mandatory. 1 means they do not
categoryYesCategory code, for example 1 for doctor
categoryIdYesSubcategory code, for example 1 for Modern Medicine
registeredWithCouncil, registrationNumberYesCouncil ID comes from the councils master
nameOfDegreeOrDiplomaObtainedYesID from the courses master
college, universityYesIDs from the master data. Send 0 for "Any Other"
yearOfAwardingDegreeDiplomaYesmonthOfAwardingDegreeDiploma is optional
currentlyWorkingYes0 or 1. If 0, reasonForNotWorking becomes mandatory
chooseWorkStatusYes0 private, 1 government, 2 both
ministryConditionalMandatory when chooseWorkStatus is 1 or 2. Values from the get all ministry master
isPermanentOrRenewableConditionalMandatory for a doctor. If Renewable, renewableDueDate is mandatory. Not required for a nurse

Three conditional rules apply separately:

  • When chooseWorkStatus is 1 or 2, category inside personalInformation must be C for central government or S for state. When it is 0, send an empty string. Mandatory either way.
  • When chooseWorkStatus is 1 or 2, facilityDeclarationData is mandatory.
  • Without facilityId, then facilityName, facilityAddress, facilityPincode, state, district and facilityType are mandatory. With it, facilityDepartment and facilityDesignation are mandatory.

Degree codes

CodeDegreeSystem of medicine
4060MBBSModern Medicine
4074BDSDentistry
4079BAMSAyurvedic
4082BUMSUnani
61BSMSSiddha
74BTMSSowa-Rigpa
40BHMSHomoeopathy
9568BPharmPharmacist

Attachments

Every attachment in the payload uses the same shape:

{
"fileType": "image/jpeg",
"data": "<BASE64_ENCODED_FILE>"
}

Accepted file types are JPEG, PNG and PDF, sent in fileType. Read the exact value back from your own response rather than hard coding one.

A note on nurses

The SMD ID identifies doctors only. Searching nurse colleges by SMD returns a null college or university name. That is expected, not a failure. For nurses, SMD is always null.

The other professional calls

CallPublished parametersPath
Retrieve professional document listhpridNot in text
Upload documentshpr_token, document_id, document_type, data (base64)Not in text
Update professionalThe same field table as register professional, with hprToken from a login callNot in text
Fetch professional detailsid (HPR ID, mandatory), name (minimum 3 letters), contactNumber, state, registrationNumber, stateCouncilNameNot in text
Search facility from HPRownershipCode, stateLGDCode, districtLGDCode, subdistrictLGDCode, pincode, facilityName, facilityId, page, resultsPerPageNot in text

Upload rules: profile photo 1 MB or smaller, other documents 5 MB or smaller, accepted types png, jpeg, jpg and PDF. The document types are profilePhoto, degreeCertificate, registrationCertificate, proofOfWorkCertificate, proofOfNameChangeRegCertificate and proofOfNameChangeQualCertificate. Which identifier you send as document_id depends on the type:

Document typeIdentifier to use
profilePhotoParent identifier
degreeCertificateQualification block identifier
registrationCertificateRegistration block identifier
proofOfWorkCertificateParent identifier
proofOfNameChangeRegCertificateRegistration block identifier
proofOfNameChangeQualCertificateQualification block identifier

HFR onboarding

Five calls, in order. Method and path are not yet published; the parameter tables are.

Run this before you create anything, so you do not create a second record for a facility that already exists.

ParamRequiredNotes
facilityIdNo6 digit numeric facility unique ID
nameYesAlphanumeric, one space between words
addressNoAlphanumeric plus -_.(),/
districtYesDistrict LGD code
subDistrictYesSub district LGD code
villageNoVillage LGD code
geolocationNoLatitude and longitude, 1 to 6 decimal places

LGD codes come from the Local Government Directory at lgdirectory.gov.in, and from the LGD lookup calls below.

2. Basic facility information

Creates the record and returns a tracking ID that acts as the facility ID for every later call. Needs an HPR token in the header, generated from an HPR ID and password.

Mandatory fields:

ParamNotes
facilityNameFirst character must be a letter or a digit
ownershipCodeG government, P private, PP public private
ownershipSubTypeCodeC or S when ownership is G. P or NP when ownership is P or PP
ownershipSubTypeCode2From the ownership subtype call
workingInPsu, facPsuNameOnly when ownership is G and subtype is C
systemOfMedicineCodeFrom master data with type=MEDICINE. Comma separate for several
facilityTypeCode, facilitySubTypeFrom the facility type and facility subtype calls
specialityTypeCodeFrom master data with type=SPECIALITY-TYPE
facilityOperationalStatusFrom master data with type=FACSTATUS
typeOfServiceCodeFrom master data with type=TYPESERVICE. Not required for diagnostic laboratory, imaging centre, cath laboratory, dialysis centre, blood bank or pharmacy
facilityAddressDetailsCountry, state, district and sub district LGD codes, address line 1, pincode, latitude and longitude
facilityUploadsfacilityBoardPhoto and facilityBuildingPhoto, each as a name and a base64 value, maximum 5 MB, extension in the name matching the file
timingsOfFacilityworkingDays and openingHours, mandatory when the facility is functional. Hours accept 10:00 AM-2:00 PM or 24*7

Optional fields include facilityRegion (R rural or U urban), the contact block, the address proof block and abdmCompliantSoftware.

3. Additional information

The tracking ID plus yes or no flags, each answered with a code from master data type=GENERAL-INFO-OPTIONS: hasDialysisCenter, hasPharmacy, hasBloodBank, hasCathLab, hasDiagnosticLab, hasImagingCenter. With an imaging centre, servicesByImagingCenter carries a service code and equipment count per service.

It also carries the facility's existing scheme identifiers, all optional: nhrrId, nin, abpmjayId, rohiniId, echsId, cghsId, ceaRegistration and stateInsuranceSchemeId.

4. Detailed information

The tracking ID plus the sections that apply, which depends on the facility type, the type of service and the system of medicine. The rules:

  • Specialities are required for most facility types, but not for blood bank, cath laboratory, diagnostic laboratory, dialysis centre, imaging centre or pharmacy.
  • Medical infrastructure is mandatory for IPD and day care. For IPD at least one bed count must be greater than zero; for day care at least one day care bed count must be.
  • For OPD where the system of medicine is dentistry, countDentalChairs is mandatory.
  • For imaging centre, diagnostic laboratory, blood bank and pharmacy, medical infrastructure is not required.
  • totalNumberOfBeds must be equal to or greater than the sum of the individual bed counts.
  • The pharmacy, blood bank, diagnostic and imaging sections are each required when the facility is of that type or offers that service.

5. Submit facility

ParamRequiredNotes
trackingIdYesFrom the basic information call
sourceOfInformationNoLeave empty and the facility is treated as a submitted entity
sourceUniqueIDNoThe facility's ID in your own source system

Needs an x-hpird-auth token in the header. Until you make this call the facility stays in draft.

Bridge linkage

Links one facility to one or more bridges. Path not in text.

ParamRequiredNotes
facilityIdYesStarts with IN, 12 characters in total
facilityNameYesAlphanumeric plus -_.(),/
bridgeIdYesAlphanumeric
hipNameYesThe name a patient sees in their ABHA or PHR app. 15 characters or fewer, no special characters, unique for every bridge on a facility
typeYesHIP or HIU
activeYestrue or false

HFR search and master data

Paths are not yet published. Two appear inside other parameter descriptions: v1.5/facility/fetchfacilitytype and /v1.5/facility/get-specialities.

CallParametersNotes
Master typesNoneA GET. Returns the list of master data set types
Master datatypeThe type comes from master types
LGD statesNoneA GET. Returns states with their districts nested
LGD districtsstateCode
LGD sub districtsdistrictCode
Facility typeownershipCode, systemOfMedicineCodeOwnership accepts G or P here
Facility subtypefacilityTypeCode
Ownership subtypeownershipCode, ownerSubtypeCode
Get specialitiessystemOfMedicineCodeOne system of medicine per call
PSU details by ministryMinistry code from ownership subtype
Search facilityEither facilityId, or ownershipCode with stateLGDCode and facilityName. Plus page (minimum 1) and resultsPerPage (minimum 10)Fuzzy match on name, exact match on everything else
Nearby searchcenterLat, centerLon, radiusInKm, from, size are mandatory. abdmSoftware, facilityOwnership, hospitalSpecialityType, speciality and facilityName are optional filtersResults are ordered by distance, nearest first
Send OTP to contactfacilityIdReturns a transaction ID and sends an OTP to the facility's registered mobile
Validate OTPfacilityId, sourceId, otp, source, transactionIdsource accepts Government programs

HPR master data

There are 17 master data calls, in four groups:

  • Qualifications: system of medicine, medical councils, languages, universities, courses, colleges
  • Geography: countries, states, districts, sub districts
  • Nursing bodies: nurse affiliated boards, nurse councils, nurse college by state, affiliated board by state councils
  • Classification: get all ministry, HPRID categories, HPRID subcategories

The only master data paths the document carries in text:

CallMethod and path
CountriesGET /v4/int/apis/v1/masters/countries/{country_id}
StatesGET /v4/int/apis/v1/masters/states/{state_id}
DistrictsGET /v4/int/apis/v1/masters/district/{state_id}
Sub districtsGET /v4/int/apis/v1/masters/sub-districts/{district_id}
LanguagesGET /v4/int/apis/v1/masters/languages/{language_id}
CoursesGET /v4/int/apis/v1/masters/courses
Nurse affiliated boardsGET /v4/int/apis/v1/masters/affiliated-board

Three appear as complete URLs: countries, states and nurse affiliated boards. The other four appear only as path fragments inside field descriptions, so the /v4/int/ prefix on those is our reading of the base URL, not a quote.

Path variables are optional. Drop one and you get the full list. Countries returns:

{
"id": 356,
"alpha_2_code": "IN",
"alpha_3_code": "IND",
"enShortName": "India",
"nationality": "Indian"
}

Two calls take parameters:

CallParameters
HPRID categoriesrole: 1 healthcare professional, 2 facility manager, 3 both
HPRID subcategoriesrole as above, plus categoryCode from the categories call

A published system of medicine table carries a twelfth row, 12 Registered Pharmacist, filed under nurse. Fetch the list from the master API rather than copying either table.

Error codes

There are 150 error codes, all prefixed HIS-, in six groups.

RangeWhat it coversExamples
HIS-400 to HIS-504The HTTP level failuresHIS-401 user is not authorized, HIS-403 forbidden, HIS-503 requested service is unavailable
HIS-1xxxValidation and facility errors, 103 of themHIS-1002 the field value should not be empty, HIS-1124 bridge not linked, HIS-1128 HIP name already exists, HIS-1132 duplicate facility detected
HIS-2xxxAadhaar, OTP and session errorsHIS-2022 invalid OTP, HIS-2031 request expired, HIS-2045 session expired
HIS-3xxxAadhaar data and HPID stateHIS-3001 resident data not available, HIS-3021 HPRID already exists, HIS-3031 invalid token
HIS-4xxxFacility record errorsHIS-4003 facility already exists, HIS-4032 invalid state code, HIS-4055 invalid image format
HIS-5xxxRegistration workflow errorsHIS-5005 already registered, HIS-5011 token expired

The full list is in the sandbox documentation for the healthcare professional registry.

Where to go next