---
title: "Tag a data model"
method: POST
path: "/v2/dataModels/tag"
tags: ["Data models"]
---

# Tag a data model

`POST /v2/dataModels/tag`

## Request

- Base URL: `https://api.sigmacomputing.com`
- URL: `https://api.sigmacomputing.com/v2/dataModels/tag`
- Auth: HTTP bearer

Add a version tag to a data model and optionally set up a connection to swap to for a specific version of the data model.

  ### Usage notes
  - Retrieve the **dataModelId** by calling the [/v2/dataModels](https://help.sigmacomputing.com/reference/list-data-models) endpoint.
  - Retrieve the **tag** by calling the [/v2/tags](https://help.sigmacomputing.com/reference/list-version-tag) endpoint and using the `name` in the response.
  - Retrieve the **connectionId** to use as the **fromId** or **toId** by calling the [/v2/connections](https://help.sigmacomputing.com/reference/list-connections) endpoint.
  - If your data model includes a source that is not mapped to a new source, that source is not swapped.
  - When swapping data models used as the source for the data model:
    - You can only swap a data model source to another version of the same data model source. You cannot swap a data model source to a table in your data warehouse or a dataset.
    - When you swap sources from one data model version to a new one, specify the version tag of the data model that you swap to with `toVersionTagId`:
      - To swap to the latest published version of the data model, specify `toVersionTagId` as `null`.
      - To swap to a specific tagged version of the data model, specify the `toVersionTagId` of the data model.
    - If the data model already uses a specific tagged version of a data model as a source, use `fromVersionTagId` to indicate which tagged version to swap from.
      - To swap from the latest published version of the data model, specify `fromVersionTagId` as `null`.
      - To swap from a specific tagged version of the data model, specify the `fromVersionTagId` of the data model.
  - To retrieve the `fromVersionTagId` for a data model used as the data model source, call the [/v2/dataModels/{dataModelId}/sources](https://help.sigmacomputing.com/reference/list-data-model-sources) endpoint and use the `versionTagId` in the response.
  - To retrieve the `versionTagId` for a data model, call the [/v2/dataModels](https://help.sigmacomputing.com/reference/list-data-models) endpoint and use the `versionTagId` in the response.

  ### Usage scenarios
  - **Lifecycle management**: Identify production and development resources.

## Request body

- object
  - `dataModelId` string, required: Unique identifier of the data model.
  - `tag` string, required: Name of the version tag to apply.
  - `dataModelVersion` number, double: Specific version of the published data model to tag.
  - `sourceMappingConfig` V2DataModelsTagPostRequestBodyContentApplicationJsonSchemaSourceMappingConfigItems[]: Swap sources for the data model when you add a tag.
    - `fromConnectionId` string, required
    - `toConnectionId` string, required
    - `paths` V2DataModelsTagPostRequestBodyContentApplicationJsonSchemaSourceMappingConfigItemsPathsItems[], required
      - `fromPath` string[], required
      - `toPath` string[], required
  - `dataModelSourceTaggedVersions` V2DataModelsTagPostRequestBodyContentApplicationJsonSchemaDataModelSourceTaggedVersionsItems[]: Which tagged version of the data model to use as the source.
    - `dataModelId` string, required
    - `fromVersionTagId` string, nullable, required
    - `toVersionTagId` string, nullable, required
  - `isDefault` boolean: Whether to make this tag the default tagged version to load if the user doesn't have access to the published version.

## Response `200`

The response body.

- DataModelsTagDataModelResponse200
  - `versionTagId` string, required
  - `taggedDataModelId` string, required: Unique identifier of the data model.
  - `taggedDataModelVersion` number, double, required

---

[API](https://skmtc.dev/sigmacomputing/apis/sigma-rest-api.md) - [All operations](https://skmtc.dev/sigmacomputing/apis/sigma-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/sigmacomputing/apis/sigma-rest-api/revisions/fb6036208c49?raw)
