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

***

# Function: writeDataProduct()

> **writeDataProduct**(`directory`): (`dataProduct`, `options`) => `Promise`<`void`>

Defined in: data-products.ts:115

Write a data product to EventCatalog.

You can optionally override the path of the data product.

## 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                                                                                                           |
| --------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `dataProduct`                     | `DataProduct`                                                                                                  |
| `options`                         | { `format`: `"md"` \| `"mdx"`; `override`: `boolean`; `path`: `string`; `versionExistingContent`: `boolean`; } |
| `options.format`?                 | `"md"` \| `"mdx"`                                                                                              |
| `options.override`?               | `boolean`                                                                                                      |
| `options.path`?                   | `string`                                                                                                       |
| `options.versionExistingContent`? | `boolean`                                                                                                      |

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

`Promise`<`void`>

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

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

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

// Write a data product to the catalog
// Data product would be written to data-products/CustomerDataProduct
await writeDataProduct({
  id: 'CustomerDataProduct',
  name: 'Customer Data Product',
  version: '0.0.1',
  summary: 'Customer data product',
  markdown: '# Customer data product',
});

// Write a data product to the catalog but override the path
// Data product would be written to data-products/Account/CustomerDataProduct
await writeDataProduct({
   id: 'CustomerDataProduct',
   name: 'Customer Data Product',
   version: '0.0.1',
   summary: 'Customer data product',
   markdown: '# Customer data product',
}, { path: "/Account/CustomerDataProduct"});

// Write a data product to the catalog and override the existing content (if there is any)
await writeDataProduct({
   id: 'CustomerDataProduct',
   name: 'Customer Data Product',
   version: '0.0.1',
   summary: 'Customer data product',
   markdown: '# Customer data product',
}, { override: true });

// Write a data product to the catalog and version the previous version
// only works if the new version is greater than the previous version
await writeDataProduct({
   id: 'CustomerDataProduct',
   name: 'Customer Data Product',
   version: '0.0.1',
   summary: 'Customer data product',
   markdown: '# Customer data product',
}, { versionExistingContent: true });
```
