API's flow for create abha address and attach to abha number

Hi @IntegrationSupport @satyadeep ,

I have done the create abha number and the profile update functionality. now I am trying to create Abha address and attach it to the Abha number
here I am getting the doubt that what flow of the APIs I need to follow to create in v3 API i felt I need to use
/v3/enrollment/enrol/abha-address but what will be the previous API’s i need use to execute this. please help me to resolve this.

Thanks in advance.

@Vinay

  1. Generate session token by submitting a POST request of the following JSON format

{ "clientId" : "XXX", "clientSecret" :"YYY" }

to https://dev.abdm.gov.in/gateway/v0.5/sessions
2. Get public key of ABDM (to be used for encryption) by submitting a get request to https://healthidsbx.abdm.gov.in/api/v1/auth/cert with

`Content-Encoding: application/json

Authorization: Bearer token-received-in-step-1

Accept-Language: en-us`

  1. Encrypt Aadhaar using public key in RSA/ECB/OAEPWithSHA-1AndMGF1Padding mode.
  2. Create a JSON packet in following format:

{"txnId":"","scope":["abha-enrol"],"loginHint":"aadhaar","otpSystem":"aadhaar","loginId":"encrypted-aadhaar"}

  1. Submit the packet to https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/request/otp along with following headers :

Content-Encoding: application/json Authorization: Bearer token-received-in-step-1 Accept-Language: en-us REQUEST-ID: uuidv4 TIMESTAMP: 2023-12-05T17:17:32.246Z Content-Type: application/json

Response will be received in following format:

{ "txnId": "32187f01-075a-40bd-82ac-e1be02c159e4", "message": "OTP sent to Aadhaar registered mobile number ending with ******5156", "statusMessage": "OK" }

  1. Encrypt the OTP received in step 5 on Mobile using using public key

(received in step 2) in RSA/ECB/OAEPWithSHA-1AndMGF1Padding mode.

  1. create a JSON packet in following format:

{ "authData": { "authMethods": [ "otp" ], "otp": { "txnId": "txnId-received-in-step-5", "otpValue": "encrypted-otp-in-step-6", "timeStamp": "2023-12-05T18:12:38", "mobile": "mobile-number-of-the-patient" } }, "consent": { "code": "abha-enrollment", "version": "1.4" } }

  1. Submit the JSON packet created in step 7 to

https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/enrol/byAadhaar with following headers:

Content-Encoding: application/json Authorization: Bearer token-received-in-step-1 Accept-Language: en-us REQUEST-ID: 592031f9-59d8-46e3-9235-a3c818ecb22c TIMESTAMP: 2023-12-05T18:12:45.450Z TRANSACTION_ID: 142bc004-ac47-495f-9877-4e786b438a7d

  1. The response packet will be in the format below:

{ "message": "new account", "txnId": "142bc004-ac47-495f-9877-4e786b438a7d", "tokens": { "token": "token", "expiresIn": 1800, "refreshToken": "refresh-token", "refreshExpiresIn": 1296000 }, "ABHAProfile": { "firstName": "Satyadeep", "middleName": "", "lastName": "Kumar", "dob": "25-08-1978", "gender": "M", "photo": "image-from-aadhaar-in-base64", "mobile": "9711475156", "email": null, "phrAddress": [ "91661258485043@sbx" ], "address": "K-35/d, Pocket-k, Shekh Sarai-2, Malviya Nagar, South Delhi, Delhi", "districtCode": "83", "stateCode": "7", "pinCode": "110017", "abhaType": "STANDARD", "ABHANumber": "91-6612-5848-5043", "abhaStatus": "ACTIVE" }, "isNew": true }

  1. Call https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/enrol/suggestion with following headers to get a list of suggested abha addresses:

Content-Encoding: application/json Authorization: Bearer token-received-in-step-1 Accept-Language: en-us REQUEST-ID: 592031f9-59d8-46e3-9235-a3c818ecb22c TIMESTAMP: 2023-12-05T18:12:45.450Z TRANSACTION_ID: txnId-received-in-step-9

  1. The response will be in this format:

{ "txnId": "142bc004-ac47-495f-9877-4e786b438a7d", "abhaAddressList": [ "satyadeep1978", "satyadeep2581978", "satyadeepkumar.25", "satyadeep.2581978", "kumar.258", "satyadeep258", "satyadeepkumar1978", "satyadeep_kumar", "satyadeep_258", "satyadeep_2581978", "kumar_258", "satyadeep.258", "satyadeepkumar_25", "satyadeepkumar25", "satyadeep.1978", "satyadeepkumar", "satyadeep_1978", "25_satyadeep.kumar" ] }

  1. Create a JSON packet in the following format:

{ "txnId" : "txnId-received-in-step-11", "abhaAddress" ": "selected-abha-address-from-step-11", "preferred" : 1 }

  1. Submit the packet to https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/enrol/abha-address with following headers:

Content-Encoding: application/json Authorization: Bearer token-received-in-step-1 Accept-Language: en-us REQUEST-ID: uuidv4 TIMESTAMP: 2023-12-05T17:17:32.246Z Content-Type: application/json

  1. Response will be in following format:

{ "txnId": "txnId-received-in-step-11", "healthIdNumber": "abha-number", "preferredAbhaAddress": "selected-abha-address-from-step-11" }

Hi @satyadeep,
Thank you for the quick responce. In step 5 what is the REQUEST-ID: uuidv4 where we will get?
and one more is you mentioned in the step 4 txnId ; how can i get that txnId because previously I executed session API

Hi @Vinay,

UUID is just a unique identifier , in Python you get it from

str(uuid.uuidv4())

OR in Java

UUID.randomUUID().toString()

Initial txnId will be blank in step4 , in response you will get a value which you need to chain in subsequent requests.

Thanks

Hi @satyadeep @IntegrationSupport

In the step 7. what is the purpose of giving patient mobile number. further api’s we are not using this number any where
and it will take other number also rather then Aadhar connected phone number.

Thanks

Can anyone suggest me on this? @satyadeep @IntegrationSupport