Copy as Markdown[View as Markdown](/docs/sdk/functions/addServiceToDomain.md)

***

# Function: addServiceToDomain()

> **addServiceToDomain**(`directory`): (`id`, `service`, `version`?) => `Promise`<`void`>

Defined in: domains.ts:359

Add a service to a domain by it's id.

Optionally specify a version to add the service to a specific version of the domain.

## Parameters[​](#parameters "Direct link to Parameters")

| Parameter   | Type     |
| ----------- | -------- |
| `directory` | `string` |

## Returns[​](#returns "Direct link to Returns")

`Function`

### Parameters[​](#parameters-1 "Direct link to Parameters")

| Parameter          | Type                                     |
| ------------------ | ---------------------------------------- |
| `id`               | `string`                                 |
| `service`          | { `id`: `string`; `version`: `string`; } |
| `service.id`       | `string`                                 |
| `service.version`? | `string`                                 |
| `version`?         | `string`                                 |

### Returns[​](#returns-1 "Direct link to Returns")

`Promise`<`void`>

## Example[​](#example "Direct link to Example")

```
import utils from '@eventcatalog/utils';

// Adds a service to the domain
const { addServiceToDomain } = utils('/path/to/eventcatalog');

// Adds a service (Orders Service) to the domain (Orders)
await addServiceToDomain('Orders', { service: 'Order Service', version: '2.0.0' });
// Adds a service (Orders Service) to the domain (Orders) with a specific version
await addServiceToDomain('Orders', { service: 'Order Service', version: '2.0.0' }, '1.0.0');
```
