Message reference

Every message is a JSON object with a type field.

Messages you send

typePurposeExample
subscribeSubscribe to market data channels{"type":"subscribe","channels":["orderbook:CC/USDCx"]}
unsubscribeStop receiving channels{"type":"unsubscribe","channels":["orderbook:CC/USDCx"]}
authRe-authenticate an open connection (usually not needed){"type":"auth","api_key":"your-api-key-here"}
pingCheck the connection{"type":"ping"}
place_orderPlace an order{"type":"place_order","id":"c-1","symbol":"CC/USDCx","side":"buy","quantity":10,"price":0.15}
cancel_orderCancel one order, by order_id or request_id{"type":"cancel_order","id":"c-2","request_id":51234}
cancel_all_ordersCancel all open orders, optionally for one symbol{"type":"cancel_all_orders","id":"c-3","symbol":"CC/USDCx"}

Fields for the order commands are on Placing and cancelling orders.

Messages you receive

typeWhenExample
subscribedAfter subscribe{"type":"subscribed","channels":["orderbook:CC/USDCx"]}
authenticatedAfter a successful auth{"type":"authenticated","user_id":12345}
pongAfter ping{"type":"pong"}
dataMarket data on a channel you subscribed to{"type":"data","channel":"trades:CC/USDCx","data":{...}}
user_dataAn event on your account{"type":"user_data","event":"user_order","user_id":12345,"data":{...}}
order_ackplace_order was queued{"type":"order_ack","id":"c-1","request_id":51234}
cancel_ackcancel_order was queued{"type":"cancel_ack","id":"c-2","order_id":"51234","already_queued":false}
cancel_all_ackcancel_all_orders was queued{"type":"cancel_all_ack","id":"c-3","canceled_count":2,"already_queued_count":0,"order_ids":["ord_a","ord_b"]}
auth_expiredYour credential is no longer valid; the connection then closes with 4008{"type":"auth_expired","reason":"api_key_revoked","message":"API key revoked or regenerated, please re-authenticate"}
errorSomething was refused or went wrong{"type":"error","code":"MAX_SUBSCRIPTIONS","message":"Maximum subscriptions reached"}

Payloads for data and user_data are on Market data channels and User events.

Errors

{"type":"error","id":"c-1","code":"VALIDATION_FAILED","message":"Validation failed","fields":{"quantity":"quantity must be greater than 0"}}
FieldDescription
codeMachine-readable error code (below)
messageHuman-readable description
idThe order command's id, when the error answers one
fieldsFor VALIDATION_FAILED, a message per field, by JSON field name

A command with a missing id, or one longer than 64 bytes, is not run and gets VALIDATION_FAILED with no id.

Connection, authentication and subscriptions

CodeMeaning
INVALID_MESSAGEThe message could not be read or its type is not known
MAX_SUBSCRIPTIONSThe connection already has 50 subscriptions
RATE_LIMITEDToo many messages (see Rate limits)
AUTH_REQUIREDThe connection is not authenticated for what you sent, or its credential is no longer valid and it is closing
INVALID_API_KEYThe API key was not found
API_KEY_REVOKEDThe API key was revoked
INVALID_TOKEN, TOKEN_EXPIRED, SESSION_REVOKEDWeb-app login (JWT) connections only
ACCOUNT_LOCKEDThe account is locked or suspended
ACCOUNT_WITHDRAW_ONLYThe account is restricted to withdraw-only access
IP_ALLOWLIST_DENIEDYour IP address is not on the account's allowlist
MAINTENANCE_MODETrading is halted for maintenance
INSUFFICIENT_SCOPEThe API key lacks the scope needed
INTERNAL_ERROROn API-key authentication, the key could not be checked (retry later), not that it is invalid. On an order command, see below.

Order commands

Order command errors carry the command's id. Each matches a REST rejection unless marked WebSocket only.

CodeMeaning
VALIDATION_FAILEDA field is missing or invalid (REST 400); see fields
INVALID_SYMBOLThe trading pair does not exist
MINIMUM_QUANTITY_NOT_METThe quantity is below the pair's minimum
MAX_DECIMALS_EXCEEDEDThe quantity or price has more decimals than the pair allows
PRICE_OUTSIDE_COLLARWebSocket only: the limit price is outside the matching engine's price collar; the message gives the bound
SELF_CROSSThe order would only cross your own resting orders
INSUFFICIENT_BALANCENot enough balance for the order
INSUFFICIENT_FEE_BALANCENot enough prepaid trading fees
ORDER_LIMIT_EXCEEDEDMax open orders reached
ORDER_RATE_LIMIT_EXCEEDEDOrders per minute reached (per pair, or across the account if it has an account-wide limit)
RATE_LIMITEDThe cancel limit, too many refused orders in the current second, or a key whose rate limit is 0
BUSYWebSocket only: too many commands in progress; retry shortly
TRADING_PAUSEDTrading is paused (REST 423); cancels still work
ORDER_NOT_FOUNDCancel of an order that is not yours, does not exist, or has already left the book (for example filled)
ORDERS_NOT_ALLOWEDThe connection cannot trade: it needs a user's API key with the write scope
ACCOUNT_LOCKED, ACCOUNT_NOT_AVAILABLE, USER_NOT_KYC_APPROVED, USER_EMAIL_NOT_VERIFIED, NOT_ONBOARDEDThe account cannot trade
INTERNAL_ERRORSomething failed on our side. See the table below.

INTERNAL_ERROR on place_order. The message tells you whether the order can exist:

messageWas the order placed?
Order entry is starting; retry shortlyNo
Order entry is not availableNo
Failed to create order requestNo, in practice. Nearly all of these come from a check failing before the order is saved. Only a database connection failing at the exact moment of the save can leave the order saved, which is very rare and the same as with a 500 from REST. To be certain, check your open orders (see "Commands with no reply" on Placing and cancelling orders).
Internal errorUnknown. Treat it like a command with no reply.

Did this page help you?