String. Required. Specify a name for the Collection.
Collections Beta
ThoughtSpot now provides REST APIs that enable developers to organize different ThoughtSpot objects into an organizational container called Collections. These objects can be Liveboards, Answers, data models, tables, and even other Collections. Collections provide a powerful way to manage your data assets, making discovery and collaboration easier, while ensuring the integrity of embedded workflows.
|
Note
|
The Collections APIs are in Beta and disabled by default on ThoughtSpot instances. To enable these APIs on your instance, contact ThoughtSpot Support. |
Before you beginπ
-
For REST API v2 operations, the Org context is determined based on the authentication token used in your API requests. Ensure you log in to the appropriate Org context from which you want to send API requests.
-
When enabled on a ThoughtSpot instance, Collections can be created by any user, and need no special user privileges.
Create a Collectionπ
To create a new Collection, send a POST request to the POST /api/rest/2.0/collections/create API endpoint, with the following parameters in the request body.
Request parametersπ
In your POST request body, include the following parameters:
| Parameter | Description |
|---|---|
| |
| String. Optional. A short description for the Collection. |
| Array. Optional. The details for the metadata objects to be added to the Collection.
|
Example requestπ
curl -X POST \
--url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/create' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {AUTH_TOKEN}' \
--data-raw '{
"name": "Demo Collection",
"metadata": [
{
"type": "LIVEBOARD",
"identifiers": [
"Retail sales (Sample)",
"fe307a35-5242-445f-b3cb-b84cd1fc339c"
]
},
{
"type": "COLLECTION",
"identifiers": [
"Collection A"
]
}
],
"description": "For testing"
}'
API responseπ
If the API request is successful, a Collection with the given metadata objects will be created.
Search for a Collectionπ
To get a list of Collections, send a POST request to the POST /api/rest/2.0/collections/search API endpoint.
If no parameters are specified, the API returns the first 10 collections (or fewer, depending on the total number available).
Request parametersπ
In your POST request body, include the following parameters:
| Parameter | Description |
|---|---|
| String. Optional. Specify any case agnostic pattern to match the name of a Collection. Use |
| Number. Optional. The index of the first record to be included. Default value is 0. |
| Number. Optional. The total number of records to be searched. Default value is 10. Set to -1 to search across all available collections. |
| Array. Optional. GUID of the Collection(s) to be searched. |
| Array. Optional. Searches for Collections by the name of the author. |
| Boolean. Optional. When set to |
| Array. Optional. To sort the search results, specify the field to apply the sort on |
Example requestπ
curl -X POST \
--url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/search' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {AUTH_TOKEN}' \
--data-raw '{
"record_offset": 2,
"record_size": 15,
"include_metadata": false,
"name_pattern": "%",
"sort_options": {
"field_name": "NAME",
"order": "ASC"
}
}'
API responseπ
If the API request is successful, it will return a list of Collection(s) matching the search criteria.
Update a Collectionπ
To update an existing Collection, send a POST request to the POST /api/rest/2.0/collections/{collection_identifier}/update API endpoint.
Request parametersπ
In your POST request body, include the following parameters:
| Parameter | Description |
|---|---|
| Required. GUID of the Collection to be updated. |
| String. Optional. New name for the Collection. |
| String. Optional. Updated or a newly added description for the Collection. |
| Array. Required. The details for the metadata objects to be added, removed, or replaced in the Collection.
|
| Enum. Required. Specify the nature of the update. Select one of the following values:
|
Example requestπ
curl -X POST \
--url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/0e5fd958-cb2b-43f0-b67f-13ac5c805bad/update' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {AUTH_TOKEN}' \
--data-raw '{
"operation": "ADD",
"metadata": [
{
"type": "LIVEBOARD",
"identifiers": [
"6fee1adb-1c50-4c15-8d49-4fe0503d0b34"
]
}
]
}'
API responseπ
If the API request is successful, the object specified in the API request is added to the Collection.
Example requestπ
curl -X POST \
--url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/0e5fd958-cb2b-43f0-b67f-13ac5c805bad/update' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {AUTH_TOKEN}' \
--data-raw '{
"operation": "REMOVE",
"metadata": [
{
"type": "LIVEBOARD",
"identifiers": [
"6fee1adb-1c50-4c15-8d49-4fe0503d0b34"
]
}
]
}'
API responseπ
If the API request is successful, the object specified in the API request is removed from the Collection.
Example requestπ
curl -X POST \
--url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/0e5fd958-cb2b-43f0-b67f-13ac5c805bad/update' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {AUTH_TOKEN}' \
--data-raw '{
"operation": "REPLACE",
"metadata": [
{
"type": "LIVEBOARD",
"identifiers": [
"6fee1adb-1c50-4c15-8d49-4fe0503d0b34",
"87328d32-2bf0-4fc4-ac51-a738712d7e79"
]
},
{
"type": "COLLECTION",
"identifiers": [
"6d85c77c-4822-42ba-8074-6306a90ba8e1"
]
}
]
}'
API responseπ
If the API request is successful, the objects in the Collection are replaced with the objects in this API request.
Share a Collectionπ
|
Note
|
Collections sharing via the security API is available from ThoughtSpot Cloud 26.6.0.cl. |
To share a Collection with a user or group, send a POST request to the POST /api/rest/2.0/security/metadata/share endpoint with metadata_type set to COLLECTION.
Collections support dual permissions that let you set independent access levels for the Collection and the objects within it.
Permission fieldsπ
| Field | Applies to | Description |
|---|---|---|
| Collection | Controls access to the Collection itself β view, edit, or delete the Collection.
Accepted values: |
| Collection content | Controls access to the objects within the Collection β Liveboards, Answers, Models, and nested Collections.
Accepted values: Only applicable when |
Permission scenariosπ
| Role | share_mode | content_share_mode | What the principal can do |
|---|---|---|---|
|
| Full control β manage the Collection and edit its contents |
|
| Manage the Collection structure but cannot edit objects within it |
|
|
Edit objects within the Collection but cannot change the Collection itself |
|
| View the Collection and its contents only |
Share a Collection (read-only)π
To share a Collection with a user in read-only mode, send the following request:
curl -X POST \
--url 'https://{ThoughtSpot-Host}/api/rest/2.0/security/metadata/share' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {AUTH_TOKEN}' \
--data-raw '{
"metadata_type": "COLLECTION",
"metadata_identifiers": ["Sales reports"],
"permissions": [
{
"principal": {
"type": "USER",
"identifier": "[email protected]"
},
"share_mode": "READ_ONLY"
}
],
"notification": {
"message": "I have shared the Sales reports collection with you.",
"notify_on_share": true
}
}'
If the request is successful, the API returns the HTTP 204 No Content status code.
Share a Collection with dual permissionsπ
To give a user different levels of access to the Collection and its contents, set both share_mode and content_share_mode.
curl -X POST \
--url 'https://{ThoughtSpot-Host}/api/rest/2.0/security/metadata/share' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {AUTH_TOKEN}' \
--data-raw '{
"metadata_type": "COLLECTION",
"metadata_identifiers": ["Marketing Analytics"],
"permissions": [
{
"principal": {
"type": "USER",
"identifier": "[email protected]"
},
"share_mode": "MODIFY",
"content_share_mode": "READ_ONLY"
},
{
"principal": {
"type": "USER_GROUP",
"identifier": "Marketing Team"
},
"share_mode": "READ_ONLY",
"content_share_mode": "READ_ONLY"
}
],
"notification": {
"message": "Sharing the Marketing Analytics collection with your team.",
"notify_on_share": true
}
}'
If the request is successful, the API returns the HTTP 204 No Content status code.
Remove Collection accessπ
To remove a userβs access to a Collection, set share_mode to NO_ACCESS:
curl -X POST \
--url 'https://{ThoughtSpot-Host}/api/rest/2.0/security/metadata/share' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {AUTH_TOKEN}' \
--data-raw '{
"metadata_type": "COLLECTION",
"metadata_identifiers": ["Confidential Reports"],
"permissions": [
{
"principal": {
"type": "USER",
"identifier": "[email protected]"
},
"share_mode": "NO_ACCESS"
}
]
}'
If the request is successful, the API returns the HTTP 204 No Content status code.
Delete a Collectionπ
To remove an existing Collection, send a POST request to the POST /api/rest/2.0/collections/delete API endpoint.
Request parametersπ
In your POST request body, include the following parameters:
| Parameter | Description |
|---|---|
| String. Required. GUID of the Collection to be deleted. |
| String. Optional. Set to |
| String. Optional. Set to true to preview the deletion process without removing any objects. The response lists the items that would be deleted, so you can review them before proceeding with actual deletion. |
Example requestπ
To review your deletion request without actually deleting the Collection and its objects, set dry_run to true and delete_children to true.
curl -X POST \
--url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/delete' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {AUTH_TOKEN}' \
--data-raw '{
"collection_identifiers": [
"6996b262-8733-4af6-8f8e-8d7faefb5be0"
],
"delete_children": true,
"dry_run": true
}'
API responseπ
If the API request is successful, it gives you a preview of the deletion operation without actually deleting anything.
-
metadata_deleted: List of metadata objects that will be deleted -
metadata_skipped: List of metadata objects that will not be deleted for lack of permissions or other constraints
{"metadata_deleted":[{"type":"COLLECTION","identifiers":[{"id":"6996b262-8733-4af6-8f8e-8d7faefb5be0","name":"Docs Collection"}]},{"type":"LIVEBOARD","identifiers":[{"id":"278d2313-ac3a-44bb-b842-a4c9dff84e68","name":"Demo-lb"},{"id":"1bcdb2c1-e960-4f6b-bbf9-64f3e0cd33b9","name":"Demo-lb1"}]}],"metadata_skipped":[]}
Example requestπ
To delete the Collection and the objects within it, set dry_run to false and delete_children to true.
curl -X POST \
--url 'https://{ThoughtSpot-Host}/api/rest/2.0/collections/delete' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {AUTH_TOKEN}' \
--data-raw '{
"collection_identifiers": [
"6996b262-8733-4af6-8f8e-8d7faefb5be0"
],
"delete_children": true,
"dry_run": false
}'
API responseπ
If the API request is successful, it deletes the Collection and all objects within it for which you have delete permission.
{"metadata_deleted":[{"type":"COLLECTION","identifiers":[{"id":"6996b262-8733-4af6-8f8e-8d7faefb5be0","name":"Docs Collection"}]},{"type":"LIVEBOARD","identifiers":[{"id":"278d2313-ac3a-44bb-b842-a4c9dff84e68","name":"Demo-lb"},{"id":"1bcdb2c1-e960-4f6b-bbf9-64f3e0cd33b9","name":"Demo-lb1"}]}],"metadata_skipped":[]}
Additional referencesπ
-
For information about creating and managing Collections via ThoughtSpot UI, see Collections in ThoughtSpot