Skip to main content
WSS
/
orders
/
ws
Messages
token
type:http

Bearer token authentication using user/session tokens from /api/get_user_token.

To connect to the WebSocket, include the Authorization header:

Authorization: Bearer <token>
Place Order Request
type:object

Request to place a new order (t="p")

Cancel Order Request
type:object

Request to cancel an existing order (t="x")

Replace Order Request
type:object

Request to cancel and replace an existing order with a new order (t="r")

Get Open Orders Request
type:object

Request to retrieve all open orders (t="o")

Login Response
type:object

Initial response upon WebSocket connection (rid=0)

Place Order Response
type:object

Response to place order request

Cancel Order Response
type:object

Response to cancel order request

Get Open Orders Response
type:object

Response to get open orders request

Heartbeat Event
type:object

Heartbeat/timestamp event (t="h")

Cancel Rejected Event
type:object

Order cancel request was rejected (t="e")

Order Acknowledged Event
type:object

Order has been acknowledged by the exchange (t="n")

Order Canceled Event
type:object

Order has been canceled (t="c")

Order Replaced/Amended Event
type:object

Order has been replaced or amended (t="r")

Order Rejected Event
type:object

Order has been rejected (t="j")

Order Expired Event
type:object

Order has expired (t="x")

Order Done For Day Event
type:object

Order is done for the day (t="d")

Order Partially Filled Event
type:object

Order has been partially filled (t="p")

Order Filled Event
type:object

Order has been completely filled (t="f")

Quickstart

1. Get a token

curl -s -X POST https://gateway.sandbox.architect.exchange/api/authenticate \
  -H "Content-Type: application/json" \
  -d '{"api_key":"YOUR_KEY","api_secret":"YOUR_SECRET","expiration_seconds":3600}'
# Response: {"token":"<bearer-token>"}

2. Connect to the WebSocket

Pass the token as an Authorization header on the WebSocket upgrade request. Invalid or missing tokens are rejected with HTTP 401 before the connection is established.
# Store the token
TOKEN=$(curl -s -X POST https://gateway.sandbox.architect.exchange/api/authenticate \
  -H "Content-Type: application/json" \
  -d '{"api_key":"YOUR_KEY","api_secret":"YOUR_SECRET","expiration_seconds":3600}' \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['token'])")

# Connect
wscat -c wss://gateway.sandbox.architect.exchange/orders/ws \
  -H "Authorization: Bearer $TOKEN"
Replace gateway.sandbox.architect.exchange with gateway.architect.exchange for production.

3. Login response

On successful connection, the server sends a login response with rid: 0 containing your open orders:
{"rid":0,"res":{"li":"user@example.com","o":[]},"err":null}

4. Place an order

{"rid":1,"t":"p","s":"BTCUSD-PERP","d":"B","q":100,"p":"50000.50","tif":"GTC","po":false}
The server responds with the order ID:
{"rid":1,"res":{"oid":"O-01ARZ3NDEKTSV4RRFFQ69G5FAV"}}
You then receive order lifecycle events as they happen (acknowledged t="n", filled t="f", canceled t="c", rejected t="j").

Cancel on Disconnect

To automatically cancel all orders placed during a WebSocket session when the connection drops, pass the cancel_on_disconnect query parameter when opening the connection:
var ws = new WebSocket(
  'wss://gateway.sandbox.architect.exchange/orders/ws?cancel_on_disconnect=true'
);
wscat -c "wss://gateway.sandbox.architect.exchange/orders/ws?cancel-on-disconnect=true" \
  -H "Authorization: Bearer $TOKEN"
Only orders sent on that specific connection are canceled; orders placed via other connections or the REST API are unaffected.