# ThoughtSpot

> Search metadata and data, list liveboards, export liveboard data, and search users in ThoughtSpot through the REST API v2.

Lets an agent query your ThoughtSpot analytics platform through the REST API v2: search metadata (liveboards, worksheets, answers, tags), run search-language queries against a worksheet to get data, list liveboards, export liveboard data, and search users. Use it to pull numbers from your data model or find the right dashboard.

## What it can do

| Method | What it does |
| --- | --- |
| `thoughtspot_metadata_search` | Search metadata objects (LIVEBOARD, ANSWER, LOGICAL_TABLE, CONNECTION, TAG, USER). |
| `thoughtspot_search_data` | Run a ThoughtSpot search-language query against a worksheet/table and return the data. |
| `thoughtspot_liveboards_list` | List liveboards (dashboards) - a convenience wrapper over metadata search. |
| `thoughtspot_liveboard_data` | Export a liveboard (or answer) as CSV, PDF, PNG or XLSX. |
| `thoughtspot_users_search` | Search users, or look one up by GUID/username. |
| `thoughtspot_request` | Generic passthrough to any REST v2 endpoint for full API coverage. |

## How to get your access token

ThoughtSpot REST API v2 uses a bearer access token tied to your cluster host.

1. Note your cluster URL - the address you sign in at, e.g. `https://my.thoughtspot.cloud`. This is your **host**.
2. In ThoughtSpot, open **Develop -> REST API** and use the Playground (or the `auth/token/full` endpoint) to get a **full-access token** ([auth v2 docs](https://developers.thoughtspot.com/docs/api-authv2)).
3. Copy the token. Tokens are time-limited - when one expires, generate a new one and update the field.
4. Paste both the host and the token into FlyMyAI.

## Fields to fill

| FlyMyAI field | Where it comes from |
| --- | --- |
| `THOUGHTSPOT_HOST` | Your cluster URL, e.g. `https://my.thoughtspot.cloud` |
| `THOUGHTSPOT_TOKEN` | ThoughtSpot -> Develop -> REST API -> full-access auth token |

## Troubleshooting

- **`401 Unauthorized`** - the token is wrong or expired (tokens are time-limited). Generate a fresh full-access token.
- **`404` / connection refused** - the host is wrong. Use the full `https://...` cluster URL, not just the subdomain.
- **`searchdata` returns nothing** - check the `logical_table_identifier` (worksheet GUID or exact name) and the search-language `query_string` (e.g. `[revenue] [product] top 5`).
- **Export looks empty / not JSON** - non-CSV formats (PDF/PNG/XLSX) return raw bytes, surfaced under `raw`; ask for CSV for tabular data.

## Links

- [ThoughtSpot REST API v2 reference](https://developers.thoughtspot.com/docs/rest-apiv2-reference)
- [REST API v2 authentication](https://developers.thoughtspot.com/docs/api-authv2)
