> 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/futures-api/websockets/futures-account-streams.md).

# Futures Account Streams

Private real-time streams for your futures positions, orders and margin

Private futures streams push changes to your own account as they happen. Use them together with the [Futures REST API](broken://pages/5af105514c769e54cdcc5c7c16de2848aa3aa267): REST for snapshots and actions, the streams for live updates.

**Service host**

```
wss://futures-trading-service.outpoll.com
```

| Path              | Stream                                                                                                                             |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `/ws/account`     | [Account](broken://pages/b98b6cd479e29bae1cf234bb22dd91f425304c45) — positions, orders, conditional orders and TP/SL levels        |
| `/ws/margin-call` | [Margin Call](broken://pages/a4f871986afaae9dec015a2458fcea86fc10200e) — warnings when your cross margin gets close to liquidation |

Each stream is a separate connection with its own authentication. You can keep both open at the same time.

### Authentication

The connection opens without credentials. Authenticate with the first message, signed with your API key — the same key and signature scheme as the [private REST endpoints](broken://pages/ad7a5aad5382f76a22dab4548a284719ba32284b#authentication), with an empty body:

```
message   = ts + "GET" + path
signature = Base64URL_NoPadding( HMAC_SHA256( key = Base64URL_Decode(apiSecret), message ) )
```

| Part   | Value                                                                                |
| ------ | ------------------------------------------------------------------------------------ |
| `ts`   | Current Unix time in seconds, as a string; must be within ±30 seconds of server time |
| `path` | The stream path: `/ws/account` or `/ws/margin-call`                                  |

```json
{
  "t": "AUTH",
  "d": {
    "key": "your-api-key",
    "ts": "1790835600",
    "sig": "signature"
  }
}
```

On success the server replies:

```json
{
  "t": "AUTH",
  "d": {
    "ok": true
  }
}
```

* Send `AUTH` within **5 seconds** of connecting. Otherwise the server closes the connection with code `1008` (`auth required`).
* A wrong signature, a stale `ts`, or an unknown, expired or blocked key closes the connection with code `1008` immediately.
* Each `AUTH` counts against your API key's [rate limits](broken://pages/17081ff6556bc030aad99768726350d198881933#do-i-have-any-rate-limits).
* Until you are authenticated, every message other than `AUTH` is ignored, including `ping`.
* A user access token is accepted too: `{"t":"AUTH","d":{"t":"<access-token>"}}`. Browser clients on an Outpoll site are authenticated from the session cookie and don't need to send `AUTH`.
* Don't send an `Origin` header from a non-browser client. A connection with an `Origin` that is not an Outpoll site is rejected during the handshake (`403`).

### Message Envelope

Server messages are JSON text frames. The `AUTH` acknowledgement uses `t` / `d`:

| Field | Type   | Description          |
| ----- | ------ | -------------------- |
| `t`   | string | Message type, `AUTH` |
| `d`   | object | `{"ok": true}`       |

Data messages have a stream-specific shape — see [Account](broken://pages/b98b6cd479e29bae1cf234bb22dd91f425304c45#message-envelope) and [Margin Call](broken://pages/a4f871986afaae9dec015a2458fcea86fc10200e#margin_call-payload).

### Ping / Pong

Send the plain text `ping` (not JSON) to keep the connection alive; the server answers with the plain text `pong`. Standard WebSocket ping control frames are answered as well.

```
ping
```

```
pong
```

Send a `ping` every 20–30 seconds. A `ping` sent before authentication gets no answer.

### Errors

The streams send no error messages. Problems are reported by closing the connection:

| Close code | Reason          | Cause                                                            |
| ---------- | --------------- | ---------------------------------------------------------------- |
| `1008`     | `auth required` | No `AUTH` within 5 seconds, or an `AUTH` that fails verification |

Messages the server does not understand (invalid JSON, unknown types, subscription requests) are ignored.

### Delivery and Reconnects

* There is no initial snapshot and no replay. A stream only carries changes that happen while you are connected.
* Delivery is best-effort; messages carry no sequence numbers.
* After connecting or reconnecting: authenticate first, then load the current state over REST, then apply stream messages on top of it.
* Reconnect with exponential backoff and jitter (for example 1 s, 2 s, 4 s … up to 30 s).
* Every open, authenticated connection of the same user receives every message.

### Pages

* [Account](broken://pages/b98b6cd479e29bae1cf234bb22dd91f425304c45) — `/ws/account`
* [Margin Call](broken://pages/a4f871986afaae9dec015a2458fcea86fc10200e) — `/ws/margin-call`


---

# 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/futures-api/websockets/futures-account-streams.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.
