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

***

# Domains CLI Commands

Manage domains in your EventCatalog from the command line.

## getDomain[​](#getdomain "Direct link to getDomain")

Returns a domain from EventCatalog by its ID

**Arguments:**

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

**Examples:**

```
# Get the latest domain
npx @eventcatalog/cli getDomain "Orders"

# Get a specific version
npx @eventcatalog/cli getDomain "Orders" "1.0.0"
```

***

## getDomains[​](#getdomains "Direct link to getDomains")

Returns all domains from EventCatalog

**Arguments:**

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

**Examples:**

```
# Get all domains
npx @eventcatalog/cli getDomains
```

***

## writeDomain[​](#writedomain "Direct link to writeDomain")

Writes a domain to EventCatalog

**Arguments:**

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

***

## rmDomain[​](#rmdomain "Direct link to rmDomain")

Removes a domain by its path

**Arguments:**

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

**Examples:**

```
# Remove a domain
npx @eventcatalog/cli rmDomain "/Orders"
```

***

## rmDomainById[​](#rmdomainbyid "Direct link to rmDomainById")

Removes a domain by its ID

**Arguments:**

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

**Examples:**

```
# Remove a domain
npx @eventcatalog/cli rmDomainById "Orders"
```

***

## versionDomain[​](#versiondomain "Direct link to versionDomain")

Moves the current domain to a versioned directory

**Arguments:**

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

**Examples:**

```
# Version a domain
npx @eventcatalog/cli versionDomain "Orders"
```

***

## addFileToDomain[​](#addfiletodomain "Direct link to addFileToDomain")

Adds a file to a domain

**Arguments:**

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

***

## addServiceToDomain[​](#addservicetodomain "Direct link to addServiceToDomain")

Adds a service to a domain

**Arguments:**

| Name          | Type   | Required | Description                      |
| ------------- | ------ | -------- | -------------------------------- |
| domainId      | string | Yes      | The ID of the domain             |
| service       | json   | Yes      | Service reference: {id, version} |
| domainVersion | string | No       | Specific domain version          |

***

## addSubDomainToDomain[​](#addsubdomaintodomain "Direct link to addSubDomainToDomain")

Adds a subdomain to a domain

**Arguments:**

| Name          | Type   | Required | Description                        |
| ------------- | ------ | -------- | ---------------------------------- |
| domainId      | string | Yes      | The ID of the parent domain        |
| subDomain     | json   | Yes      | Subdomain reference: {id, version} |
| domainVersion | string | No       | Specific domain version            |

***

## addEntityToDomain[​](#addentitytodomain "Direct link to addEntityToDomain")

Adds an entity to a domain

**Arguments:**

| Name          | Type   | Required | Description                     |
| ------------- | ------ | -------- | ------------------------------- |
| domainId      | string | Yes      | The ID of the domain            |
| entity        | json   | Yes      | Entity reference: {id, version} |
| domainVersion | string | No       | Specific domain version         |

***

## addEventToDomain[​](#addeventtodomain "Direct link to addEventToDomain")

Adds an event relationship to a domain

**Arguments:**

| Name          | Type   | Required | Description                      |
| ------------- | ------ | -------- | -------------------------------- |
| domainId      | string | Yes      | The ID of the domain             |
| direction     | string | Yes      | Direction: "sends" or "receives" |
| event         | json   | Yes      | Event reference: {id, version}   |
| domainVersion | string | No       | Specific domain version          |

***

## addCommandToDomain[​](#addcommandtodomain "Direct link to addCommandToDomain")

Adds a command relationship to a domain

**Arguments:**

| Name          | Type   | Required | Description                      |
| ------------- | ------ | -------- | -------------------------------- |
| domainId      | string | Yes      | The ID of the domain             |
| direction     | string | Yes      | Direction: "sends" or "receives" |
| command       | json   | Yes      | Command reference: {id, version} |
| domainVersion | string | No       | Specific domain version          |

***

## addQueryToDomain[​](#addquerytodomain "Direct link to addQueryToDomain")

Adds a query relationship to a domain

**Arguments:**

| Name          | Type   | Required | Description                      |
| ------------- | ------ | -------- | -------------------------------- |
| domainId      | string | Yes      | The ID of the domain             |
| direction     | string | Yes      | Direction: "sends" or "receives" |
| query         | json   | Yes      | Query reference: {id, version}   |
| domainVersion | string | No       | Specific domain version          |

***

## addUbiquitousLanguageToDomain[​](#addubiquitouslanguagetodomain "Direct link to addUbiquitousLanguageToDomain")

Adds ubiquitous language definitions to a domain

**Arguments:**

| Name          | Type   | Required | Description                         |
| ------------- | ------ | -------- | ----------------------------------- |
| domainId      | string | Yes      | The ID of the domain                |
| dictionary    | json   | Yes      | Array of {term, definition} objects |
| domainVersion | string | No       | Specific domain version             |

***

## getUbiquitousLanguageFromDomain[​](#getubiquitouslanguagefromdomain "Direct link to getUbiquitousLanguageFromDomain")

Gets ubiquitous language definitions from a domain

**Arguments:**

| Name          | Type   | Required | Description             |
| ------------- | ------ | -------- | ----------------------- |
| domainId      | string | Yes      | The ID of the domain    |
| domainVersion | string | No       | Specific domain version |

**Examples:**

```
# Get ubiquitous language
npx @eventcatalog/cli getUbiquitousLanguageFromDomain "Orders"
```

***

## domainHasVersion[​](#domainhasversion "Direct link to domainHasVersion")

Checks if a specific version of a domain exists

**Arguments:**

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

**Examples:**

```
# Check if version exists
npx @eventcatalog/cli domainHasVersion "Orders" "1.0.0"
```

***
