Verify an HMAC-SHA256 request signature
Headers:
X-Timestamp: current Unix time in seconds; must be within 300 seconds of server time. X-Signature: lowercase hex of HMAC-SHA256(key: "apibee-hmac-secret", message: X-Timestamp + "." + raw request body). An optional sha256= prefix is accepted. Bash: SIG=$(printf '%s' "$TS.$BODY" | openssl dgst -sha256 -hmac apibee-hmac-secret | awk '{print $NF}')
Note: X-Signature = hex(HMAC-SHA256("apibee-hmac-secret", X-Timestamp + "." + rawBody)); timestamp must be within 5 minutes. Each signature is accepted once: the identical request sent again within the 5-minute window gets 401 (replay refused).
HMAC-SHA256 request signature (X-Timestamp + X-Signature), secret apibee-hmac-secret
Parameters 2
| Name | Type | Description |
|---|---|---|
X-Timestamprequired | header · string | Unix time in seconds; must be within 5 minutes of the server clock. |
X-Signaturerequired | header · string | Hex HMAC-SHA256 of "{X-Timestamp}.{raw body}" with secret apibee-hmac-secret (optional sha256= prefix). |
Request body
Optional. application/json. Any body; it is covered by X-Signature.
{"event":"ping"}Responses
- 200
- Signature valid.
- 401
- Headers missing, timestamp not numeric or outside the tolerance, signature mismatch, or a replayed signature.
Example
curl -X POST "https://api.testingapis.com/api/auth/hmac" \
-H "Content-Type: application/json" \
-H "X-Timestamp: {{unixTimestamp}}" \
-H "X-Signature: {{hmacSignature}}" \
-d '{"event":"ping"}' \
-H "X-TestingApis-Key: YOUR_API_KEY"{"authenticated": true, "scheme": "hmac-sha256", "timestamp": 1790792796, "bodyLength": 16}Sign in to see the details
The parameters, request and response examples and the live Try it panel for this endpoint are for signed-in members. Accounts are free and take a few seconds to create.