> ## Documentation Index
> Fetch the complete documentation index at: https://api.globalwebindex.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Transition Guide

> Transition from Spark API v1 to v2

## What you need to change

1. **Nothing, to keep working** — existing v1 calls keep working. You can move at your own pace.
2. **New capabilities are optional** — filters, audience generation, dataset descriptions, survey question discovery and workflow skills can be adopted one at a time.
3. **Real changes** — when you move a call to v2, check [Argument and response changes](#argument-and-response-changes).

## Endpoint mapping

| Client-facing endpoint | v1 | v2 |
| :- | :- | :- |
| Insights from a prompt | `POST /v1/spark-api/generic` | `POST /v2/spark-api/insights/generate` |
| Insight details | `GET /v1/spark-api/generic/insights/{id}` | `GET /v2/spark-api/insights/{id}` |
| Dataset list | `GET /v1/spark-api/datasets` | `GET /v2/spark-api/datasets` |
| Saved audience search | `POST /v1/spark-api/audiences/search` | `POST /v2/spark-api/audiences/search` |

All v2 endpoints are under `https://api.globalwebindex.com/v2/spark-api/`. The new v2 endpoints are listed in the tool mapping below.

## Tool mapping

| v1 endpoint | v2 endpoint | Notes |
| :- | :- | :- |
| `POST /v1/spark-api/generic` | `POST /v2/spark-api/insights/generate` | Discovery; takes a list of prompts (see argument changes below) |
| `GET /v1/spark-api/generic/insights/{id}` | `GET /v2/spark-api/insights/{id}` | Follow-up enrichment; sources and statistics move under `metadata` |
| `GET /v1/spark-api/datasets` | `GET /v2/spark-api/datasets` | Dataset discovery; tree is wrapped in `datasets` |
| `POST /v1/spark-api/audiences/search` | `POST /v2/spark-api/audiences/search` | Find saved audiences; `search_term` is now `query` |
| — | `POST /v2/spark-api/global-filters` | Location and timeframe scope |
| — | `POST /v2/spark-api/audiences/generate` | Create audiences from descriptions |
| — | `POST /v2/spark-api/audiences/join` | Combine two or more audiences into an intersection or a union |
| — | `GET /v2/spark-api/skills` | List workflow skill keys and descriptions |
| — | `GET /v2/spark-api/skills/{key}` | Get the full instructions of a workflow skill |
| — | `POST /v2/spark-api/datasets/explore` | Dataset descriptions and coverage |
| — | `POST /v2/spark-api/taxonomy/explore` | Survey questions and attributes for a topic |

## Argument and response changes

v1 `POST /generic` takes a single string **`prompt`**. v2 **`POST /insights/generate`** takes **`prompts[]`** (1–10 short prompts per request) and returns one result per prompt.

| v1 | v2 |
| :- | :- |
| `prompt` (string) | `prompts[]` (array of strings, 1–10) |
| `chat_id` in the request and response for follow-ups | No `chat_id`. For a follow-up, call `POST /insights/generate` again with the same `enforced_audiences`, `location_codes` and `wave_codes` |
| `docked_audiences` | `enforced_audiences` (up to 10 audience IDs from `POST /audiences/search` or `POST /audiences/generate`) |
| `dataset_code` (string) or `dataset_codes` | `dataset_codes` only |
| Locations and timeframes written in the prompt | `location_codes` and `wave_codes` from `POST /global-filters` |
| `message`, `insights[]` and `sources` at the top level of the response | `results[]`, one object per prompt in the same order as `prompts[]`, each with its own `message`, `insights[]` and `origins` (the v1 `sources` object, renamed) |
| Insight IDs in `insights[].id` | Insight IDs in `results[].insights[].id`; pass them to `GET /insights/{id}` |
| `GET /generic/insights/{id}` returns `insight`, `attributes`, `audiences`, `question_calculations`, `location_groups`, `timeframe_groups` and `datasets` at the top level | `GET /insights/{id}` returns `id`, `title`, `text` and `url`, with `audiences`, `datasets`, `location_groups`, `timeframe_groups` and per-answer `attributes` under `metadata` |
| `GET /datasets` returns an array of tree nodes, with `url` on dataset nodes | `GET /datasets` returns `{ "datasets": [...] }`; dataset help URLs come from `POST /datasets/explore` |
| `POST /audiences/search` takes `search_term` | `POST /audiences/search` takes `query` |
| Errors as `{ "code", "message" }` | Errors as [RFC 9457 problem details](https://api.globalwebindex.com/docs/spark-api/v2/getting-started/errors.md); use `type` to identify the error |
| — | A prompt that fails is reported on its own result (`results[].error` and `results[].message`) in a `200` response; the other prompts still return |
| — | Fields that are not documented are rejected with [`invalid-params`](https://api.globalwebindex.com/docs/spark-api/problems/invalid-params) |

**Custom clients:** build every request from the published [v2 API reference](https://api.globalwebindex.com/docs/spark-api/v2/reference/insights/generate-insights.md) schemas for the endpoints you call. Do not reuse v1 request shapes or hardcode argument shapes from these guides.

## Suggested migration checklist

1. Keep your existing integration running.
2. Point a test client at one v2 endpoint, for example `GET /v2/spark-api/datasets`, with your current API token.
3. Move discovery calls from `POST /v1/spark-api/generic` to `POST /v2/spark-api/insights/generate`, sending `prompts[]` and reading `results[]`.
4. Call `POST /v2/spark-api/global-filters` first and pass `location_codes` and `wave_codes` to audience and insight calls. See [Step 2: Structuring a Query](https://api.globalwebindex.com/docs/spark-api/v2/getting-started/structuring-query.md).
5. Use `POST /v2/spark-api/audiences/search` or `POST /v2/spark-api/audiences/generate` when you need an audience, store its ID, and pass it in `enforced_audiences` instead of `docked_audiences`.
6. Replace `chat_id` follow-ups with new `POST /insights/generate` calls that reuse the same audience IDs and codes.
7. Update error handling to read problem details `type` and per-prompt `results[].error`.

## What stays the same

* API token and authentication: send the same token as `Authorization: Bearer YOUR_API_KEY`. See [Authorization](https://api.globalwebindex.com/docs/spark-api/getting-started/authorization.md)
* v1 routes remain available; existing v1 calls are unchanged

## Related

* [Spark API overview](https://api.globalwebindex.com/docs/spark-api/v2/getting-started/introduction.md)
* [Quickstart](https://api.globalwebindex.com/docs/spark-api/v2/getting-started/authorization.md)
* [Getting started with v1](https://api.globalwebindex.com/docs/spark-api/getting-started/introduction.md)
* [Spark MCP transition guide](https://api.globalwebindex.com/docs/spark-mcp/v2/transition-guide.md)
