Skip to main content

3. API Specification

3.1 Authentication and Authorization

OAuth 2.0 API authentication mechanism has been implemented for authentication and authorization process in NPI. The client needs to provide client specific credentials in the authorization header and user credentials in the body with grant type as password for token generation on first login or during refresh token expiration.
On successful authentication, system will provide access token and refresh token pair. Access tokens are used for accessing the resources and refresh tokens are used for obtaining and renewal of access tokens. Validity of access token is 300 seconds and validity of refresh token is 12 hours (which may vary as per NCHL Security Policy). Access tokens could be obtained by using non-expired refresh tokens in the body with grant type as refresh token.

Method to generate & use access and refresh token

  1. Use the provided basic authentication credentials along with username/password and grant type as password to obtain a refresh token. Refresh token has validity of 12 hours for now, so store the refresh token for future access token requests. Do not use the access token obtained during this initial request.

  2. Use the stored refresh token obtained from step 1 to generate new access token keeping grant type as refresh token. Access tokens are valid for 300 seconds. Use the obtained access token in the authorization header: Bearer {access_token} of all API resources requests within this period. On expiry of access token re-request using the stored refresh token.

  3. On expiry of refresh token repeat the process from step 1.

MethodURL
POST(base URL)/oauth/token

3.2 Token Generation Process

  1. Generate token string as per the instruction provided in API specification.

  2. Sign the message token from step 1 using the digital certificate private key (pfx file/KeyStore). The digital signature algorithm will be the SHA256withRSA.

  3. Convert the signed token above in step 2 to base64 encoding.

  4. Pass this signature string to the “token” field of the request message.

3.3 Create Withdraw Request

This API is used to initiate OTP request based on the parameters provided. Third party user must have user for authentication from NPI.

MethodURLAuthorization
POST(base URL)/api/v1/cardless/create-requestBearer(access_token)

Request Parameter

#Field NameData TypeLengthDescriptionPresence
1amountstringTransaction amount should be in rupees and multiples of 1000M
2mobileNumberstring10Mobile number of usersM
3accountNamestring50Customer A/C name. In case of wallet, this should be wallet pool A/C name.M
4accountNumberstring20Customer A/C number. In case of wallet, this should be wallet pool A/C numberM
5branchIdstring3Customer A/C branch. In case of wallet, this should be wallet pool A/C branch.M
6transactionUniqueIdstring36Transaction ID which is used to reconcile between third party and NCHL. It must be unique for each request.M
7currencyCodestring3Currency of transaction. Example: NPRM
8remarksstring36Remarks for the transaction.M

Token String: Mobile Number+,”+transactionUniqueId+”,+amount+, NPI userId

Sample Request Payload:

{
"amount": 5000.0,
"mobileNumber": "98XXXXXXXX",
"accountName": "Ankit Neupane",
"accountNumber": "00100XXXXXXX",
"branchId": "1",
"bankId": "1000",
"transactionUniqueId": "b39a8e6f-d022-49e2-b21e-452178ad2746",
"remarks": "Towards the mountains",
"token":"dUD1Fmxb2l9NE+aTgCLuomlOFm0bpkmlE2XwpTDIF2r1tG1xZU5FfNj9SRJpQEQm5V+u7SF9aTXa0AsINnXYwcJiNT/Fd5K818SIsQ/ELXeAskbl3MZyV6GuY0Uh7n3RjIoZhJ3mdz0lbr9PZohSB8EQFAccj/yeZgSLGRAJgeg="
}

Sample Success Response:

{
"responseCode": "000",
"responseMessage": "Withdrawal request process successfully. You will be notified with SMS with more detail."
}

3.4 Cash Withdraw Request

This request initiates the cash withdrawal transactions processed through the acquiring switch to retail payment switch.

MethodURLAuthorization
POST(base URL)/cardless/withdraw/transactionBearer (access_token)
#Field NameData TypeLengthDescriptionPresence
1verificationCodeStringOTP received by the customer.M
2mobileNumberString10Mobile number of customersM
3amountStringAmount entered during withdrawal request.M
4bankCodeString4ATM Acquiring Bank CodeM
5traceNumberStringTrace NumberM
6referenceNumberStringATM reference numberM
7terminalIdStringATM Terminal IdM

Sample Request Payload:

{
"verificationCode": "999277",
"mobileNumber": "9813XXXXXX",
"amount": 500000,
"bankCode": "PCBLNPKA",
"traceNumber": "TRACE015",
"referenceNumber": "CLW-058834591",
"terminalId": "PRIME2101"
}

Sample Success Response:

{
"status": "true",
"message": "Cash withdrawal Successful",
"code": "000",
"developerMessage": "null",
"link": "null",
"data": "{
"accountNumber": "0010XXXXXXXX",
"mobileNumber": "9813XXXXXX",
"bankCode": "PCBLNPKA",
"amount": 5000,
"bookingDate": "2024-05-09 11:27:16.676",
"referenceId": "CLW-058834591",
"terminalId": "PRIME2101",
"traceNumber": "TRACE015"
}",
}

3.5 Cardless Withdraw Report

MethodURLAuthorization
POST(base URL)/oauth/tokenBearer(access_token)
#Field NameData TypeLengthDescriptionPresence
1transactionUniqueIdString36Transaction Unique Id of that transaction.M

Sample Request Payload:


{
"transactionUniqueId": "b39a8e6f-d022-49e2-b21e-452178ad2746"
}

Sample Success Response

{
"responseCode": "000",
"responseData": [
{
"accountNumber": "001XXXXXXXXXXX",
"branchId": "1",
"bankId": "2501",
"accountName": "Ankit Neupane",
"amount": 5000,
"mobileNumber": "9813XXXXXX",
"expiryDate": "2024-05-09T06:58:25.029+00:00",
"customerIdentifier": "SABITA@999",
"status": "ACTIVE",
"txnId": "12809565",
"paymentStatus": "PAID",
"instrument": "MOBILE_BANKING",
"transactionUniqueId": "b39a8e6f-d022-49e2-b21e-452178ad2746",
"remarks": "Towards the mountains"
}
]
}

3.6 Cardless Withdraw Notification

To notify about the transaction status (success or failure) for reconciliation purposes. Status of transaction will be pushed to notification URL. Each request will be formatted in JSON and signed using private key. The receiver will verify the signature using public key provided by NCHL ensuring the integrity and authenticity of the request, preventing tampering during transmission. Notifications will be dispatched upon transaction processing, and a response is expected to confirm whether the notification was successfully delivered.

The notification API provided by the receiver should be secured using basic authentication. The credentials must be added in the header of each API call. Credentials should be combined into a single string in below format, then encoded using Base64.

Method URLAuthorization
POST(base URL)/cardless/thirdparty/notificationBasic Base64(username:password)

Request Details:

The request body will be a JSON object containing the transaction details:

#Field NameLengthDescription
1transactionUniqueId36Transaction ID which is used to reconcile between third party and NCHL. It must be unique for each request.
2debitStatus4Status of the debit operation.
3debitDescription36Description of the debit status.
4creditStatus4Status of the credit operation.
5creditDescription36Description of the credit status.
6rpsTransactionId10Unique identifier of transaction on NPI (RPS).
7mobileNumber10Mobile number associated with the transaction.
8remarks36User Remarks.
9tokenSignature token.

Sample JSON Request


{
"transactionUniqueId": "card30",
"debitStatus": "000",
"debitDescription": "SUCCESS",
"creditStatus": "000",
"creditDescription": "SUCCESS",
"rpsTransactionId": 13185492,
"mobileNumber": "*****08459",
"remarks": " Towards the mountains ",
"paymentStatus": "PAID",
}

The JSON payload must be signed using private key. Upon receiving the notification, the receiver will use verify the public key provided by NCHL to ensure authenticity and integrity. After processing the notification, the receiver will send a response back to the sender to confirm whether the notification was successfully delivered. Response format can be any, but following in response is mandatory, for proper verification of withdraw Notification.

#Field NameData TypeExampleDescription
1statusStringSUCCESSNotification Response status: SUCCESS or FAILED or TIMEOUT
2messageStringNotification send successfullyA message providing additional context or remarks about the response.