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

***

# Function: writeServiceToDomain()

> **writeServiceToDomain**(`directory`): (`service`, `domain`, `options`) => `Promise`<`void`>

Defined in: services.ts:223

Write a service to a domain in EventCatalog.

## 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                                                                      |
| ------------------- | ------------------------------------------------------------------------- |
| `service`           | `Service`                                                                 |
| `domain`            | { `direction`: `string`; `id`: `string`; `version`: `string`; }           |
| `domain.direction`? | `string`                                                                  |
| `domain.id`         | `string`                                                                  |
| `domain.version`?   | `string`                                                                  |
| `options`           | { `format`: `"md"` \| `"mdx"`; `override`: `boolean`; `path`: `string`; } |
| `options.format`?   | `"md"` \| `"mdx"`                                                         |
| `options.override`? | `boolean`                                                                 |
| `options.path`?     | `string`                                                                  |

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

`Promise`<`void`>

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

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

const { writeServiceToDomain } = utils('/path/to/eventcatalog');

// Write a service to a domain
// Service would be written to domains/Shopping/services/InventoryService
await writeServiceToDomain({
  id: 'InventoryService',
  name: 'Inventory Service',
  version: '0.0.1',
  summary: 'Service that handles the inventory',
  markdown: '# Hello world',
}, { id: 'Shopping' });
```
