Update a workbook from a code representation (Beta)
Update a workbook from a code representation (Beta)
This endpoint replaces a workbook with a workbook defined in a code representation. You can programmatically update the workbook's structure, metadata, and contents. This creates a new version of the workbook, which is accessible from the Sigma UI.
**Beta**: This documentation describes a public beta feature and is subject to the [Beta features](/docs/sigma-product-releases#beta-features) disclaimer.
### System and user requirements
- To perform this operation, you must use API credentials owned by a user assigned an account type with **Create, edit, and publish workbooks** permission.
- To perform this operation, you must use API credentials owned by a user with **Can edit** access for the workbook.
### Usage notes
- The default response format is JSON. To use YAML, add the header `Accept: application/yaml`.
- You can define the layout of contents on the workbook page using XML in the `contents.layout` field. For more information, see [Customize the layout of a workbook in code representation](https://help.sigmacomputing.com/docs/customize-the-layout-of-a-workbook-in-code-representation).
- You can combine multiple YAML documents to create one workbook representation. For more information, see [Prepare a representation from multiple YAML documents](https://help.sigmacomputing.com/docs/create-a-workbook-from-a-code-representation#prepare-a-representation-from-multiple-yaml-documents).
- To retrieve the current representation of a workbook, use `GET /workbooks/{workbookId}?includeContents=true`.
- To create a new workbook from code, use `POST /workbooks` with `contents` in the request body.
- When `documentVersion` is provided in the request body, the update fails when the workbook has changed since that version. If omitted, the update preserves last-write-wins behavior.
- The endpoint only supports updates to the `contents` object. Workbook metadata sent alongside `contents` -- including `name`, `folderId`, and `description` -- is ignored, so you can submit a `GET` response unchanged. To rename or move a workbook, use the [/v2/files/{fileId}](https://help.sigmacomputing.com/reference/updatefile) endpoint.
- Partial updates are not supported. You must provide the entire representation of the workbook in the request body.
### Usage scenarios
- **Agentic workflows**: Agents can use these endpoints to directly manage workbook contents in code.
- **Automation**: If you want to update several workbooks across one or more organizations, or in response to external events, you can use this endpoint to programmatically update the workbooks.
- **Integration**: Using this endpoint, you can update workbooks based on external data sources or integrate Sigma with other tools and platforms.
Authentication
AuthorizationBearer
OAuth authentication of the form <token>.
Path parameters
workbookId
Unique identifier of the workbook.
Request
The request body.
contents
The code representation of the workbook to write: its pages, elements, columns, sources, layout, and theme.
documentVersion
When provided, update only if the workbook is still at this document version.
Response
The response body.
workbookId
Unique identifier of the workbook.
workbookUrlId
name
url
path
latestVersion
The most recently published document version of the workbook.
ownerId
createdBy
The identifier of the user who created this object.
updatedBy
The identifier of the user or process that last updated this object.
createdAt
When the object was created.
updatedAt
When the object was last updated.
isArchived
description
taggedSourceUrlId
For a workbook deployed to a tenant organization by a deployment policy with a version tag, the `urlId` of the original source workbook in the parent organization. Only present when `includeTaggedSourceUrlId=true` is included in the request.

