Skip to main content
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:
  1. Send a command message with a unique request_id.
  2. Receive command_ack or command_error.
  3. Track final order status through user.orders or REST order reads.
command_ack means the command was accepted for processing. It does not mean the order is filled, cancelled, or replaced. Use user.orders and GET /partner/exchange/orders/{order_id} for canonical status.

Required Access

Command Envelope

Every command uses the same outer shape:
Use 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, send USD/NGN; topic keys such as USD_NGN are only used in subscription topic names.
Acknowledgement:

Cancel Order

Acknowledgement:

Replace Order

Acknowledgement:

Command Errors

Command rejections use command_error.
Common error classes:

Production Pattern

  1. Subscribe to user.orders before submitting commands.
  2. Store {request_id, idempotency_key, action, local_order_intent} before sending.
  3. Treat command_ack as asynchronous acceptance.
  4. Reconcile final status from user.orders.
  5. If the socket disconnects after a command, reconnect, resubscribe with resume, and read the order by REST before sending a replacement intent.