Skip to main content
API key authentication lets you call authenticated endpoints from servers and scripts without the interactive wallet signing flow. Every authenticated request carries three headers, and the signature is recomputed per request from the request contents.
Your API secret is used to compute signatures and is never sent in a request. Never commit it to version control, log it, or expose it in client-side code. Store it in an environment variable or a secrets manager.

Required headers

How the signature is computed

The signature is HMAC-SHA256(secret, prehash), hex-encoded, where:

Building the canonical string

The canonical string is built from sorted parameters joined into key=value pairs with a | separator. Where the parameters come from depends on the method:
Use the JSON request body. Sort its top-level keys alphabetically and join them:
For a body of {"market":"BTCUSDT","side":"buy","type":"limit","amount":"0.5","price":"35000"}:
Send decimal values (amount, price, …) as strings, exactly as they appear in the body you transmit. This keeps the signed value identical to the sent value and avoids floating-point formatting differences.

Worked example

For POST /perpetual/order at timestamp 1701938200 with the body above:
The request then carries:

Code examples

Common pitfalls

  • Sign the body you send. The JSON you transmit must contain exactly the values used to build the canonical string. Re-serializing or reordering after signing will invalidate the signature.
  • Seconds, not milliseconds. X-TIMESTAMP is Unix seconds. Sending milliseconds will fail verification.
  • Path only. Exclude the query string from PATH; query parameters belong in the canonical string for GET/DELETE.
  • Sort keys. Both body keys and query keys must be sorted alphabetically before joining.