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

***

# Events CLI Commands

Manage events in your EventCatalog from the command line.

## getEvent[​](#getevent "Direct link to getEvent")

Returns an event from EventCatalog by its ID

**Arguments:**

| Name    | Type   | Required | Description                                    |
| ------- | ------ | -------- | ---------------------------------------------- |
| id      | string | Yes      | The ID of the event to retrieve                |
| version | string | No       | Specific version to retrieve (supports semver) |
| options | json   | No       | Options object, e.g. {"attachSchema": true}    |

**Examples:**

```
# Get the latest version of an event
npx @eventcatalog/cli getEvent "OrderCreated"

# Get a specific version
npx @eventcatalog/cli getEvent "OrderCreated" "1.0.0"
```

***

## getEvents[​](#getevents "Direct link to getEvents")

Returns all events from EventCatalog

**Arguments:** None

**Examples:**

```
# Get all events
npx @eventcatalog/cli getEvents
```

***

## writeEvent[​](#writeevent "Direct link to writeEvent")

Writes an event to EventCatalog

**Arguments:**

| Name  | Type | Required | Description                                       |
| ----- | ---- | -------- | ------------------------------------------------- |
| event | json | Yes      | Event object with id, name, version, and markdown |

***

## writeEventToService[​](#writeeventtoservice "Direct link to writeEventToService")

Writes an event to a specific service in EventCatalog

**Arguments:**

| Name    | Type | Required | Description                                       |
| ------- | ---- | -------- | ------------------------------------------------- |
| event   | json | Yes      | Event object with id, name, version, and markdown |
| service | json | Yes      | Service reference: {id, version?}                 |
| options | json | No       | Options: {path?, format?, override?}              |

***

## rmEvent[​](#rmevent "Direct link to rmEvent")

Removes an event by its path

**Arguments:**

| Name | Type   | Required | Description                                |
| ---- | ------ | -------- | ------------------------------------------ |
| path | string | Yes      | Path to the event, e.g. /InventoryAdjusted |

**Examples:**

```
# Remove an event by path
npx @eventcatalog/cli rmEvent "/InventoryAdjusted"
```

***

## rmEventById[​](#rmeventbyid "Direct link to rmEventById")

Removes an event by its ID

**Arguments:**

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

**Examples:**

```
# Remove latest version
npx @eventcatalog/cli rmEventById "OrderCreated"

# Remove specific version
npx @eventcatalog/cli rmEventById "OrderCreated" "1.0.0"
```

***

## versionEvent[​](#versionevent "Direct link to versionEvent")

Moves the current event to a versioned directory

**Arguments:**

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

**Examples:**

```
# Version an event
npx @eventcatalog/cli versionEvent "OrderCreated"
```

***

## addFileToEvent[​](#addfiletoevent "Direct link to addFileToEvent")

Adds a file to an event

**Arguments:**

| Name    | Type   | Required | Description                      |
| ------- | ------ | -------- | -------------------------------- |
| id      | string | Yes      | The ID of the event              |
| file    | json   | Yes      | File object: {content, fileName} |
| version | string | No       | Specific version to add file to  |

***

## addSchemaToEvent[​](#addschematoevent "Direct link to addSchemaToEvent")

Adds a schema file to an event

**Arguments:**

| Name    | Type   | Required | Description                       |
| ------- | ------ | -------- | --------------------------------- |
| id      | string | Yes      | The ID of the event               |
| schema  | json   | Yes      | Schema object: {schema, fileName} |
| version | string | No       | Specific version to add schema to |

***

## eventHasVersion[​](#eventhasversion "Direct link to eventHasVersion")

Checks if a specific version of an event exists

**Arguments:**

| Name    | Type   | Required | Description                        |
| ------- | ------ | -------- | ---------------------------------- |
| id      | string | Yes      | The ID of the event                |
| version | string | Yes      | Version to check (supports semver) |

**Examples:**

```
# Check if version exists
npx @eventcatalog/cli eventHasVersion "OrderCreated" "1.0.0"

# Check with semver range
npx @eventcatalog/cli eventHasVersion "OrderCreated" "1.0.x"
```

***
