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

***

# Function: writeEventToService()

> **writeEventToService**(`directory`): (`event`, `service`, `options`) => `Promise`<`void`>

Defined in: events.ts:156

Write an event to a service in EventCatalog.

You can optionally override the path of the event.

## 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                                                                      |
| ------------------- | ------------------------------------------------------------------------- |
| `event`             | `Event`                                                                   |
| `service`           | { `id`: `string`; `version`: `string`; }                                  |
| `service.id`        | `string`                                                                  |
| `service.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 { writeEventToService } = utils('/path/to/eventcatalog');

// Write an event to a given service in the catalog
// Event would be written to services/Inventory/events/InventoryAdjusted
await writeEventToService({
  id: 'InventoryAdjusted',
  name: 'Inventory Adjusted',
  version: '0.0.1',
  summary: 'This is a summary',
  markdown: '# Hello world',
}, { id: 'Inventory' });
```
