> For the complete documentation index, see [llms.txt](https://docs.outpoll.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.outpoll.com/api/rest-api/websockets/account-and-history-streams/order-updates.md).

# Order Updates

Real-time order execution and TP/SL status events

Use this stream for private order lifecycle events.

### Endpoint

```
wss://order-service.outpoll.com/order/ws
```

### Authentication

Send this message right after connect.

```json
{
  "t": "AUTH",
  "d": {
    "apiKey": "<API_KEY>",
    "signature": "<SIGNATURE>",
    "timestamp": "<UNIX_EPOCH_SECONDS>"
  }
}
```

Build `signature` from `timestamp + "GET" + "/order/ws"`.

Success response:

```json
{
  "t": "success",
  "d": "authorized",
  "r": null
}
```

Failure response:

```json
{
  "t": "error",
  "d": {
    "error": "Invalid or missing credentials"
  }
}
```

### Order event

```json
{
  "t": "ORDER_UPDATE",
  "d": {
    "i": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "u": "user-id",
    "s": "SUCCESS"
  }
}
```

| Field | Type   | Description                   |
| ----- | ------ | ----------------------------- |
| `d.i` | string | Order ID                      |
| `d.u` | string | User ID                       |
| `d.s` | string | Status. `SUCCESS` or `FAILED` |

### TP/SL event

```json
{
  "t": "TPSL_UPDATE",
  "d": {
    "i": "order-id",
    "u": "user-id",
    "a": "asset-id",
    "q": 100,
    "tpp": 0.95,
    "slp": 0.10,
    "s": "ACTIVE"
  }
}
```

| Field   | Type   | Description       |
| ------- | ------ | ----------------- |
| `d.i`   | string | Order ID          |
| `d.u`   | string | User ID           |
| `d.a`   | string | Asset ID          |
| `d.q`   | number | Quantity          |
| `d.tpp` | number | Take-profit price |
| `d.slp` | number | Stop-loss price   |
| `d.s`   | string | Status            |

### Heartbeat

```json
{
  "t": "PING",
  "d": null,
  "r": null
}
```

### Python example

{% code title="order\_updates.py" %}

```python
import asyncio, json, websockets

def auth_message(api_key, signature, timestamp):
    return {
        "t": "AUTH",
        "d": {
            "apiKey": api_key,
            "signature": signature,
            "timestamp": timestamp,
        },
    }

async def order_updates(api_key, signature, timestamp):
    uri = "wss://order-service.outpoll.com/order/ws"
    async with websockets.connect(uri) as ws:
        await ws.send(json.dumps(auth_message(api_key, signature, timestamp)))

        async for msg in ws:
            print(json.loads(msg))
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.outpoll.com/api/rest-api/websockets/account-and-history-streams/order-updates.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
