POST /tspublic/v1/metadata/tml/import
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.
Import TMLš
To import TML representation of objects into ThoughtSpot, use the /tspublic/v1/metadata/tml/import
API endpoint.
Resource URLš
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 |
|
| String. Specifies the schema version to use during TML export.
By default, the API request uses v1 schema for Worksheets. If you are using Models, set |
|
| Boolean. Specifies if the Tables of the referenced Connection object must be included in the export. |
|
| Boolean. Specifies if a connection object must be included as a dependent object when exporting a Table, Worksheet, Answer, or Liveboard TML. This parameter is considered only when |
|
| Boolean. Specifies if the export request is sent from all Orgs context. Applicable to Orgs-enabled instances only. |
|
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 |