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

***

# Diagrams CLI Commands

Manage diagrams in your EventCatalog from the command line.

## getDiagram[​](#getdiagram "Direct link to getDiagram")

Returns a diagram from EventCatalog by its ID

**Arguments:**

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

**Examples:**

```
# Get the latest diagram
npx @eventcatalog/cli getDiagram "ArchitectureDiagram"

# Get a specific version
npx @eventcatalog/cli getDiagram "ArchitectureDiagram" "1.0.0"
```

***

## getDiagrams[​](#getdiagrams "Direct link to getDiagrams")

Returns all diagrams from EventCatalog

**Arguments:**

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

**Examples:**

```
# Get all diagrams
npx @eventcatalog/cli getDiagrams
```

***

## writeDiagram[​](#writediagram "Direct link to writeDiagram")

Writes a diagram to EventCatalog

**Arguments:**

| Name    | Type | Required | Description                                          |
| ------- | ---- | -------- | ---------------------------------------------------- |
| options | json | No       | Options: {path?, override?, versionExistingContent?} |

***

## rmDiagram[​](#rmdiagram "Direct link to rmDiagram")

Removes a diagram by its path

**Arguments:**

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

**Examples:**

```
# Remove a diagram
npx @eventcatalog/cli rmDiagram "/ArchitectureDiagram"
```

***

## rmDiagramById[​](#rmdiagrambyid "Direct link to rmDiagramById")

Removes a diagram by its ID

**Arguments:**

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

**Examples:**

```
# Remove a diagram
npx @eventcatalog/cli rmDiagramById "ArchitectureDiagram"
```

***

## versionDiagram[​](#versiondiagram "Direct link to versionDiagram")

Moves the current diagram to a versioned directory

**Arguments:**

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

**Examples:**

```
# Version a diagram
npx @eventcatalog/cli versionDiagram "ArchitectureDiagram"
```

***

## addFileToDiagram[​](#addfiletodiagram "Direct link to addFileToDiagram")

Adds a file to a diagram

**Arguments:**

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

***

## diagramHasVersion[​](#diagramhasversion "Direct link to diagramHasVersion")

Checks if a specific version of a diagram exists

**Arguments:**

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

***
