Get the code representation of a data model
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
dataModelId
Query parameters
documentVersion
Response
The response body.
dataModelId
Unique identifier of the data model.
name
The name of the data model.
url
The full URL for the requested document version of the data model.
documentVersion
The document version of the data model.
latestDocumentVersion
The most recently published document version of the data model.
ownerId
The identifier of the user who owns the data model.
folderId
The identifier of the folder in which the data model is located.
createdBy
The identifier of the user who created the data model.
updatedBy
The identifier of the user or process that last updated the data model.
createdAt
When the data model was created.
updatedAt
When the data model was last updated.
schemaVersion
The schema version used by this representation of the data model.
pages
The pages of the data model and their contents.
description
The description of the data model.

