> For the complete documentation index, see [llms.txt](https://sodex.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sodex.com/documentation/for-developers/api-reference/trading-api/websocket-v1/account-updates.md).

# Account Updates Stream

Pushed when account balances, TWAP orders, or positions (perps only) are updated.

Balances in `B` are updated values, not deltas: Spot uses `t` (including locked funds) and `l` (locked funds); Perps uses `wb`. Assets absent from an update must not be reset to zero.

Builder fee credits are reflected in the receiving builder account's balances. This channel does not attach a fee reason or trade ID to those balance values. See [Fee credits and withdrawals](/documentation/for-developers/developers/trading/builder-codes-in-trading.md#fee-credits-and-withdrawals) for subscription and reconciliation guidance.

## Update Speed

* Pushed on each block.

## Subscribe Request

* Subscribe Schema

See [`WsAccountUpdateSubscriptionParams`](/documentation/for-developers/api-reference/trading-api/rest-v1/schema.md#wsaccountupdatesubscriptionparams) in [Schema](/documentation/for-developers/api-reference/trading-api/rest-v1/schema.md).

```typescript
interface SubscribeRequest {
  op: "subscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  params: WsAccountUpdateSubscriptionParams;
}
```

* Subscribe Ack Schema

See [`WsAccountUpdateSubscriptionResult`](/documentation/for-developers/api-reference/trading-api/rest-v1/schema.md#wsaccountupdatesubscriptionresult) in [Schema](/documentation/for-developers/api-reference/trading-api/rest-v1/schema.md).

```typescript
interface SubscriptionResult {
  op: "subscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  result: WsAccountUpdateSubscriptionResult | null;
  success: boolean; // Indicates if the request was successfully processed by the engine.
  connID: string;
  error: string | null; // Condition: If success is false. Error message.
  time_in: number; // The timestamp when the subscription was received on the wire, just prior to parsing data, in milliseconds.
  time_out: number; // The timestamp when the acknowledgement was sent on the wire, just prior to transmitting data, in milliseconds.
}
```

* Example: Subscribe

```json
{
  "op": "subscribe",
  "params": {
    "channel": "accountUpdate",
    "user": "0xed3e79ef16a7890e6eaef2aa6373b6bec5d59d5c"
  }
}
```

* Example: Subscribe Ack

```json
{
  "op": "subscribe",
  "result": {
    "channel": "accountUpdate",
    "user": "0xed3e79ef16a7890e6eaef2aa6373b6bec5d59d5c",
    "accountID": 1001
  },
  "success": true,
  "connID": "0xb0922dfe2b14dadb1195ea4db2b45508",
  "time_in": 1672515782130,
  "time_out": 1672515782136
}
```

## Unsubscribe Request

* Unsubscribe Schema

See [`WsAccountUpdateSubscriptionParams`](/documentation/for-developers/api-reference/trading-api/rest-v1/schema.md#wsaccountupdatesubscriptionparams) in [Schema](/documentation/for-developers/api-reference/trading-api/rest-v1/schema.md).

```typescript
interface UnsubscribeRequest {
  op: "unsubscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  params: WsAccountUpdateSubscriptionParams;
}
```

* Unsubscribe Ack Schema

See [`WsAccountUpdateSubscriptionResult`](/documentation/for-developers/api-reference/trading-api/rest-v1/schema.md#wsaccountupdatesubscriptionresult) in [Schema](/documentation/for-developers/api-reference/trading-api/rest-v1/schema.md).

```typescript
interface UnsubscriptionResult {
  op: "unsubscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  result: WsAccountUpdateSubscriptionResult | null;
  success: boolean; // Indicates if the request was successfully processed by the engine.
  connID: string;
  error: string | null; // Condition: If success is false. Error message.
  time_in: number; // The timestamp when the subscription was received on the wire, just prior to parsing data, in milliseconds.
  time_out: number; // The timestamp when the acknowledgement was sent on the wire, just prior to transmitting data, in milliseconds.
}
```

* Example: Unsubscribe

```json
{
  "op": "unsubscribe",
  "params": {
    "channel": "accountUpdate",
    "user": "0xed3e79ef16a7890e6eaef2aa6373b6bec5d59d5c"
  }
}
```

* Example: Unsubscribe Ack

```json
{
  "op": "unsubscribe",
  "result": {
    "channel": "accountUpdate",
    "user": "0xed3e79ef16a7890e6eaef2aa6373b6bec5d59d5c",
    "accountID": 1001
  },
  "success": true,
  "connID": "0xb0922dfe2b14dadb1195ea4db2b45508",
  "time_in": 1672515782130,
  "time_out": 1672515782136
}
```

## Update Response

* Update Schema

See [`WsSpotAccountUpdate`](/documentation/for-developers/api-reference/trading-api/rest-v1/schema.md#wsspotaccountupdate), [`WsPerpsAccountUpdate`](/documentation/for-developers/api-reference/trading-api/rest-v1/schema.md#wsperpsaccountupdate) in [Schema](/documentation/for-developers/api-reference/trading-api/rest-v1/schema.md).

```typescript
interface AccountUpdateResponse {
  channel: "accountUpdate";
  type: "update";
  data: WsSpotAccountUpdate | WsPerpsAccountUpdate;
}
```

* Example: Update

```json
{
  "channel": "accountUpdate",
  "type": "update",
  "data": {
    "E": 1766847039189,
    "h": 2211,
    "B": [
      { "i": 1, "a": "vBTC", "t": "10113.00266312", "l": "4.57789" },
      {
        "i": 0,
        "a": "vUSDC",
        "t": "999998045.21473685",
        "l": "1948375.89155815"
      },
      { "i": 2, "a": "vETH", "t": "287322.7167728536949776", "l": "115.0146" },
      {
        "i": 3,
        "a": "vPEPE",
        "t": "163666213677145.6235679214402619",
        "l": "90965473761"
      },
      {
        "i": 4,
        "a": "WSOSO",
        "t": "1355197181.1898631250846998",
        "l": "729242.63"
      }
    ],
    "TO": [
      {
        "s": "vETH_vUSDC",
        "i": 12001,
        "S": "BUY",
        "q": "0.5",
        "m": 10,
        "r": false,
        "R": false,
        "z": "0.1",
        "v": "350",
        "ct": 1766847039000,
        "nt": 1766847099000,
        "a": true
      }
    ]
  }
}
```
