For the complete documentation index, see llms.txt. This page is also available as Markdown.

Signing Requests With API Keys

Sign authenticated API requests with HMAC-SHA256 using your API key.

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.

Required headers

Header
Value

X-API-KEY

Your API key

X-TIMESTAMP

Request time as a Unix timestamp in seconds

X-SIGNATURE

Hex-encoded HMAC-SHA256 signature (see below)

How the signature is computed

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

prehash = METHOD + PATH + TIMESTAMP + CANONICAL
Part
Description

METHOD

Uppercase HTTP method, e.g. GET, POST, DELETE

PATH

Request path only, without the query string, e.g. /perpetual/order

TIMESTAMP

The same value sent in X-TIMESTAMP (Unix seconds)

CANONICAL

The canonical string built from the request parameters (below)

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:

key1=value1|key2=value2|...

For a body of {"market":"BTCUSDT","side":"buy","type":"limit","amount":"0.5","price":"35000"}:

amount=0.5|market=BTCUSDT|price=35000|side=buy|type=limit

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

Last updated

Was this helpful?