> ## Documentation Index
> Fetch the complete documentation index at: https://docs.struct.to/llms.txt
> Use this file to discover all available pages before exploring further.

# Accounts

> Stream share balance, USDCe, pUSD, and MATIC updates for tracked wallets.

<Note>
  **Room ID:** `polymarket_accounts` \
  **Endpoint:** `wss://api.struct.to/ws` \
  **Rate:** 0.005 credits per message
</Note>

Stream share balance, USDCe (V1 collateral), pUSD (V2 CLOB collateral), and MATIC updates for tracked wallets. By default only share balance updates are delivered. Enable `include_usdce`, `include_pusd`, and `include_matic` to receive those balance types as well.

## Subscribe

The `wallets` filter is required. Optionally enable USDCe, pUSD, and MATIC balance updates with the boolean flags.

### Filters

| Filter          | Type       | Required | Description                                                                                                                                            |
| --------------- | ---------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `wallets`       | `string[]` | Yes      | Wallet addresses to track (0x-prefixed)                                                                                                                |
| `include_usdce` | `boolean`  | No       | Include USDCe collateral balance updates, V1 (default: false)                                                                                          |
| `include_pusd`  | `boolean`  | No       | Include pUSD collateral balance updates, V2 CLOB (default: false)                                                                                      |
| `include_matic` | `boolean`  | No       | Include MATIC gas balance updates (default: false)                                                                                                     |
| `subscribe_all` | `boolean`  | No       | Firehose: receive balance updates for every wallet. The `wallets` filter is ignored when set; the `include_*` flags still gate the extra token streams |

### Example

```json theme={null}
{
  "type": "join_room",
  "payload": {
    "room_id": "polymarket_accounts"
  }
}
```

```json theme={null}
{
  "type": "room_message",
  "payload": {
    "room_id": "polymarket_accounts",
    "message": {
      "action": "subscribe",
      "wallets": ["0x1234567890abcdef1234567890abcdef12345678"],
      "include_usdce": true,
      "include_pusd": true,
      "include_matic": true
    }
  }
}
```

### Response

```json theme={null}
{
  "type": "accounts_stream_subscribe_response",
  "room_id": "polymarket_accounts",
  "data": {
    "wallets": ["0x1234567890abcdef1234567890abcdef12345678"],
    "rejected": [],
    "include_usdce": true,
    "include_pusd": true,
    "include_matic": true
  }
}
```

## Events

### `accounts_update`

Share balance update for a tracked wallet.

```json theme={null}
{
  "type": "accounts_update",
  "room_id": "polymarket_accounts",
  "data": {
    "wallet": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    "position_id": "12345678901234567",
    "balance": "500.000000",
    "block_number": 65000000,
    "updated_at": 1743500000,
    "condition_id": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "event_slug": "bitcoin-price-markets"
  }
}
```

### `usdce_update`

USDCe (V1) collateral balance update for a tracked wallet.

```json theme={null}
{
  "type": "usdce_update",
  "room_id": "polymarket_accounts",
  "data": {
    "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    "token_address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
    "balance": "10250.500000",
    "block_number": 65000000,
    "updated_at": 1743500000
  }
}
```

### `pusd_update`

pUSD (V2 CLOB) collateral balance update for a tracked wallet.

```json theme={null}
{
  "type": "pusd_update",
  "room_id": "polymarket_accounts",
  "data": {
    "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    "token_address": "0xc011a7E12A19f7B1F670D46F03b03f3342e82DfB",
    "balance": "10250.500000",
    "block_number": 65000000,
    "updated_at": 1743500000
  }
}
```

### `matic_update`

MATIC balance update for a tracked wallet.

```json theme={null}
{
  "type": "matic_update",
  "room_id": "polymarket_accounts",
  "data": {
    "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    "token_address": "0x0000000000000000000000000000000000001010",
    "balance": "25.750000000000000000",
    "block_number": 65000000,
    "updated_at": 1743500000
  }
}
```
