Add and Update Scripts
This documentation is for Kyvos 2026.6.x. To view documentation for other Kyvos versions, click here. |
|---|
Overview
This API adds or updates the script in a Semantic Model.
Method: POST
Request URL: {kyvos-url}/rest/v2/semantic-models/{name-or-id}/scripts
Authorization
API Key: sessionid
This method authenticates requests using a session ID which acts like an API key.
BasicAuth: HTTP Authorization Scheme
This method authenticates requests using a username and password sent in the HTTP Authorization header.
Headers
Header Name | Type | Description | Possible Values |
|---|---|---|---|
Content-Type (Required) | String | Specifies media type of request body. |
|
sessionid | String | The session ID is the token received from the login API. Note: Session ID is required for token-based authentication. | – |
Path Parameters
Parameter Name | Type | Description | Possible Values |
|---|---|---|---|
name-or-id (Required) | String | Name or ID of the Semantic Model in which the scripts are to be added or updated. Note: If the Semantic Model name is provided, either folderName or folderId must also be provided. | – |
Query Parameters
Parameter Name | Type | Description | Possible Values |
|---|---|---|---|
by | String | Specifies whether the name-or-id parameter should be interpreted as a Semantic Model name or Semantic Model ID. If by=name, provide the Semantic Model name in the name-or-id parameter. If by=id, provide the Semantic Model ID in the name-or-id parameter. The default value is name. | – |
folderName | String | Name of the folder containing the Semantic Model. If the Semantic Model is present in the root directory, specify [Root]. Note: If neither folderName nor folderId is provided, the Semantic Model will be treated as a root-level entity by default. | – |
folderId | String | ID of the folder containing the Semantic Model. | – |
Request Body
Parameter Name | Type | Description | Possible Values |
|---|---|---|---|
scripts (Required) | String | Script information object that needs to be added to the Semantic Model. Note: An example object is provided under the Resources section below for reference. | – |
Responses
200 Success
{
"code": 0,
"message": "Script updated successfully."
}Status Code | Description |
|---|---|
401 | Authorization information is missing or invalid. |
404 | No matching record found. |
412 | Precondition failed. Parameter missing. |
500 | Internal Server Error |
Resources
Below is an example of JSON structure which can be used as a reference for the scripts parameter in the request body.
[
{
"expression":"SCOPE([Order].[OrderPriority].&[Critical],[Measures].[Avg Profit]); \n\t This = [Measures].[Avg Discount],[CustomerName].[H_CustomerName].[Segment].&[Consumer]; \nEND SCOPE;",
"name":"DEFAULT_SCRIPT",
"disabled":true
}
]JSON Fields Description
Field | Type | Description | Possible Values | Example |
(root) | Array | Root JSON array containing script definitions. Each object represents an MDX script for the semantic model | Array of Script objects | [{...}] |
name | String | Unique name for the script. Used to identify the script for updates or deletion. Required field | Any descriptive name | "Calculate YTD Sales" |
expression | String | MDX script expression. This can contain calculated member definitions, named set definitions, SCOPE statements, or other valid MDX script commands. Required field | Valid MDX script | "CREATE MEMBER [Measures].[YTD Sales] AS SUM(YTD([Time].CurrentMember), [Measures].[Sales])" |
disabled | Boolean | Whether the script is disabled. Disabled scripts are stored but not executed during cube processing. Defaults to false | TRUE, FALSE | FALSE |