API endpoint | Available from |
---|---|
| ThoughtSpot Cloud ts7.may.cl |
| ThoughtSpot Cloud ts7.may.cl |
TML API
The TML API endpoints allow you to programmatically export, validate, and import scriptable ThoughtSpot Modeling Language (TML) files. You can use these API endpoints to automate the change management and deployment processes between your development and production environments. With TML API, you can easily migrate your ThoughtSpot content from one environment to another by automating the entire change management process and thereby reducing the risk of human error.
Note
|
Starting with version 8.9.0.cl, ThoughtSpot exports TML files with |
Supported operationsš
Required permissionsš
You must have at least view access to the objects to export the TML data. To import a modified TML object, your account must have the DATAMANAGEMENT
privilege.
Import TMLš
To import TML representation of objects into ThoughtSpot, use the /tspublic/v1/metadata/tml/import
API endpoint.
The import TML API endpoint allows you to upload multiple TML files at a time. If you are importing TML files one at a time, include the fqn
property to distinguish objects that have the same name. For example, if you have multiple connections or tables with the same name, the connection or table you reference in your TML does not have a unique name and thus can lead to invalid object references. Adding fqn
helps ThoughtSpot differentiate a table from another with the same name.
By default, the fqn
parameter is not present in the TML file. However, you can export TML with FQNs and use it during the import.
Note
|
You can import single or multiple objects using the However, if you import a Worksheet along with Liveboards, answers, and other dependent objects in a single API call, the imported objects will be immediately available for use. |
Resource URLš
POST /tspublic/v1/metadata/tml/import
Request parametersš
Form parameter | Description | Default |
---|---|---|
| String. An If in YAML format within the JSON array, use escape characters for YAML quotes, and new line characters when there is a new line. For example:
| None |
| String. Policy to follow during import. The allowed values are:
|
|
| Boolean. Specifies if you are updating or creating objects. To create new objects, specify By default, ThoughtSpot updates existing objects that have the same GUID as the objects you are importing. When set to |
|
Example requestš
Make sure the API request has the following headers:
-
The
Accept
header is set asAccept: text/plain
-
The
X-requested-by
header set asX-Requested-By: ThoughtSpot
curl -X POST --header 'Accept: text/plain' --header 'X-Requested-By: ThoughtSpot' --data-urlencode 'import_objects=[{
"guid": "12289fad-f230-485e-8c65-e36082eebf44",
"answer": {
"name": "Basic Answer 1",
"description": "This is basic answer with table and headline visualizations.",
"tables": [{
"id": "LINEORDER",
"name": "LINEORDER",
"fqn": "2445fe81-30d6-46fa-9f42-f6b1b4e01623"
}, {
"id": "PART",
"name": "PART",
"fqn": "a7fc012e-bdb3-4e75-9ce4-b3f731d90136"
}],
"search_query": "[LINEORDER_1::Revenue] [PART_1::Color]",
"answer_columns": [{
"name": "Total Revenue"
}, {
"name": "Color"
}],
"table": {
"table_columns": [{
"column_id": "Color",
"headline_aggregation": "COUNT_DISTINCT"
}, {
"column_id": "Total Revenue",
"headline_aggregation": "SUM"
}],
"ordered_column_ids": ["Color", "Total Revenue"]
},
"chart": {
"type": "COLUMN",
"chart_columns": [{
"column_id": "Total Revenue"
}, {
"column_id": "Color"
}],
"axis_configs": [{
"x": ["Color"],
"y": ["Total Revenue"]
}]
},
"display_mode": "TABLE_MODE"
}
}]'
--data-urlencode 'import_policy=PARTIAL'
--data-urlencode 'force_create=true'
'http://{ThoughtSpot-Host}/callosum/v1/tspublic/v1/metadata/tml/import'
https://{ThoughtSpot-Host}/callosum/v1/tspublic/v1/metadata/tml/import
Example responseš
{
"object": [
{
"response": {
"status": {
"status_code": "OK"
},
"header": {
"id_guid": "a09a3787-e546-42cb-888f-c17260dd1229",
"name": "Basic Answer 1",
"description": "This is basic answer with table and headline visualizations.",
"author_guid": "59481331-ee53-42be-a548-bd87be6ddd4a",
"owner_guid": "a09a3787-e546-42cb-888f-c17260dd1229",
"metadata_type": "QUESTION_ANSWER_BOOK"
}
}
}
]
}
Response codesš
HTTP status code | Description |
---|---|
200 | Successful import of the TML object representations |
400 | Bad request |
401 | Unauthorized or wrong credentials |
403 | Forbidden - incorrect permissions |
404 | Not found |
500 | Internal server error |
Export TMLš
To export TML objects, use the /tspublic/v1/metadata/tml/export
API endpoint.
Resource URLš
POST /tspublic/v1/metadata/tml/export
Request parametersš
Form parameter | Description | Default | ||
---|---|---|---|---|
| String. JSON array of the IDs of objects to export. An For example:
| None | ||
| String. The format in which to export the objects. Valid values are |
| ||
| Boolean. Specifies if you would like to export the associated objects. To export the objects associated with the objects specified in |
| ||
| Boolean. When set to ThoughtSpot recommends adding the The
|
|
Example requestš
Make sure the API request has the following headers:
-
The
Accept
header is set asAccept: text/plain
-
The
X-requested-by
header must beX-Requested-By: ThoughtSpot
curl -X POST
--header 'Accept: text/plain' \
--header 'X-Requested-By: ThoughtSpot' \
--data-urlencode 'export_ids=["12289fad-f230-485e-8c65-e36082eebf44"]' \
--data-urlencode 'formattype=JSON' \
--data-urlencode 'export_associated=false' \
--data-urlencode 'export_fqn=true' \
'http://{ThoughtSpot-Host}/callosum/v1/tspublic/v1/metadata/tml/export'
https://{ThoughtSpot-Host}/callosum/v1/tspublic/v1/metadata/tml/export
Example responseš
{
"object":[
{
"info":{
"name":"Total sales",
"filename":"Total sales.pinboard.tml",
"status":{
"status_code":"OK"
},
"type":"pinboard",
"id":"bf3b1f36-b96e-4aa7-b619-b7743c8bd15c"
},
"edoc":"{\"guid\": \"bf3b1f36-b96e-4aa7-b619-b7743c8bd15c\",\"liveboard\": {\"name\": \"Total sales\",\"visualizations\": [{\"id\": \"Viz_1\",\"answer\": {\"name\": \"Total sales by store\",\"tables\": [{\"id\": \"(Sample) Retail - Apparel\",\"name\": \"(Sample) Retail - Apparel\",\"fqn\": \"cd252e5c-b552-49a8-821d-3eadaa049cca\"}],\"search_query\": \"[sales] [store] [state]\",\"answer_columns\": [{\"name\": \"state\"},{\"name\": \"store\"},{\"name\": \"Total sales\"}],\"table\": {\"table_columns\": [{\"column_id\": \"store\",\"show_headline\": false},{\"column_id\": \"state\",\"show_headline\": false},{\"column_id\": \"Total sales\",\"show_headline\": false}],\"ordered_column_ids\": [\"store\",\"state\",\"Total sales\"],\"client_state\": \"\",\"client_state_v2\": \"{\\\"tableVizPropVersion\\\": \\\"V1\\\"}\"},\"chart\": {\"type\": \"GEO_AREA\",\"chart_columns\": [{\"column_id\": \"store\"},{\"column_id\": \"state\"},{\"column_id\": \"Total sales\"}],\"axis_configs\": [{\"x\": [\"state\"],\"y\": [\"Total sales\"]}],\"client_state\": \"\",\"client_state_v2\": \"{\\\"version\\\": \\\"V4DOT2\\\",\\\"chartProperties\\\": {\\\"mapviewport\\\": {\\\"center\\\": [-1.0815372462017208E7,4944187.994859374],\\\"zoomLevel\\\": 5.140063818579165},\\\"responsiveLayoutPreference\\\": \\\"AUTO_ON\\\",\\\"chartSpecific\\\": {}},\\\"axisProperties\\\": [{\\\"id\\\": \\\"be5fe824-1a94-4fc4-88f6-501198708122\\\",\\\"properties\\\": {\\\"axisType\\\": \\\"Y\\\",\\\"linkedColumns\\\": [\\\"Total sales\\\"],\\\"isOpposite\\\": false}},{\\\"id\\\": \\\"474621ab-c78c-496f-aa71-8de82a5a1af4\\\",\\\"properties\\\": {\\\"axisType\\\": \\\"X\\\",\\\"linkedColumns\\\": [\\\"state\\\"]}}],\\\"systemSeriesColors\\\": [{\\\"serieName\\\": \\\"Total sales\\\",\\\"color\\\": \\\"#48D1E0\\\"}],\\\"systemMultiColorSeriesColors\\\": [{\\\"serieName\\\": \\\"Total sales\\\",\\\"colorMap\\\": [{\\\"serieName\\\": \\\"state\\\",\\\"color\\\": [\\\"#ffffb2\\\",\\\"#fddd87\\\",\\\"#fba35d\\\",\\\"#f75534\\\",\\\"#f9140a\\\",\\\"#d70315\\\",\\\"#b10026\\\"]}]}]}\"},\"display_mode\": \"CHART_MODE\"}},{\"id\": \"Viz_2\",\"answer\": {\"name\": \"Total sales by store\",\"tables\": [{\"id\": \"(Sample) Retail - Apparel\",\"name\": \"(Sample) Retail - Apparel\",\"fqn\": \"cd252e5c-b552-49a8-821d-3eadaa049cca\"}],\"search_query\": \"[sales] [store] [quantity purchased]\",\"answer_columns\": [{\"name\": \"store\"},{\"name\": \"Total quantity purchased\"},{\"name\": \"Total sales\"}],\"table\": {\"table_columns\": [{\"column_id\": \"store\",\"show_headline\": false},{\"column_id\": \"Total sales\",\"show_headline\": false},{\"column_id\": \"Total quantity purchased\",\"show_headline\": false}],\"ordered_column_ids\": [\"store\",\"Total sales\",\"Total quantity purchased\"],\"client_state\": \"\",\"client_state_v2\": \"{\\\"tableVizPropVersion\\\": \\\"V1\\\"}\"},\"chart\": {\"type\": \"COLUMN\",\"chart_columns\": [{\"column_id\": \"store\"},{\"column_id\": \"Total sales\"},{\"column_id\": \"Total quantity purchased\"}],\"axis_configs\": [{\"x\": [\"store\"],\"y\": [\"Total sales\",\"Total quantity purchased\"]}],\"client_state\": \"\",\"client_state_v2\": \"{\\\"version\\\": \\\"V4DOT2\\\",\\\"chartProperties\\\": {\\\"responsiveLayoutPreference\\\": \\\"AUTO_ON\\\",\\\"chartSpecific\\\": {}},\\\"axisProperties\\\": [{\\\"id\\\": \\\"6cac31dc-bf75-4e9e-ab96-422053d913cd\\\",\\\"properties\\\": {\\\"axisType\\\": \\\"Y\\\",\\\"linkedColumns\\\": [\\\"Total sales\\\"],\\\"isOpposite\\\": false}},{\\\"id\\\": \\\"5f5971ce-7e5f-48a0-9ba4-2c376699f64c\\\",\\\"properties\\\": {\\\"axisType\\\": \\\"Y\\\",\\\"linkedColumns\\\": [\\\"Total quantity purchased\\\"],\\\"isOpposite\\\": true}},{\\\"id\\\": \\\"23799dc2-3d6c-4da1-9d1b-e1dba0e5cc00\\\",\\\"properties\\\": {\\\"axisType\\\": \\\"X\\\",\\\"linkedColumns\\\": [\\\"store\\\"]}}],\\\"systemSeriesColors\\\": [{\\\"serieName\\\": \\\"Total sales\\\",\\\"color\\\": \\\"#48D1E0\\\"},{\\\"serieName\\\": \\\"Total quantity purchased\\\",\\\"color\\\": \\\"#2E75F0\\\"}],\\\"systemMultiColorSeriesColors\\\": [{\\\"serieName\\\": \\\"Total sales\\\",\\\"colorMap\\\": [{\\\"serieName\\\": \\\"a3882487-1509-4b13-8430-2e91d511a865\\\",\\\"color\\\": [\\\"#ffffb2\\\",\\\"#fddd87\\\",\\\"#fba35d\\\",\\\"#f75534\\\",\\\"#f9140a\\\",\\\"#d70315\\\",\\\"#b10026\\\"]}]}]}\"},\"display_mode\": \"CHART_MODE\"}}]}}"
}
]
}
Response codesš
HTTP status code | Description |
---|---|
200 | Successful TML export operation |
400 | Bad request |
401 | Unauthorized - wrong credentials |
403 | Forbidden - incorrect permissions |
404 | Not found |
500 | Internal server error |