# REST API

Base URL: `https://app.vozradar.com/rest/v1`. JSON in and out. The full list of endpoints is in the [reference](/en/developers/reference) and the [OpenAPI 3.1 spec](https://app.vozradar.com/rest/v1/openapi.json), which also imports into Postman or Insomnia and generates clients.

## Authentication

Send an API key as a bearer token:

```bash
curl https://app.vozradar.com/rest/v1/me \
  -H "Authorization: Bearer $VOZRADAR_API_KEY"
```

Create keys in the app under **Settings → API keys & MCP**. A key is shown once; VozRadar keeps only its hash.

- **Access.** *Read only* keys can call every `GET`; any other method returns `403 KEY_READ_ONLY`. The same key refuses MCP tools that change data. *Full access* keys can also write.
- **Projects.** A key can see all projects of its workspace or only one. A key limited to one project gets `404` for every other project, as if it did not exist.
- **Who it acts as.** A key acts as the person who created it, with that person's current role in the workspace. If they leave the workspace, the key stops working.
- Access and project are fixed when the key is created. To change them, create a new key and revoke the old one.
- The API accepts API keys only. Browser sessions and cookies do not work on `/rest/v1`, and the API sends no CORS headers: call it from a server, a script or CI.

## Rate limits

Limits are shared by the REST API and MCP.

| Plan | Calls per workspace per hour |
|---|---|
| Free, Get Found, Founder | 3,000 |
| Growth | 10,000 |
| Agency | 30,000 |

Each key can also make at most **120 calls per minute**. Every response carries:

- `X-RateLimit-Limit`: calls allowed in the current hour for the workspace;
- `X-RateLimit-Remaining`: calls left in that hour;
- `X-RateLimit-Reset`: when the hour ends, in Unix seconds.

Over a limit, the API answers `429 RATE_LIMITED` with `Retry-After` (seconds). `GET /usage` shows the hour, the month's answer credits and tracked questions.

Requests are cheap; answers are not. Starting a run spends **answer credits** from your plan, exactly like "Run now" in the app. Reading never spends credits.

## Errors

Every error has the same shape and an `X-Request-Id` header with the same id:

```json
{ "error": { "code": "VALIDATION", "message": "A window can cover at most 92 days", "requestId": "req_…", "reason": "WINDOW_TOO_LONG" } }
```

| Status | `code` | Meaning |
|---|---|---|
| 400 | `VALIDATION` | A parameter or the body is not valid. `reason` names the rule. |
| 401 | `UNAUTHENTICATED` | No valid API key. |
| 402 | `PLAN_REQUIRED` | The plan does not include this, or a plan limit is reached. |
| 402 | `CREDITS_EXHAUSTED` | Not enough answer credits left this month. |
| 403 | `KEY_READ_ONLY` | A read-only key tried to change something. |
| 403 | `FORBIDDEN` | The key's owner has a viewer role. |
| 404 | `NOT_FOUND` | Unknown id, or a project the key cannot see. |
| 405 | `METHOD_NOT_ALLOWED` | The path exists with other methods; see the `Allow` header. |
| 409 | `IDEMPOTENCY_CONFLICT`, `CHANNEL_IN_USE`, … | The request conflicts with the current state. |
| 415 | `UNSUPPORTED_MEDIA_TYPE` | Send bodies as JSON with `Content-Type: application/json`. |
| 413 | `PAYLOAD_TOO_LARGE` | Bodies are limited to 1 MB. |
| 429 | `RATE_LIMITED` | See `Retry-After`. |
| 500 | `INTERNAL` | Our side failed. Retry later; quote `requestId` if you write to us. |

`code` values are stable. `reason` gives the more specific rule and may gain new values.

## Lists and pagination

Lists return `{ "data": [...], "nextCursor": "…" }`. Pass `nextCursor` back as `cursor` to get the next page; it is `null` on the last page. `limit` is 50 by default, 1 to 200. Each list documents its order (questions and answers are newest first). Cursors are opaque: do not build them, and keep the same `limit` for every page of a list (another `limit` with a cursor is a `400`).

## Dates and markets

- `from` and `to` are UTC dates (`2026-10-01`), both included. The default is the last 28 days. A window can cover at most 92 days; a longer one is a `400`.
- `market` takes a market id, a locale (`es-MX`) or a country code (`MX`). Without it, the project's primary market is used. Every market-scoped response names the market it covers in a `market` field. An unknown market is a `404`.
- "About you" questions (questions that name your brand) are left out of rates, as in the app.

## Personas

`GET /projects/{projectId}/personas?market=` lists a market's personas: `id`, `name`, `status`, `version`, `about` (the text sent in front of each question it asks) and `questionIds`. Pass `persona={id}` to `/visibility`, `/heatmap` or `/answers` for that persona's answers only, in its market. Without `persona`, every endpoint returns the market's plain answers, with no persona text. Persona answers are a separate sample: compare them with the plain answers to the same questions, never add them together. Google AI Overview does not run for personas, so it has no persona rate. One answer (`/answers/{id}`) carries `personaId` and `personaVersion`; both are `null` for a plain answer. For a persona answer, `questionText` is the full text sent: the persona text, a blank line, then the question. Personas are read-only over the API.

## Rates

Every rate is an object, never a bare number:

```json
{ "rate": 0.31, "low": 0.22, "high": 0.41, "n": 96, "hits": 30 }
```

- `rate`: the estimate (posterior mean).
- `low`, `high`: the 95% interval. Two rates whose intervals overlap may not differ at all.
- `n`: answers measured; `hits`: answers where it happened.
- With no answers, `rate`, `low` and `high` are `null` and `n` is 0.

How the interval is computed, and why answers that do not name you count, is on the [methodology](/en/methodology) page.

## Idempotent writes

Send an `Idempotency-Key` header (up to 120 characters) on any `POST`. A retry with the same key and the same body within 24 hours gets the first response back, with `Idempotent-Replayed: true`, and does nothing twice. The same key with a different body is `409 IDEMPOTENCY_CONFLICT` with `reason: DIFFERENT_REQUEST`. While the first request is still running, a retry gets `409` with `reason: IN_PROGRESS` and `Retry-After`: wait and retry with the same key; if the first request never finished (our server restarted), the key is taken over after 5 minutes. Responses with `429` or a `5xx` are not kept, so retrying those runs again. Keys are scoped to the API key that sent them.

```bash
curl -X POST https://app.vozradar.com/rest/v1/projects/$PROJECT/runs \
  -H "Authorization: Bearer $VOZRADAR_API_KEY" \
  -H "Idempotency-Key: nightly-2026-10-28" \
  -H "Content-Type: application/json" \
  -d '{"market":"es-MX","engines":["CHATGPT_WEB_APP"],"repetitions":1}'
```

`CHATGPT_WEB_APP` is ChatGPT as people see it in the app. `OPENAI_WEB_SEARCH_API` is ChatGPT API, a separate engine that answers through OpenAI's API with its own models and credits.

## Runs

`POST /projects/{id}/runs` asks the project's tracked questions (or the `questionIds` you pass) on the `engines` you name, and spends answer credits. It returns `202` with the run. Poll `GET /projects/{id}/runs/{runId}` until `status` is `COMPLETED` or `FAILED`, or subscribe a webhook to `RUN_COMPLETED` and `RUN_FAILED`.

## Webhooks

Webhooks are the project's alert channels. Create one with `POST /projects/{id}/webhooks` and the events you want:

| Event | When |
|---|---|
| `RUN_COMPLETED` | A run finished with at least one answer (including scheduled runs). |
| `RUN_FAILED` | A run finished and every question failed. |
| `VISIBILITY_CHANGE` | A significant change, never a single-run fluctuation. |
| `EXPERIMENT_RESULT` | An experiment reached a result. |
| `BUDGET_REACHED` | An AI hit its daily budget; monitoring pauses until tomorrow. |
| `INTEGRATION_ERROR` | Search Console, Google Analytics, PostHog, Bing or GitHub needs attention. |
| `MENTION_CHANGE` | A third-party page that mentions you disappeared, lost its link, turned the link nofollow or can no longer be indexed. The alert carries the page URL, the change and a link to the Mentions tab. |
| `CLIENT_REVIEW` | A client commented on or decided a draft review. Subscribable; its link opens the draft in the app, never the review bearer link. The alert carries a generic summary and a link to the draft in the app; it has no comment text, names or review link. |
| `WATCH` | A watch found a credible change (sent to the watch's own webhooks). |
| `ANALYST_REPEAT` | A repeated analyst question finished. Sent only to the repeat's selected channels; not subscribable. Uses the dedicated body below. |
| `PUBLISH_DRAFT` | A draft to create in your CMS (sent only to the webhook picked when publishing; not subscribable). See [Publishing](/en/developers/publishing). |

The creation response contains the signing **secret**, once. Each delivery is a `POST`:

```json
{ "id": "…", "type": "RUN_COMPLETED", "title": "Run finished", "occurredAt": "2026-10-28T09:00:00Z",
  "project": { "id": "…", "name": "StoryCraft" }, "url": "https://app.vozradar.com/projects/…/runs",
  "data": { "runId": "…", "marketId": "…", "tasks": { "total": 40, "done": 40, "failed": 0 } } }
```

with these headers: `X-VozRadar-Event`, `X-VozRadar-Delivery`, `X-VozRadar-Timestamp` and `X-VozRadar-Signature: v1=<hex HMAC-SHA256 of "timestamp.body">`. Check the signature on the raw body and reject old timestamps:

```js
import crypto from "node:crypto";
function verify(rawBody, headers, secret) {
  const ts = headers["x-vozradar-timestamp"];
  if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const expected = "v1=" + crypto.createHmac("sha256", secret).update(`${ts}.${rawBody}`).digest("hex");
  const sent = [headers["x-vozradar-signature"], headers["x-vozradar-signature-previous"]].filter(Boolean);
  return sent.some((s) => s.length === expected.length && crypto.timingSafeEqual(Buffer.from(s), Buffer.from(expected)));
}
```

```python
import hashlib, hmac, time
def verify(raw_body: bytes, headers, secret: str) -> bool:
    ts = headers["X-VozRadar-Timestamp"]
    if abs(time.time() - int(ts)) > 300:
        return False
    expected = "v1=" + hmac.new(secret.encode(), ts.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    sent = [headers.get("X-VozRadar-Signature"), headers.get("X-VozRadar-Signature-Previous")]
    return any(s and hmac.compare_digest(s, expected) for s in sent)
```

- **Rotating the secret.** `POST /webhooks/{id}/rotate-secret` returns a new secret. For 24 hours, deliveries carry both `X-VozRadar-Signature` (new secret) and `X-VozRadar-Signature-Previous` (old secret), so you can switch without missing events.
- **Retries.** A failed delivery is retried with backoff. After 20 failed deliveries in a row the webhook turns itself off, and the app and the API show `disabledReason: TOO_MANY_FAILURES`. Turning it back on resets the count.
- A webhook that a watch uses cannot be deleted through the API (`409 CHANNEL_IN_USE`).
- `POST /webhooks/{id}/test` sends a `TEST` delivery.

## Repeated analyst questions

`/rest/v1/projects/{projectId}/analyst-repeats` lists and saves weekly or monthly analyst questions. Create, resume and confirmed run-now require a writable team role and an eligible plan. Runs share the analyst message allowance and spending cap. Client seats and Viewers can list repeats but cannot change them. Full configuration is required on PATCH; `market: null` selects all markets. Pause, delete, take-over and channel removal remain available after a downgrade. Run-now requires `?confirm=true`, is limited to once per repeat per ten minutes, and does not retry.

A selected webhook receives `X-VozRadar-Event: ANALYST_REPEAT` with the usual delivery ID, timestamp and signatures. Unlike general alert envelopes, its body is:

```json
{
  "event": "ANALYST_REPEAT",
  "repeatId": "…",
  "runId": "…",
  "question": "Which competitor gained citations?",
  "market": null,
  "period": {"from": "2026-10-27T08:00:00Z", "to": "2026-11-03T08:00:00Z"},
  "answerMarkdown": "The answer, cut at a paragraph within 1,500 characters…",
  "truncated": true,
  "read": {"tools": ["get_visibility"], "market": null, "from": "2026-10-27T08:00:00Z", "to": "2026-11-03T08:00:00Z", "n": 24},
  "suggestedFixes": 1,
  "conversationUrl": "https://app.vozradar.com/projects/…/overview?analyst=…"
}
```

The conversation URL requires sign-in and project team access. It is never a share link. Skipped runs send nothing. Delivery retries use the existing bounded alert outbox.

## Versioning

`/v1` only changes by adding things: new endpoints, new optional parameters, new fields, new event types and new `reason` values. Ignore fields you do not know. Anything we must remove is announced first in the [changelog](/en/developers/changelog), and the endpoint answers with `Deprecation` and `Sunset` headers until it goes. A breaking change would ship as `/v2`.

Fix details include `markupChecks`: one result per checked page, with status, a plain reason, rule details, attempt count and check times. A markup result does not prove a change in AI visibility.
