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.
Where to find your credentials
For more details on environments and endpoints, see the Environment page.
Required Headers
You must include these headers in every API request:
Here’s an example of how to include these headers in your request:
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.
Signature Generation Steps
- Get the raw JSON payload of your POST request.
- Serialize the JSON object as a string, sorting keys alphabetically and removing all whitespace between separators (e.g., 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 serialized JSON string. The output should be in binary format.
- Encode the binary digest as a Base64 string. This is your final signature.
Code Examples
- Python
- Node.js
- PHP
Complete Request Example
Here’s a complete example showing how to make an authenticated request to the Tonder API:- Python
- cURL
Security Best Practices
Troubleshooting Authentication Errors
Next Steps
- Review Environment for Sandbox and Production endpoints
- Explore Card Payments or Non-Card Payments to process your first transaction
- Test different scenarios using our testing data
- Check out the Process Overview for the full integration guide

