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

***

# Function: writeFlowToService()

> **writeFlowToService**(`directory`): (`flow`, `service`, `options`) => `Promise`<`void`>

Defined in: flows.ts:220

Write a flow to a service 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                                                                      |
| ------------------- | ------------------------------------------------------------------------- |
| `flow`              | `Flow`                                                                    |
| `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 { writeFlowToService } = utils('/path/to/eventcatalog');

// Flow would be written to services/PaymentService/flows/PaymentFlow
await writeFlowToService({
  id: 'PaymentFlow',
  name: 'Payment Flow',
  version: '0.0.1',
  markdown: '# Payment Flow',
  steps: [],
}, { id: 'PaymentService' });
```
