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

***

# Function: addDataProductToDomain()

> **addDataProductToDomain**(`directory`): (`id`, `dataProduct`, `version`?) => `Promise`<`void`>

Defined in: domains.ts:489

Add a data product to a domain by its id. Optionally specify a version to add the data product 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`                                 |
| `dataProduct`          | { `id`: `string`; `version`: `string`; } |
| `dataProduct.id`       | `string`                                 |
| `dataProduct.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 data product to the domain
const { addDataProductToDomain } = utils('/path/to/eventcatalog');

// Adds a data product (CustomerDataProduct) to the domain (Orders)
await addDataProductToDomain('Orders', { id: 'CustomerDataProduct', version: '1.0.0' });
// Adds a data product (SalesDataProduct) to the domain (Orders) with a specific version
await addDataProductToDomain('Orders', { id: 'SalesDataProduct', version: '2.0.0' }, '1.0.0');
```
