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

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


### Unsubscription

The parameter struct and builder for [LiveClient::unsubscribe](https://databento.com/docs/api-live/client/unsubscribe.md).

The builder can be instantiated with the associated function `builder()`, and the struct is created from the builder with the `build()` method.
For every field except `sent_at`, there is an identically named setter method on the builder.

An `Unsubscription` can also be created from a [Subscription](https://databento.com/docs/api-live/helpers/subscription.md) with `Subscription::to_unsubscription()` or `Unsubscription::from(&subscription)`.

#### API method

```rust
pub struct Unsubscription {
    pub symbols: Symbols,
    pub schema: Schema,
    pub stype_in: SType,
    pub sent_at: OffsetDateTime,
}
```

#### Fields

| Parameter | Type | Description |
| `symbols` | Symbols | The symbols of the instruments to unsubscribe from. `Symbols::All` removes every symbol for the schema. |
| `schema` | Schema | The data record [schema](https://databento.com/docs/schemas/whats-a-schema.md) to unsubscribe from. |
| `stype_in` | SType | The [symbology type](https://databento.com/docs/api-live/basics/symbology.md) of input `symbols`. Must be `SType::RawSymbol`, `SType::Parent`, or `SType::InstrumentId`. Defaults to `SType::RawSymbol`. |
| `sent_at` | OffsetDateTime | When the unsubscription was last sent to the gateway. Set by the client and used by [LiveClient::resubscribe](https://databento.com/docs/api-live/client/resubscribe.md) to replay subscriptions and unsubscriptions in order. Defaults to `OffsetDateTime::UNIX_EPOCH` until sent. |

#### Example usage

```rust
use databento::{
    dbn::{SType, Schema},
    live::{Subscription, Unsubscription},
};

let unsubscription = Unsubscription::builder()
    .symbols(vec!["AAPL", "MSFT"])
    .schema(Schema::Tbbo)
    .build();
assert_eq!(unsubscription.stype_in, SType::RawSymbol);

let subscription = Subscription::builder()
    .symbols(vec!["AAPL", "MSFT"])
    .schema(Schema::Tbbo)
    .build();
assert_eq!(subscription.to_unsubscription(), unsubscription);
```
