Copy as Markdown[View as Markdown](/docs/cli/cli-channels.md)

***

# Channels CLI Commands

Manage channels in your EventCatalog from the command line.

## getChannel[​](#getchannel "Direct link to getChannel")

Returns a channel from EventCatalog by its ID

**Arguments:**

| Name    | Type   | Required | Description                       |
| ------- | ------ | -------- | --------------------------------- |
| id      | string | Yes      | The ID of the channel to retrieve |
| version | string | No       | Specific version to retrieve      |

**Examples:**

```
# Get the latest channel
npx @eventcatalog/cli getChannel "orders.events"

# Get a specific version
npx @eventcatalog/cli getChannel "orders.events" "1.0.0"
```

***

## getChannels[​](#getchannels "Direct link to getChannels")

Returns all channels from EventCatalog

**Arguments:**

| Name    | Type | Required | Description            |
| ------- | ---- | -------- | ---------------------- |
| options | json | No       | Options: {latestOnly?} |

**Examples:**

```
# Get all channels
npx @eventcatalog/cli getChannels
```

***

## writeChannel[​](#writechannel "Direct link to writeChannel")

Writes a channel to EventCatalog

**Arguments:**

| Name    | Type | Required | Description                                         |
| ------- | ---- | -------- | --------------------------------------------------- |
| channel | json | Yes      | Channel object with id, name, version, and markdown |
| options | json | No       | Options: {path?, override?}                         |

***

## rmChannel[​](#rmchannel "Direct link to rmChannel")

Removes a channel by its path

**Arguments:**

| Name | Type   | Required | Description         |
| ---- | ------ | -------- | ------------------- |
| path | string | Yes      | Path to the channel |

**Examples:**

```
# Remove a channel
npx @eventcatalog/cli rmChannel "/orders.events"
```

***

## rmChannelById[​](#rmchannelbyid "Direct link to rmChannelById")

Removes a channel by its ID

**Arguments:**

| Name    | Type   | Required | Description                     |
| ------- | ------ | -------- | ------------------------------- |
| id      | string | Yes      | The ID of the channel to remove |
| version | string | No       | Specific version to remove      |

**Examples:**

```
# Remove a channel
npx @eventcatalog/cli rmChannelById "orders.events"
```

***

## versionChannel[​](#versionchannel "Direct link to versionChannel")

Moves the current channel to a versioned directory

**Arguments:**

| Name | Type   | Required | Description                      |
| ---- | ------ | -------- | -------------------------------- |
| id   | string | Yes      | The ID of the channel to version |

**Examples:**

```
# Version a channel
npx @eventcatalog/cli versionChannel "orders.events"
```

***

## addEventToChannel[​](#addeventtochannel "Direct link to addEventToChannel")

Adds an event to a channel

**Arguments:**

| Name      | Type   | Required | Description                                 |
| --------- | ------ | -------- | ------------------------------------------- |
| channelId | string | Yes      | The ID of the channel                       |
| event     | json   | Yes      | Event reference: {id, version, parameters?} |

***

## addCommandToChannel[​](#addcommandtochannel "Direct link to addCommandToChannel")

Adds a command to a channel

**Arguments:**

| Name      | Type   | Required | Description                                   |
| --------- | ------ | -------- | --------------------------------------------- |
| channelId | string | Yes      | The ID of the channel                         |
| command   | json   | Yes      | Command reference: {id, version, parameters?} |

***

## addQueryToChannel[​](#addquerytochannel "Direct link to addQueryToChannel")

Adds a query to a channel

**Arguments:**

| Name      | Type   | Required | Description                                 |
| --------- | ------ | -------- | ------------------------------------------- |
| channelId | string | Yes      | The ID of the channel                       |
| query     | json   | Yes      | Query reference: {id, version, parameters?} |

***

## channelHasVersion[​](#channelhasversion "Direct link to channelHasVersion")

Checks if a specific version of a channel exists

**Arguments:**

| Name    | Type   | Required | Description           |
| ------- | ------ | -------- | --------------------- |
| id      | string | Yes      | The ID of the channel |
| version | string | Yes      | Version to check      |

**Examples:**

```
# Check if version exists
npx @eventcatalog/cli channelHasVersion "orders.events" "1.0.0"
```

***
