Update a report from a code representation (Beta)
Update a report from a code representation (Beta)
This documentation describes one or more public beta features that are in development. Beta features are subject to quick, iterative changes; therefore the current user experience in the Sigma service can differ from the information provided in this page.
This page should not be considered official published documentation until Sigma removes this notice and the beta flag on the corresponding feature(s) in the Sigma service. For the full beta feature disclaimer, see Beta features.
You can update an existing report from a code representation by calling the Update a report from a code representation endpoint with the code representation in the contents field of the request body.
This document provides step-by-step instructions for using this endpoint to update a report from a code representation. For more information on working with reports programmatically, see Manage reports as code.
User requirements
The ability to update a report from a code representation requires the following:
- You must have developer credentials for the Sigma API. For more information, see Get started with the Sigma REST API.
- The user associated with your API credentials must be assigned an account type with the Create, edit, and publish reports permission enabled.
- You must be the document owner or be granted Can edit access to the report.
Generate API client credentials and an API access token
To start, you must generate credentials for the Sigma API. These credentials are used to retrieve an access token, which is required to make requests to the API.
For step-by-step instructions on generating developer credentials in Sigma and using them to authenticate to the Sigma API, see the instructions in Generate client credentials.
Identify the report and retrieve the report ID
To update an existing report from a code representation, you must know the unique reportId for that report. After you identify the report you want to update, you can call the List reports endpoint to retrieve the reportId:
-
Go to your Home page.
-
In the navigation menu, select Documents.
-
Click the Document type
filter and select Reports.
The list of your reports appears.
-
Identify the report you want to update, by name, owner, or other details.
-
Make a GET request to the List reports endpoint like the following:
List reports request format
The response includes a list of reports in your organization, in the following format:
List reports response format
- Identify the report you want to update, and copy the
reportIdto use with the Update a report from a code representation endpoint.
Prepare the representation
To update an existing report from a code representation, you must prepare a valid code representation of the report with the updates you want to apply. You can base this on the existing report’s representation, or construct an entirely new one.
The Update a report from a code representation endpoint does not support partial updates. To update a report, you must provide a complete representation of the report, even if you are only making minor changes. Sigma recommends retrieving the existing representation and basing your changes on that.
The code representation you prepare can be passed into the request body of the Update a report from a code representation endpoint to update the report. The body must include the contents object with its required schemaVersion, kind, elements, pages, and layout fields.
The endpoint reads only contents and the optional documentVersion. Report metadata sent alongside contents — including name, folderId, and description — is ignored, so you can submit a response from the Get a report endpoint unchanged. The report stays in its existing folder. To rename or move a report, use the Update a file endpoint.
Whenever you add or remove an element, update the layout to match. Every element in contents.elements must be placed in the layout, and a representation with an element the layout never references is rejected with an error naming that element, such as elements[0]: element 'fWvU8grr1I' is not placed in layout.
-
Using the
reportIdyou identified in the previous section, follow the instructions in Get the code representation of a report to get the current representation.For example, you might retrieve the representation for a report with a single table, like the following:
YAML representation
-
Make any desired changes to the
contentsobject. For example, you might want to rename a table, add a new column, or remove an element.The report code representation does not support all report features. Unsupported features are silently dropped when you make a request to the Get a report endpoint. If you use a representation from that endpoint to create or update another report from code, it does not include the dropped features, even if they were present in the original report.
In this example, most columns are removed from the representation, leaving only the ID and Duration columns:
YAML representation
Call the Update a report from a code representation endpoint
Finally, call the Update a report from a code representation endpoint, passing the reportId as a path parameter and the updated code representation in the request body. The request format is as follows:
Update a report from a representation request format
The endpoint updates the report with the new representation and returns the report metadata, including the new latestVersion.
To avoid overwriting a change someone else made while you were preparing your update, include the documentVersion you retrieved alongside contents in the request body. If the report changed since that version, the update fails with a stale_document_settings error instead of replacing the newer contents. When you omit documentVersion, the last write wins.

