Skip to main content
All requests to the Tonder API must be authenticated. We use a combination of an API key and an HMAC-SHA256 signature to ensure that all communication is secure and comes from a trusted source. An unauthenticated request will result in a 401 Unauthorized error.

Authentication Methods

There are two key components to authenticating your requests:
  1. API Key: A unique token that identifies your business.
  2. 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 credentialsFor 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 the HMAC-SHA256 algorithm.

Signature Generation Steps

  1. Get the raw JSON payload of your POST request.
  2. 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}).
  3. Retrieve your secret key from the Tonder dashboard.
  4. Use the HMAC-SHA256 algorithm with your secret key to hash the serialized JSON string. The output should be in binary format.
  5. Encode the binary digest as a Base64 string. This is your final signature.

Code Examples

Complete Request Example

Here’s a complete example showing how to make an authenticated request to the Tonder API:
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 examples above assume 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.

Security Best Practices

Protect your credentials
  • Never expose your Secret Key in client-side code, mobile apps, or version control
  • Use environment variables to store credentials instead of hardcoding them
  • Rotate keys immediately if you suspect they have been compromised
  • Use separate keys for Sandbox and Production environments
  • Restrict access to credentials on a need-to-know basis within your team

Troubleshooting Authentication Errors

Debugging signature issuesIf you’re getting signature errors, try these steps:
  1. Print the serialized JSON payload before hashing to verify the format
  2. Ensure all keys are sorted alphabetically, including nested objects
  3. Verify there’s no whitespace in the serialized JSON (no spaces after : or ,)
  4. Confirm you’re using the correct Secret Key for your environment (Sandbox vs Production)

Next Steps