Kuest Docs

Authentication

Create CLOB credentials and sign private requests

The CLOB API uses two authentication levels. L1 proves control of a wallet; L2 signs trading and account requests with credentials derived from that wallet.

Choose the required level

LevelMethodUse it for
PublicNo credentialsMarkets, books, prices, spreads, and public analytics
L1EIP-712 wallet signatureCreate or derive API credentials
L2HMAC-SHA256 with API credentialsPrivate order, cancellation, trade, and account routes

L2 authenticates the request. A new order still contains an order payload signed by the trader before submission.

The TypeScript, Python, and Rust clients create or derive L2 credentials and attach the required headers. See Clients & SDKs.

When implementing authentication directly, synchronize your clock with Get Server Time first.

Create or derive credentials

Use one of the L1 routes:

POST {CLOB_URL}/auth/api-key
GET  {CLOB_URL}/auth/derive-api-key

Send these headers:

HeaderRequiredDescription
KUEST_ADDRESSYesPolygon signer address
KUEST_SIGNATUREYesEIP-712 signature for the auth payload
KUEST_TIMESTAMPYesCurrent Unix timestamp in seconds
KUEST_NONCEYesAuth nonce, commonly 0
KUEST_REFERRALNoReferral identifier used for attribution

Sign this EIP-712 shape with the same address sent in KUEST_ADDRESS:

{
  "domain": {
    "name": "ClobAuthDomain",
    "version": "1",
    "chainId": 137
  },
  "types": {
    "ClobAuth": [
      { "name": "address", "type": "address" },
      { "name": "timestamp", "type": "string" },
      { "name": "nonce", "type": "uint256" },
      { "name": "message", "type": "string" }
    ]
  },
  "message": {
    "address": "<signing_address>",
    "timestamp": "<unix_timestamp>",
    "nonce": "<nonce>",
    "message": "This message attests that I control the given wallet"
  }
}

The response contains:

{
  "apiKey": "550e8400-e29b-41d4-a716-446655440000",
  "secret": "<generated_secret>",
  "passphrase": "<generated_passphrase>"
}

Sign an L2 request

Private CLOB routes require all five headers:

HeaderValue
KUEST_ADDRESSPolygon signer address
KUEST_SIGNATUREHMAC signature for the request
KUEST_TIMESTAMPCurrent Unix timestamp in seconds
KUEST_API_KEYAPI key UUID
KUEST_PASSPHRASEPassphrase paired with the API key

The HMAC input must match the exact timestamp, method, path, and body sent over the wire. Do not serialize the body again after calculating the signature.

Store credentials as secrets

Keep the private key, API secret, and passphrase in a server-side secret store. Do not place them in frontend bundles, logs, analytics, URLs, or support messages.

Troubleshooting

SymptomCheck
Timestamp or expired-signature errorSynchronize with server time and retry
Invalid L1 signatureConfirm chain ID, signer address, nonce, and exact message
Invalid L2 signatureConfirm method, path, raw body, timestamp, and base64 secret
Auth works but order failsValidate the order signature, funder, balance, and approvals