# Channel reference

> Channel properties, data types, name rules, and error messages.

This page lists the properties of a [channel](https://docs.synnaxlabs.com/reference/channels), the data types that it can have, and the errors that channel operations can return.

## Properties

* [Key](https://docs.synnaxlabs.com/reference/channels/reference#key)`number`

  A number that identifies the channel. Synnax sets the key when you create the channel, and the key never changes. Plots, schematics, and tasks refer to channels by key.

  Field `key`Cannot change

* [Name](https://docs.synnaxlabs.com/reference/channels/reference#name)`string`\* Required

  The name of the channel. It must follow the [name rules](https://docs.synnaxlabs.com/reference/channels/reference#name-rules). To change it, [rename the channel](https://docs.synnaxlabs.com/reference/channels/rename-and-delete#rename-channels).

  Field `name`Can change

* [Data type](https://docs.synnaxlabs.com/reference/channels/reference#data-type)`string`\* Required

  The type of each sample in the channel. See [data types](https://docs.synnaxlabs.com/reference/channels/reference#data-types). An index channel always has the `timestamp` data type. In Python, `is_index=True` sets `timestamp` for you.

  Python `data_type`TypeScript `dataType`Cannot change

* [Is index](https://docs.synnaxlabs.com/reference/channels/reference#is-index)`boolean = false`

  `true` for an [index channel](https://docs.synnaxlabs.com/reference/channels#index-channels). An index channel cannot be virtual.

  Python `is_index`TypeScript `isIndex`Cannot change

* [Index](https://docs.synnaxlabs.com/reference/channels/reference#index)`number`

  The key of the index channel that holds the timestamps of this channel. Each data channel needs an index, and the index must exist before you create the data channel. Leave it unset for index, virtual, and calculated channels.

  Field `index`Cannot change

* [Virtual](https://docs.synnaxlabs.com/reference/channels/reference#virtual)`boolean = false`

  `true` for a [virtual channel](https://docs.synnaxlabs.com/reference/channels#virtual-channels). Synnax streams the values of a virtual channel and does not store them. A calculated channel also has `virtual` set to `true`, because Synnax does not store its values.

  Field `virtual`Cannot change

## Calculated channel properties

A [calculated channel](https://docs.synnaxlabs.com/reference/channels/calculated) has a name and the properties below. Synnax sets its data type, its index, and its `virtual` property. You can change all of these properties after you create the channel.

* [Expression](https://docs.synnaxlabs.com/reference/channels/reference#expression)`string`\* Required

  The [Arc](https://docs.synnaxlabs.com/reference/control/arc) expression that computes each value. See [write an expression](https://docs.synnaxlabs.com/reference/channels/calculated#write-an-expression).

  Field `expression`

* [Operations](https://docs.synnaxlabs.com/reference/channels/reference#operations)`list of operations`

  The [operations](https://docs.synnaxlabs.com/reference/channels/reference#operation-properties) that Synnax applies to the result of the expression. The Console sets one operation. The client libraries accept a list, and Synnax applies the operations in order.

  Console **Operation**Field `operations`

### Operation properties

* [Type](https://docs.synnaxlabs.com/reference/channels/reference#type)`string`\* Required

  `min`, `max`, `avg`, `derivative`, or `none`.

  Console **Operation**Field `type`

* [Window](https://docs.synnaxlabs.com/reference/channels/reference#window)`TimeSpan = 0`

  The time after which `min`, `max`, or `avg` resets, in seconds in the Console. `0` never resets.

  Field `duration`

* [Reset channel](https://docs.synnaxlabs.com/reference/channels/reference#reset-channel)`number = 0`

  The key of a `boolean` channel. `min`, `max`, or `avg` resets when this channel receives `true`, and `0` means no reset channel.

  Python `reset_channel`TypeScript `resetChannel`

## Data types

| Data type   | Size     | Arc type | Description                                                         |
| ----------- | -------- | -------- | ------------------------------------------------------------------- |
| `boolean`   | 1 byte   | `bool`   | `true` or `false`.                                                  |
| `int8`      | 1 byte   | `i8`     | Signed 8-bit integer.                                               |
| `int16`     | 2 bytes  | `i16`    | Signed 16-bit integer.                                              |
| `int32`     | 4 bytes  | `i32`    | Signed 32-bit integer.                                              |
| `int64`     | 8 bytes  | `i64`    | Signed 64-bit integer.                                              |
| `uint8`     | 1 byte   | `u8`     | Unsigned 8-bit integer.                                             |
| `uint16`    | 2 bytes  | `u16`    | Unsigned 16-bit integer.                                            |
| `uint32`    | 4 bytes  | `u32`    | Unsigned 32-bit integer.                                            |
| `uint64`    | 8 bytes  | `u64`    | Unsigned 64-bit integer.                                            |
| `float32`   | 4 bytes  | `f32`    | 32-bit floating-point number.                                       |
| `float64`   | 8 bytes  | `f64`    | 64-bit floating-point number.                                       |
| `timestamp` | 8 bytes  | `i64`    | Nanoseconds since the Unix epoch, in UTC.                           |
| `uuid`      | 16 bytes | `str`    | A [UUID](https://www.rfc-editor.org/rfc/rfc9562.html).              |
| `string`    | Variable | `str`    | UTF-8 text.                                                         |
| `json`      | Variable | `str`    | A JSON value.                                                       |
| `bytes`     | Variable | None     | Raw bytes. Arc automations and calculated channels cannot use them. |

All data types can be stored, and all can be virtual. Only `timestamp` can be the data type of an index channel.

## Name rules

* A name contains only letters, digits, and underscores.
* A name cannot start with a digit.
* Each name is unique. Names are case-sensitive, so `tank_pressure` and `Tank_pressure` are two different names.

An administrator can turn off these rules on a Core with the [`--disable-channel-name-validation`](https://docs.synnaxlabs.com/reference/enterprise/cli-reference#flags) flag. Then names can have any characters, and two channels can have the same name.

## Errors

### Names

* [channel with name '\<name>' already exists](https://docs.synnaxlabs.com/reference/channels/reference#channel-with-name-name-already-exists)

  * Cause

    Another channel has this name.

  * Fix

    Select a different name.

* [channel name '\<name>' contains invalid characters](https://docs.synnaxlabs.com/reference/channels/reference#channel-name-name-contains-invalid-characters)

  * Cause

    The name does not follow the [name rules](https://docs.synnaxlabs.com/reference/channels/reference#name-rules).

  * Fix

    Change the name to follow the name rules.

### Indexes

* [non-indexed channel must have an index](https://docs.synnaxlabs.com/reference/channels/reference#non-indexed-channel-must-have-an-index)

  * Cause

    A data channel has no index.

  * Fix

    Set its index, or make it virtual.

* [virtual channel cannot be indexed](https://docs.synnaxlabs.com/reference/channels/reference#virtual-channel-cannot-be-indexed)

  * Cause

    A virtual channel has an index, or is an index.

  * Fix

    Remove the index setting.

* [index channel with key \<key> does not exist](https://docs.synnaxlabs.com/reference/channels/reference#index-channel-with-key-key-does-not-exist)

  * Cause

    The index does not exist.

  * Fix

    Create the index channel first.

* [channel \<key> is not an index](https://docs.synnaxlabs.com/reference/channels/reference#channel-key-is-not-an-index)

  * Cause

    The index setting points to a channel that is not an index channel.

  * Fix

    Set the index to an index channel.

### Calculated channels

* [calculated channels cannot specify an index manually](https://docs.synnaxlabs.com/reference/channels/reference#calculated-channels-cannot-specify-an-index-manually)

  * Cause

    A calculated channel has an index setting.

  * Fix

    Remove the index setting. Synnax creates the index.

* [undefined symbol: \<name>](https://docs.synnaxlabs.com/reference/channels/reference#undefined-symbol-name)

  * Cause

    An expression uses a channel name that does not exist.

  * Fix

    Correct the name, or create the channel.

### Delete

* [cannot delete channel \<index> because channel \<data> uses it as its index](https://docs.synnaxlabs.com/reference/channels/reference#index-in-use)

  * Cause

    Data channels use this index.

  * Fix

    Delete them first, or in the same call.

* [cannot delete channel \<name> because task \<task> uses it](https://docs.synnaxlabs.com/reference/channels/reference#task-uses-channel)

  * Cause

    A hardware task reads or writes the channel.

  * Fix

    Remove the channel from the task, or delete the task. Then delete the channel.

* [there are \<n> unclosed writers/iterators accessing it](https://docs.synnaxlabs.com/reference/channels/reference#there-are-n-unclosed-writers-iterators-accessing-it)

  * Cause

    A task or a script has the channel open.

  * Fix

    Stop the task or the script, then delete the channel.

### Find

* [NotFoundError](https://docs.synnaxlabs.com/reference/channels/reference#notfounderror)

  * Cause

    No channel matches the name or key.

  * Fix

    Check the name or key. Names are case-sensitive.
