Signing API requests
All endpoints require signature validation for the request to be accepted for processing. We use HMAC SHA-512 based signatures to valiate requests. Add Request-Signature
and Request-Timestamp
as required header parameters.
Signing Key
Get your API secret that will be used for signing requests on the dashboard. How to get your API credentials
Please note that your API secret should be stored securely. It should be used only for generating Request-Signature
header, do not add the API secret directly to any API request to avoid exposure. Paycashless will never request you to share your API key or API secret.
Signing a request
Step | Action | Description |
---|---|---|
1 | Sort | If the request has a body, sort it alphabetically. |
2 | Hash | If the request has a body, turn the sorted body into a string and hash it with HMAC SHA-512 algorithm using your API secret as the signing key (output should be hex-encoded). |
3 | Concatenate | Concatenate the request path , hashed body (if present), and timestamp . There are no spaces or other characters between these values. The order of the fields must follow the order stipulated here. |
4 | Sign | Take the string from the Concatenate step and generate a HMAC SHA-512 signature using your API secret as the signing key. |
5 | Encode | Take the output of the Sign step and hex-encode it. |
The fields used to generate the signature are as follows. If the conditions below are not met, your signature will not validate.
Field | Description |
---|---|
Request Path | Lowercased URL path without the base url and search parameters (e.g. /v1/virtual_account/va_84jdvcy3gyt5bfsczdaooy4/transactions ). |
Hashed Body | Should be omitted if request does not have a body (e.g. GET requests). The alphabetically sorted, stringified and HMAC SHA-512 hashed http request body. |
Timestamp | The number of seconds since the Unix Epoch in UTC, and must be within five minutes of the API service’s time when the request arrives. The same value MUST also be passed in the Request-Timestamp header. |
API Signature example
You can use the example values below to test and validate your signing code logic;
Field | Value |
---|---|
Request Path | /v1/payouts |
Sorted Body | {"amount":{"currency":"NGN","value":10000},"bankId":"bank_538ed2056326432ba8e6853b613997bb","callbackUrl":"https://webhook.site/99a59e8a-bd0b-485d-8249-fccb5eb62e27","destinationAccountNumber":"9845648577","metadata":{"category":"transfer"},"narration":"zapped","reference":"trx_fWQ7b31pbs5mmT3k3qfb46"} |
Hashed Body | 61ce72561daddb581abbd83c731dc5421b062157f707b1f683086bccbe85d8b14b7a4df6a1cdb7c14230a631d8ad7d82536f28c2e67717e6cf6673d8b6df3a23 |
Timestamp | 1749163599 |
Signing Key | live_sk_bqf5evl708c5arkfv16g37glc4isxsup.pc |
Signature | 95013b0b1e41f36b2de57cd6ef08ecc4d0f8ff846c98e1470f3ef8bce90012133a7c867b7d21e4c27cc68c1bde0bb3fc63e960c892ac82c8ef74b9f793854d7d |
Below is a node.js code sample used in signing the values above;