Get the code representation of a data model

View as MarkdownOpen in Claude
This endpoint returns a code representation of an existing data model, including metadata and contents. The response can be formatted as either JSON or YAML, and contains a data model's pages, elements, columns, sources, and more. The representation can be used to store, copy, or modify the data model programmatically. For more information on managing data models via the Sigma API, see [Manage data models as code](https://help.sigmacomputing.com/docs/manage-data-models-as-code). For more information on using this endpoint, including an end-to-end example, see [Get the code representation of a data model](https://help.sigmacomputing.com/docs/get-the-code-representation-of-a-data-model). ### Usage notes - To perform this operation, you must use API credentials owned by a user with **Can view** access to the data model. - Retrieve the **dataModelId** by calling the [/v2/dataModels](https://help.sigmacomputing.com/reference/list-data-models) endpoint. Invalid or nonexistent IDs return an error. - The response includes the data sources, metadata, and relationships necessary to recreate the data model. The data itself is not included in the response. - To create a new data model from code, use the [/v2/dataModels/spec](https://help.sigmacomputing.com/reference/create-data-model-spec) endpoint. - To update an existing data model from code, use the [/v2/dataModels/{dataModelId}/spec](https://help.sigmacomputing.com/reference/update-data-model-spec) endpoint. - The default format of the representation is JSON. To receive YAML, add the query parameter `?format=yaml` or the header `Accept: application/yaml`. ### Usage scenarios - **Backup and restore**: Developers can use this endpoint to programmatically back up data models and restore them if needed. - **Version control**: Developers can use this endpoint to programmatically manage, update, and version control data models between several organizations or tenants. - **Administration**: Administrators can use this endpoint to programmatically analyze and govern data models across an organization. - **Migration**: Administrators can use this endpoint to programmatically migrate data models between organizations or tenants. - **Agentic workflows**: Agents can use these endpoints to directly manage data model contents in code.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Path parameters

dataModelIdstringRequired

Query parameters

documentVersionintegerOptional

Response

The response body.
dataModelIdstring
Unique identifier of the data model.
namestring
The name of the data model.
urlstring
The full URL for the requested document version of the data model.
documentVersiondouble
The document version of the data model.
latestDocumentVersiondouble
The most recently published document version of the data model.
ownerIdstring
The identifier of the user who owns the data model.
folderIdstring
The identifier of the folder in which the data model is located.
createdBystring
The identifier of the user who created the data model.
updatedBystring
The identifier of the user or process that last updated the data model.
createdAtdatetime
When the data model was created.
updatedAtdatetime
When the data model was last updated.
schemaVersionenum
The schema version used by this representation of the data model.
pageslist of objects
The pages of the data model and their contents.
descriptionstring
The description of the data model.