Available languages: [Python](https://databento.com/docs/api-live/message-flows/unsubscription.python.md) · [C++](https://databento.com/docs/api-live/message-flows/unsubscription.cpp.md) · [Rust](https://databento.com/docs/api-live/message-flows/unsubscription.rust.md) · [Raw](https://databento.com/docs/api-live/message-flows/unsubscription.raw.md)

Source: https://databento.com/docs/api-live/message-flows/unsubscription


# Unsubscribing

To remove symbols from the session's subscriptions, the client sends an
[unsubscribe request](https://databento.com/docs/api-live/client-control-messages/unsubscribe-request.md) to the gateway.

An unsubscribe request applies to a single schema. It doesn't need to match an earlier subscription:
any subset of the subscribed symbols can be removed, and `symbols=ALL_SYMBOLS` removes every symbol for the schema.
Unsubscribe requests can be sent before or after the session is [started](https://databento.com/docs/api-live/message-flows/start-session.md).

The gateway acknowledges each unsubscribe request with a [system message](https://databento.com/docs/api-live/basics/system-messages.md) with `code=UNSUBSCRIBE_ACK`.
If the request is sent before the session is started, the acknowledgement is sent after the session starts, following the DBN metadata.

Symbols that aren't subscribed, or that are only subscribed through a parent symbol, are left in place and reported in an [`ErrorMsg`](https://databento.com/docs/api-live/basics/errors.md).
These errors don't end the session.

## Example

After subscribing to trades for the E-mini S&P 500 and E-mini Nasdaq-100 December 2026 futures and starting the session:

`schema=trades|stype_in=raw_symbol|symbols=ESZ6,NQZ6\n`

`start_session=1\n`

to stop receiving trades for NQZ6, the client would send:

`unsubscribe|schema=trades|stype_in=raw_symbol|symbols=NQZ6\n`

The gateway will acknowledge the request with an `UNSUBSCRIBE_ACK` system message and continue streaming trades for ESZ6.
