401 Unauthorized
error.
Authentication Methods
There are two key components to authenticating your requests:- API Key: A unique token that identifies your business.
- HMAC Signature: A hash calculated from your request body and your secret key, which verifies the integrity and authenticity of the request.
Required Headers
You must include these headers in every API request:Header | Description |
---|---|
Authorization | Your API key, prefixed with Token . |
X-Signature-Transaction | The Base64-encoded HMAC-SHA256 signature calculated from the request body. Required for POST requests. |
Content-Type | Must be application/json for requests with a body. |
How to Generate the HMAC Signature
The HMAC signature ensures that the request body has not been tampered with in transit. It is calculated using theHMAC-SHA256
algorithm.
The HMAC signature is calculated using the following steps:
- Get the raw JSON payload of your POST request.
- Serialise the JSON object as a string, sorting keys alphabetically and removing all whitespace between separators (for example, use
{"a":1,"b":2}
not{"b": 2, "a": 1}
). - Retrieve your secret key from the Tonder dashboard.
- Use the HMAC-SHA256 algorithm with your secret key to hash the serialised JSON string. The output should be in binary format.
- Encode the binary digest as a Base64 string. This is your final signature.
HMAC ConfigurationHMAC validation can be enabled or disabled on a per-business basis. The specific fields from the request body used to generate the signature are also configurable. The example above assumes the entire request body is used. If you encounter authentication issues, verify your HMAC configuration with your Tonder Customer Success Manager or check your dashboard settings.
Next Steps
- Test different scenarios using our test data.
- Learn how to process payments with other methods like SPEI and OXXO.
- Check out the full guide to going live.