QA Steps sandbox · Protocol sandbox

Protocol sandbox

The signal room: services that talk back.

Your tasks

A code appears when a task is done – type it into the lesson.

Sign in to see your tasks

Tasks check what you did, so they need your account.

/ws/orders Not connected

Your token goes with the connection as ?token=.Signed out: the server closes the connection with 4401. Sign in

Messages
  1. Connect, then send the subscribe frame. Events of your order appear here as they happen.
Send a frame
Place an order and pay it first – in the shop, or with the REST API on the API sandbox.

Order status – WebSocket

C6.11

A live feed for your orders. Subscribe with an order id and the server sends created, paid, packed and shipped as they happen. Pay for the order in the shop while you watch.

DirectionFrameMeaning
you send{"type":"subscribe","order_id":…}Follow one order. The value is a whole number such as 12, or an order number such as SH-100012.
you send{"type":"unsubscribe",…}Stop following it.
you send{"type":"ping"}Application-level ping.
you get{"type":"subscribed",…}Your subscription is on. Events of that order follow.
you get{"type":"order.status","seq":…,"status":…}One status change: created, payment_failed, paid, packed, shipped, cancelled.
you get{"type":"pong"}The answer to your ping.
you get{"type":"error","code":…}Something is wrong with your frame. The connection stays open.

Every frame is JSON text. Events of one order arrive in order with a growing seq. Packing and shipping are simulated: a few seconds after payment. A frame you cannot use gets an error frame, not a closed connection.

How to call it from your tools

In Postman

1Create the request: New → WebSocket, then enter the URL

2Before you connect, open Headers and add Authorization with the value Bearer and your token. Or add a token parameter in Params.

3Press Connect. Without a token the connection opens and closes at once with code 4401.

4In the message composer choose JSON, paste this and press Send. The value is a whole number such as 12, or an order number such as SH-100012.

5Watch the messages list. Send a wrong value to see an error frame; send a ping to get a pong.

With wscat

Then type the subscribe frame and press Enter. An event looks like this:

And a mistake like this (the connection stays open):

Close codes

Close codeWhen
4401No token or API key, or an invalid one.
4429More than 5 open connections for your account.
1009A frame larger than 4 KB.
1001The server is stopping.