Create a prompt
POST {{baseUrl}}/api/model/prompts
Creates a new prompt in the changeset, based on the definition provided in request body. The definition of the newly created prompt is returned in response. Prompts have different subtypes. Currently, we support the following subtypes:
* Expression Hierarchy: This prompt is defined on the hierarchy object.
* Expression Attribute: This prompt is defined on the attribute object.
* Expression Metric: This prompt is defined on the metric object.
* Object: This prompt is defined on objects, not including folders under a project.
* Attribute Element: This prompt is defined on an attribute element.
* Value: This prompt is defined on a value, such as double, long, text, date, or big decimal. In the request body, there are four main parts:
* Information: Stores basic prompt information such as name, subType, destinationFolderId, etc. subType and name are required fields.
* Question: The main definition for the prompt. The contents are different based on the prompt type. For example, Expression Hierarchy stores a list of predefined hierarchies or a search object.
* DefaultAnswer: Stores the default answer for the prompt. The contents are different based on prompt type. For example, Expression Hierarchy stores an expression in the In addition to the main parts, there are three other keys in the body. These are title, instruction, and expressionType. 'expressionType' is necessary when the subtype in the Information part is 'prompt_expression'. It is used to differentiate the three expression types for the prompt. The mapping between 'expressionType' and prompt type is as follows:
* attribute -> expression attribute
* hierarchy -> expression hierarchy
* metric -> expression metric The changeset ID can be obtained using the changeset creation API. An authorization token is required to execute the request and can be obtained using Authentication endpoints. To save the newly created prompt to the metadata, commit using the changeset commit API.tree
format. If there is a custom expression in the expression, the custom expression must contain the tree
format.
* Restriction: Stores some control flags for the prompt. For example, personal answers allowed flag, min flag, max flag, etc.
Body
PARAM
Key | Datatype | Required | Description |
showExpressionAs
|
string | This parameter specifies the format in which the expressions are returned in response. This parameter applies to the expressions in a fact or attribute and custom expressions used in a filter, prompt, security filter, custom group, etc. Expressions are presented in the following formats: * "text": A human readable, but non-parsable text, describing the expression. This is the default format that is always returned in the response. * "tree": A tree data structure fully defining the expression. This format can be used if you want to examine and modify the expression programmatically. * "tokens": A list of parsed tokens. This format can be used if you want to examine and modify the expression using the parser component. Note that generating tokens requires additional time. Tokens are a semi-structured representation of MicroStrategy expression text that includes object references. For example, let’s say a filter expression is "Revenue > Cost". When the filter expression is represented as tokens, the text is broken down into pieces (tokens) with information about what these pieces represent in the metadata: ("Revenue", Revenue_ID), (">", GreaterThan_ID), ("Cost", Cost_ID). If omitted, the expression is returned in "text" format. If `tree`, the expression is returned in "text" and "tree" formats. If `tokens`, the expression is returned in "text" and "tokens" formats. |
HEADERS
Key | Datatype | Required | Description |
X-MSTR-AuthToken
|
string | (Required) Authorization Token | |
X-MSTR-MS-Changeset
|
string | (Required) Changeset ID | |
Curl curl -X POST 'baseUrl/api/model/prompts?showExpressionAs=tree' -H 'X-MSTR-AuthToken: authToken' -H 'X-MSTR-MS-Changeset: rd_changesetId' -H 'Content-Type: application/json' -d '{"information":{"destinationFolderId":"publicObjectsFolderId","subType":"prompt_elements","name":"Attribute Element List on Subcategory Prompt"},"title":"Subcategory","instruction":"Choose elements of Subcategory.","question":{"attribute":{"objectId":"8D679D4F11D3E4981000E787EC6DE8A4","subType":"attribute","name":"Subcategory"},"listAllElements":true},"restriction":{"required":false,"allowPersonalAnswers":"none"}}' ENDPOINTS |