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

***

# Services CLI Commands

Manage services in your EventCatalog from the command line.

## getService[​](#getservice "Direct link to getService")

Returns a service from EventCatalog by its ID

**Arguments:**

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

**Examples:**

```
# Get the latest service
npx @eventcatalog/cli getService "OrderService"

# Get a specific version
npx @eventcatalog/cli getService "OrderService" "1.0.0"
```

***

## getServices[​](#getservices "Direct link to getServices")

Returns all services from EventCatalog

**Arguments:**

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

**Examples:**

```
# Get all services
npx @eventcatalog/cli getServices
```

***

## writeService[​](#writeservice "Direct link to writeService")

Writes a service to EventCatalog

**Arguments:**

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

***

## writeServiceToDomain[​](#writeservicetodomain "Direct link to writeServiceToDomain")

Writes a service to a specific domain

**Arguments:**

| Name    | Type | Required | Description                      |
| ------- | ---- | -------- | -------------------------------- |
| service | json | Yes      | Service object                   |
| domain  | json | Yes      | Domain reference: {id, version?} |
| options | json | No       | Options                          |

***

## rmService[​](#rmservice "Direct link to rmService")

Removes a service by its path

**Arguments:**

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

**Examples:**

```
# Remove a service
npx @eventcatalog/cli rmService "/OrderService"
```

***

## rmServiceById[​](#rmservicebyid "Direct link to rmServiceById")

Removes a service by its ID

**Arguments:**

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

**Examples:**

```
# Remove a service
npx @eventcatalog/cli rmServiceById "OrderService"
```

***

## versionService[​](#versionservice "Direct link to versionService")

Moves the current service to a versioned directory

**Arguments:**

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

**Examples:**

```
# Version a service
npx @eventcatalog/cli versionService "OrderService"
```

***

## addFileToService[​](#addfiletoservice "Direct link to addFileToService")

Adds a file to a service

**Arguments:**

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

***

## addEventToService[​](#addeventtoservice "Direct link to addEventToService")

Adds an event relationship to a service

**Arguments:**

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

***

## addCommandToService[​](#addcommandtoservice "Direct link to addCommandToService")

Adds a command relationship to a service

**Arguments:**

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

***

## addQueryToService[​](#addquerytoservice "Direct link to addQueryToService")

Adds a query relationship to a service

**Arguments:**

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

***

## addEntityToService[​](#addentitytoservice "Direct link to addEntityToService")

Adds an entity to a service

**Arguments:**

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

***

## addDataStoreToService[​](#adddatastoretoservice "Direct link to addDataStoreToService")

Adds a data store relationship to a service

**Arguments:**

| Name           | Type   | Required | Description                             |
| -------------- | ------ | -------- | --------------------------------------- |
| serviceId      | string | Yes      | The ID of the service                   |
| relationship   | string | Yes      | Relationship: "writesTo" or "readsFrom" |
| dataStore      | json   | Yes      | Data store reference: {id, version}     |
| serviceVersion | string | No       | Specific service version                |

***

## serviceHasVersion[​](#servicehasversion "Direct link to serviceHasVersion")

Checks if a specific version of a service exists

**Arguments:**

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

**Examples:**

```
# Check if version exists
npx @eventcatalog/cli serviceHasVersion "OrderService" "1.0.0"
```

***

## getSpecificationFilesForService[​](#getspecificationfilesforservice "Direct link to getSpecificationFilesForService")

Returns specification files (OpenAPI, AsyncAPI) for a service

**Arguments:**

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

**Examples:**

```
# Get spec files
npx @eventcatalog/cli getSpecificationFilesForService "OrderService"
```

***
