---
title: "Order Status WebSocket"
method: GET
path: "/ws"
tags: ["websocket"]
---

# Order Status WebSocket

`GET /ws`

Upgrade to a WebSocket connection to receive real-time order status events.

Authentication is performed over the WebSocket protocol using a `connect` message, so no HTTP headers are required during the upgrade handshake.

### Protocol

**Step 1 - Authenticate** (must be the first message sent):
```json
{"type":"connect","data":{"api_key":"<your_api_key>"}}
```
For organization-wide subscriptions, include an authorization signature generated for `GET /ws`:
```json
{"type":"connect","data":{"api_key":"<your_api_key>","authorization_signature":"APIKey=<your_api_key>,signature=<signature>,timestamp=<timestamp>"}}
```
Server responds on success:
```json
{"type":"connected","data":{"status":"authenticated"}}
```

**Step 2 - Subscribe** to a specific order:
```json
{"type":"subscribe","data":{"order_id":"<id>"}}
```
Server responds:
```json
{"type":"subscription","data":{"order_id":"<id>","scope":"order","status":"subscribed"}}
```

**Subscribe to all orders** in your organization (requires signed connect; omit `order_id` or leave it empty):
```json
{"type":"subscribe","data":{}}
```
Server responds:
```json
{"type":"subscription","data":{"scope":"organization","status":"subscribed"}}
```

**Unsubscribe** from a specific order:
```json
{"type":"unsubscribe","data":{"order_id":"<id>"}}
```
**Unsubscribe** from all org orders:
```json
{"type":"unsubscribe","data":{}}
```

**Server push - Order event:**
```json
{"type":"event","data":{...order event payload...}}
```

**Server message types:**
- `connected` - authentication succeeded
- `subscription` - confirms subscribe/unsubscribe; includes `scope` (`"order"` or `"organization"`)
- `event` - real-time order status change
- `error` - describes what went wrong (e.g. invalid api_key, not authenticated, access denied)

**Notes:**
- Clients must send `connect` before any `subscribe`/`unsubscribe` messages.
- Clients can only subscribe to orders belonging to their own organization.
- Organization-wide subscriptions require a valid `authorization_signature`; API-key-only connections can subscribe to specific orders only.
- A client subscribed at org level receives events for all orders; specific-order and org-level subscriptions can coexist.

## Other responses

- `101` — Switching Protocols - WebSocket connection established
- `400` — Bad Request - WebSocket upgrade failed

---

[API](https://skmtc.net/coinvoyage/apis/coinvoyage-api.md) · [All operations](https://skmtc.net/coinvoyage/apis/coinvoyage-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/coinvoyage/coinvoyage-api/revisions/29e628200554/schema)
