WebSocket order commands are useful when your service already keeps a live trading connection open. They follow the same business rules as REST order routes, but the response model is streaming oriented:Documentation Index
Fetch the complete documentation index at: https://stabyl.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
- Send a
commandmessage with a uniquerequest_id. - Receive
command_ackorcommand_error. - Track final order status through
user.ordersor REST order reads.
Required Access
| Action | Access requirement |
|---|---|
order_create | API key enabled for order creation |
order_cancel | API key enabled for order execution |
order_replace | API key enabled for order execution |
user.orders updates | API key enabled for exchange reads |
user.fills updates | API key enabled for exchange reads |
Command Envelope
Every command uses the same outer shape:request_id as your local correlation ID. If idempotency_key is omitted, Stabyl uses request_id as the idempotency key. For clarity, production clients should send both values and store them before sending the command.
Create Order
Use the REST pair ID in command payloads. For the currently supported pair, sendUSD/NGN; topic keys such as USD_NGN are only used in subscription topic names.
Cancel Order
Replace Order
Command Errors
Command rejections usecommand_error.
| Code | Meaning | Action |
|---|---|---|
UNAUTHORIZED | The connection is not authenticated | Reconnect with a valid API key |
FORBIDDEN | The API key is not permitted for the action | Use a key enabled for that action |
VALIDATION_FAILED | The command payload is invalid | Correct the command before retrying |
CONFLICT | The idempotency key or order state conflicts | Read the order state before sending a new intent |
RATE_LIMITED | Too many messages or commands | Back off and retry later |
Production Pattern
- Subscribe to
user.ordersbefore submitting commands. - Store
{request_id, idempotency_key, action, local_order_intent}before sending. - Treat
command_ackas asynchronous acceptance. - Reconcile final status from
user.orders. - If the socket disconnects after a command, reconnect, resubscribe with
resume, and read the order by REST before sending a replacement intent.