Authentication and HMAC signing
Every /api/v1 request requires three headers:
X-CF-API-Key: your-api-key
X-CF-Timestamp: 2026-10-14T12:00:00.000Z
X-CF-Signature: base64-hmac-sha256-signature
The API key identifies a credential. The API secret signs requests and must never be transmitted.
#Canonical request
Build the signed bytes in this exact order:
timestamp + "\n" +
uppercaseMethod + "\n" +
requestPathWithQuery + "\n" +
rawRequestBody
Calculate HMAC-SHA256 using the API secret as the key and encode the 32-byte result with standard Base64:
signature = Base64(HMAC-SHA256(apiSecret, canonicalRequest))
#Rules
- Use the timestamp header exactly as written in the canonical request.
- The timestamp must be ISO 8601 UTC and within five minutes of server time.
- Uppercase the HTTP method, for example
GETorPOST. - The path starts with
/api/v1and never includes scheme or hostname. - Include the raw query string, including parameter order, when one exists.
- Use the exact request body bytes sent over the network.
- Use an empty body after the last newline for
GETrequests. - Encode the signature with standard Base64, not Base64URL or hexadecimal.
- Do not pretty-print, reorder, or reserialize JSON after signing it.
Header names are case-insensitive. Their values are not.
#Fixed test vector
Use this non-production vector to test an implementation:
secret:
test_secret_do_not_use
timestamp:
2026-10-14T12:00:00.000Z
method:
POST
request path:
/api/v1/energy/estimate
raw body:
{"from_address":"TESVFJJpXqHsTvdoHy58qFAvsZhHeqbQgZ","to_address":"TSknn7sfj5qJEPYLesBuSDo9u1h87GveZk"}
The canonical string is:
2026-10-14T12:00:00.000Z
POST
/api/v1/energy/estimate
{"from_address":"TESVFJJpXqHsTvdoHy58qFAvsZhHeqbQgZ","to_address":"TSknn7sfj5qJEPYLesBuSDo9u1h87GveZk"}
Expected signature:
XOuqdx4Yg1tZGg77v0Rc/1lNQ86UY8zCM9U8+9Ve670=
The vector timestamp is intentionally historical and cannot authenticate a real request.
#Signature failures
Coinfira intentionally returns the same authentication_failed error for an
unknown API key and an invalid signature. This prevents credential discovery.
Common causes:
- signing
/energy/ordersinstead of/api/v1/energy/orders; - using local time instead of UTC;
- signing formatted JSON but sending compact JSON;
- appending a newline to the body;
- using Base64URL;
- omitting query parameters;
- a reverse proxy changing the URL before the signature is calculated.