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

***

# Function: versionEntity()

> **versionEntity**(`directory`): (`id`) => `Promise`<`void`>

Defined in: entities.ts:178

Version an entity by its id.

Takes the latest entity and moves it to a versioned directory. All files with this entity are also versioned (e.g /entities/User/schema.json)

## 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` |

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

`Promise`<`void`>

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

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

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

// moves the latest User entity to a versioned directory
// the version within that entity is used as the version number.
await versionEntity('User');
```
