---
title: "Save entities version (saveEntitiesVersion)"
method: POST
path: "/api/entities/vc/version"
tags: ["entities-version-control-controller"]
---

# Save entities version (saveEntitiesVersion)

`POST /api/entities/vc/version`

Creates a new version of entities (or a single entity) by request.
Supported entity types: CUSTOMER, ASSET, RULE_CHAIN, DASHBOARD, DEVICE_PROFILE, DEVICE, ENTITY_VIEW, WIDGETS_BUNDLE.

There are two available types of request: `SINGLE_ENTITY` and `COMPLEX`. Each of them contains version name (`versionName`) and name of a branch (`branch`) to create version (commit) in. If specified branch does not exists in a remote repo, then new empty branch will be created. Request of the `SINGLE_ENTITY` type has id of an entity (`entityId`) and additional configuration (`config`) which has following options: 
- `saveRelations` - whether to add inbound and outbound relations of type COMMON to created entity version;
- `saveAttributes` - to save attributes of server scope (and also shared scope for devices);
- `saveCredentials` - when saving a version of a device, to add its credentials to the version.

An example of a `SINGLE_ENTITY` version create request:
```json
{
  "type": "SINGLE_ENTITY",

  "versionName": "Version 1.0",
  "branch": "dev",

  "entityId": {
    "entityType": "DEVICE",
    "id": "b79448e0-d4f4-11ec-847b-0f432358ab48"
  },
  "config": {
    "saveRelations": true,
    "saveAttributes": true,
    "saveCredentials": false
  }
}
```

Second request type (`COMPLEX`), additionally to `branch` and `versionName`, contains following properties:
- `entityTypes` - a structure with entity types to export and configuration for each entity type;    this configuration has all the options available for `SINGLE_ENTITY` and additionally has these ones: 
     - `allEntities` and `entityIds` - if you want to save the version of all entities of the entity type         then set `allEntities` param to true, otherwise set it to false and specify the list of specific entities (`entityIds`);
     - `syncStrategy` - synchronization strategy to use for this entity type: when set to `OVERWRITE`         then the list of remote entities of this type will be overwritten by newly added entities. If set to         `MERGE` - existing remote entities of this entity type will not be removed, new entities will just         be added on top (or existing remote entities will be updated).
- `syncStrategy` - default synchronization strategy to use when it is not specified for an entity type.

Example for this type of request:
```json
{
  "type": "COMPLEX",

  "versionName": "Devices and profiles: release 2",
  "branch": "master",

  "syncStrategy": "OVERWRITE",
  "entityTypes": {
    "DEVICE": {
      "syncStrategy": null,
      "allEntities": true,
      "saveRelations": true,
      "saveAttributes": true,
      "saveCredentials": true
    },
    "DEVICE_PROFILE": {
      "syncStrategy": "MERGE",
      "allEntities": false,
      "entityIds": [
        "b79448e0-d4f4-11ec-847b-0f432358ab48"
      ],
      "saveRelations": true
    }
  }
}
```

Response wil contain generated request UUID, that can be then used to retrieve status of operation via `getVersionCreateRequestStatus`.


Available for users with 'TENANT_ADMIN' authority.

## Request body

- union
  - ComplexVersionCreateRequest
    - `versionName` string
    - `branch` string
    - `type` 'SINGLE_ENTITY' | 'COMPLEX'
    - `syncStrategy` 'MERGE' | 'OVERWRITE'
    - `entityTypes` object
  - SingleEntityVersionCreateRequest
    - `versionName` string
    - `branch` string
    - `type` 'SINGLE_ENTITY' | 'COMPLEX'
    - `entityId` EntityId
      - `id` string, uuid, required — ID of the entity, time-based UUID v1
      - `entityType` 'TENANT' | 'CUSTOMER' | 'USER' | 'DASHBOARD' | 'ASSET' | 'DEVICE' | 'ALARM' | 'RULE_CHAIN' | 'RULE_NODE' | 'ENTITY_VIEW' | 'WIDGETS_BUNDLE' | 'WIDGET_TYPE' | 'TENANT_PROFILE' | 'DEVICE_PROFILE' | 'ASSET_PROFILE' | 'API_USAGE_STATE' | 'TB_RESOURCE' | 'OTA_PACKAGE' | 'EDGE' | 'RPC' | 'QUEUE' | 'NOTIFICATION_TARGET' | 'NOTIFICATION_TEMPLATE' | 'NOTIFICATION_REQUEST' | 'NOTIFICATION' | 'NOTIFICATION_RULE' | 'QUEUE_STATS' | 'OAUTH2_CLIENT' | 'DOMAIN' | 'MOBILE_APP' | 'MOBILE_APP_BUNDLE' | 'CALCULATED_FIELD' | 'JOB' | 'ADMIN_SETTINGS' | 'AI_MODEL' | 'API_KEY', required
    - `config` VersionCreateConfig
      - `saveRelations` boolean
      - `saveAttributes` boolean
      - `saveCredentials` boolean
      - `saveCalculatedFields` boolean

## Response `200`

OK

- string, uuid

---

[API](https://skmtc.net/thingsboard/apis/thingsboard-rest-api.md) · [All operations](https://skmtc.net/thingsboard/apis/thingsboard-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/thingsboard/thingsboard-rest-api/revisions/40169ccdec5c/schema)
