---
title: "Cancel status stream"
description: "Stream the outcome of your cancel requests."
---

| | |
|---|---|
| SDK | `client.cancel_status_stream(...)` |
| Channel | `v1.cancel` on `wss://trades.<domain>/ws/full`, or `/ws/lite` for [lite names](../../guides/environments.md#encoding-full-or-lite) (the SDKs' default) |
| Selector | `<sub_account_id>` |
| Auth | Session required on the WebSocket upgrade ([Authentication](../../guides/authentication.md)) |
| Kind | `event`. Each frame is one event (an update to one object). |
| Sequenced | Yes: the first update's `prev_sequence_number` is at or below the subscribe reply's `latest_sequence_number`, then each one equals the last `sequence_number` ([rules](../../guides/websocket.md#sequence-numbers-and-gaps)). On a gap, re-subscribe, then fetch current state over HTTP ([`open_orders`](../rpc/open_orders.md), [`order_history`](../rpc/order_history.md)) for what you missed. |
| Contract id | `order.cancel_status` (`StreamCancelStatusV1`) |

## Selector

Grammar `<sub_account_id>`, e.g. `<sub_account_id>`. Parts:

- `sub_account_id` · uint64 — The sub-account ID to filter by

## Frame

Type `WSCancelFeedDataV1`.

- `stream` · lite `s` · string · required — The stream this frame belongs to, e.g. `v1.cancel`.
- `selector` · lite `s1` · string · required — The selector this frame is for, as you subscribed with it.
- `sequence_number` · lite `sn` · string (uint64) · required — This frame's number, an unsigned 64-bit integer sent as a decimal string: compare it as an integer. `"0"` on the snapshot sent right after subscribing.
  - With `use_global_sequence_number: true` (recommended), the number is unique across the exchange. One exchange event can produce several frames, so the number is `event number × 10^5 + a counter` that tells them apart.
  - With `false`, it counts up by one per frame of this stream and starts again when the server you are connected to restarts.
- `feed` · lite `f` · object CancelStatusFeed · required — Data relating to the status of the cancellation attempt
- `feed.sub_account_id` · lite `sa` · string (uint64) · required — The sub-account ID that requested the cancellation
- `feed.client_order_id` · lite `co` · string (uint64) · required — A unique identifier for the active order within a sub-account, specified by the client
- `feed.order_id` · lite `oi` · string (uint128) · required — The exchange's 128-bit id for the order.
- `feed.reason` · lite `r` · enum OrderRejectReason · required — The user-provided reason for cancelling the order
  Values: `UNSPECIFIED`, `CLIENT_CANCEL`, `CLIENT_BULK_CANCEL`, `CLIENT_SESSION_END`, `MARKET_CANCEL`, `IOC_CANCEL`, `AON_CANCEL`, `FOK_CANCEL`, `EXPIRED`, `FAIL_POST_ONLY`, `FAIL_REDUCE_ONLY`, `MM_PROTECTION`, `SELF_TRADE_PROTECTION`, `SELF_MATCHED_SUBACCOUNT`, `OVERLAPPING_CLIENT_ORDER_ID`, `BELOW_MARGIN`, `LIQUIDATION`, `INSTRUMENT_INVALID`, `INSTRUMENT_DEACTIVATED`, `SYSTEM_FAILOVER`, `UNAUTHORISED`, `SESSION_KEY_EXPIRED`, `SUB_ACCOUNT_NOT_FOUND`, `NO_TRADE_PERMISSION`, `UNSUPPORTED_TIME_IN_FORCE`, `MULTI_LEGGED_ORDER`, `EXCEED_MAX_POSITION_SIZE`, `EXCEED_MAX_SIGNATURE_EXPIRATION`, `MARKET_ORDER_WITH_LIMIT_PRICE`, `CLIENT_CANCEL_ON_DISCONNECT_TRIGGERED`, `OCO_COUNTER_PART_TRIGGERED`, `REDUCE_ONLY_LIMIT`, `CLIENT_REPLACE`, `DERISK_MUST_BE_IOC`, `DERISK_MUST_BE_REDUCE_ONLY`, `DERISK_NOT_SUPPORTED`, `INVALID_ORDER_TYPE`, `CURRENCY_NOT_DEFINED`, `INVALID_CHAIN_ID`, `BUILDER_ORDER_FEE_EXCEED`, `BUILDER_ORDER_FEE_NEGATIVE`, `BUILDER_ORDER_BUILDER_NOT_AUTHORIZED`, `BUILDER_ORDER_BUILDER_NOT_EXIST`, `TRADE_PRICE_WORSE_THAN_BANKRUPTCY_PRICE`, `TOO_MANY_MAKER_ORDERS`, `REDUCE_ONLY_NOT_SUPPORTED_FOR_SPOT_ORDER`, `TPSL_NOT_SUPPORTED_FOR_SPOT_ORDER`, `SPOT_ORDER_NOT_SUPPORTED`, `INSUFFICIENT_BALANCE`, `SPOT_TRADING_BLOCKED_DURING_SOCIALIZED_LOSS`, `BELOW_MARGIN_WITH_PENALTY_DEVIATION`, `CORPORATE_ACTION`, `NOT_QUALIFIED_MAKER`, `PRIVATE_QUOTE_REQUIRES_RFQ`, `STABLE_PERP_REQUIRES_PRICE_BOUND`, `UNSUPPORTED_TRIGGER_BY`, `RFQ_NOT_FOUND`, `RESTING_ORDER_WOULD_CROSS`, `SESSION_CLOSED`, `RFQ_TERMINATED`, `STABLE_PERP_REQUIRES_MULTI_ASSET_MODE`, `BORROW_LIMIT_EXCEEDED_AFTER_TRADE`, `UNDEPLOYED_LOAN_AUTO_EXCHANGE`, `LIQUIDATION_AUTO_EXCHANGE`, `USDC_COLLATERAL_DISABLED`, `SFP_POST_ONLY_NOT_ALLOWED`, `VAULT_NON_QUOTE_INVESTMENT_CURRENCY`, `RFQ_ID_REQUIRES_STABLE_PERP`, `RFQ_PRIVATE_POOL_NOT_SUPPORTED`, `RFQ_REQUIRES_IOC`, `RFQ_MISMATCH`, `RFQ_ALREADY_BOUND`, `RFQ_MAKER_MUST_BE_ECN`, `FOK_NOT_SUPPORTED`, `MARKET_ORDER_NOT_SUPPORTED`, `STABLE_PERP_ORDER_NOT_SUPPORTED` ([details](../enums.md#orderrejectreason)).
- `feed.update_time` · lite `ut` · string (int64 unix ns) · optional, default `0` — Set by the server. Time at which the cancellation status was updated by Grvt in unix nanoseconds
- `feed.cancel_status` · lite `cs` · enum CancelStatus · required — Status of the cancellation attempt
  Values: `EXPIRED`, `DROPPED_DUPLICATE` ([details](../enums.md#cancelstatus)).
- `prev_sequence_number` · lite `ps` · string (uint64) · required — The `sequence_number` of the frame before this one on this selector. If it doesn't match the last frame you accepted, you missed frames.

## Errors

Subscribe errors arrive as a JSON-RPC `error` object `{code, message}` (lite `{c, m}`). Codes this stream can return ([all error codes](../errors.md)):

`1000` Unauthorized (401) · `1001` Forbidden (403) · `1002` InternalServer (500) · `1008` IPNotWhitelisted (401) · `1101` InvalidFeedFormat (400) · `1102` PrimarySelectorParts (400) · `1103` SecondarySelectorParts (400) · `3000` InvalidInstrument (400) · `3020` InvalidSubAccountID (400)

## Example

```python
import asyncio
import os

from grvt import AsyncGrvt


async def main():
    async with AsyncGrvt(env=os.environ.get("GRVT_ENV", "testnet"), api_key=os.environ["GRVT_API_KEY"]) as client:
        async with client.cancel_status_stream(sub_account_id=os.environ["GRVT_SUB_ACCOUNT_ID"]) as sub:
            async for frame in sub:
                print(frame.sequence_number, frame.feed)


asyncio.run(main())
```

Raw WebSocket: connect to `wss://trades.$GRVT_DOMAIN/ws/full` (`/ws/lite` for lite names) with the `Cookie: gravity=...` and `X-Grvt-Account-Id` headers and send:

With full field names:

```json
{
  "jsonrpc": "2.0",
  "method": "subscribe",
  "params": {
    "stream": "v1.cancel",
    "selectors": ["$GRVT_SUB_ACCOUNT_ID"],
    "use_global_sequence_number": true
  },
  "id": 1
}
```

With lite field names:

```json
{
  "j": "2.0",
  "m": "subscribe",
  "p": {
    "s": "v1.cancel",
    "s1": ["$GRVT_SUB_ACCOUNT_ID"],
    "ug": true
  },
  "i": 1
}
```

The reply's `result` is a `WSSubscribeResult` (`subs`, `num_snapshots`, `latest_sequence_number`); then frames arrive in the shape under Frame above, with no JSON-RPC envelope.
