# Authentication (/docs/developers/authentication) ## API keys (REST API and SDK) [#api-keys-rest-api-and-sdk] Send your key as a bearer token on every request: ```http Authorization: Bearer qd_live_… ``` - **Owned by an organisation.** A key reads that organisation's data, not a person's. Owners and admins create, edit and revoke keys under **Developers → API keys**. - **Shown once.** QueryDeck stores only a hash. If you lose a key, revoke it and create a new one. - **Read-only.** The only scope today is `read`. - **Optional expiry.** Keys can expire after 30 or 90 days, or never. - **Scoped access.** Each key picks the data sets and properties it may read. Turning on **All properties** includes properties connected later. ### What a key can actually read [#what-a-key-can-actually-read] A request can read what **both** the organisation's data access settings and the key allow. The organisation's settings are checked on every request, so tightening them takes effect on existing keys immediately, without rotating them. | Situation | Response | | --- | --- | | No `Authorization` header | `401 API key required` | | Unknown, revoked or expired key | `401 Invalid or revoked API key` | | Key not enabled for the REST API | `403` | | Data set not shared with the key | `403 Data set … is not shared with this key` | | Property not shared with the key | `404 Property not found` | Never ship a key in browser code or a mobile app. Anyone who has it can read what it allows until you revoke it. ## OAuth (MCP) [#oauth-mcp] MCP clients don't use API keys. When you add QueryDeck to an AI app, it opens a QueryDeck sign-in and consent screen. You choose which organisations the app may read, and QueryDeck issues the app its own read-only token (scope `mcp:read`). See [Connect a client](/docs/developers/mcp/connect/). # Errors (/docs/developers/errors) Errors are JSON with a human-readable `message`: ```json { "message": "Invalid or revoked API key" } ``` Validation errors also list the fields that failed: ```json { "message": "Validation failed", "errors": [{ "field": "days", "message": "Too big: expected number to be <=365" }] } ``` | Status | Meaning | Retry? | | --- | --- | --- | | `400` | The body failed validation | No, fix the request | | `401` | Missing, unknown, revoked or expired key | No | | `403` | The key or organisation doesn't share this data set or channel | No | | `404` | Property not found, or not shared with this key | No | | `429` | Rate limit reached | Yes, after `Retry-After` seconds | | `5xx` | QueryDeck had a problem | Yes, with backoff | # Developer platform (/docs/developers) QueryDeck gives you three read-only ways to reach the data your organisation has synced. All three return the same reports. Webhooks push an event when a sync finishes, so your code can react without polling. HTTPS + JSON, authenticated with an organisation API key. Connect Claude, Cursor and other AI agents. Signs in with OAuth; no key to paste. `@querydeck/sdk`: a typed client for the REST API with retries. Signed `sync.completed` and `sync.failed` events for your endpoints. ## Endpoints [#endpoints] | Surface | URL | | --- | --- | | REST API | `https://api.querydeck.si/v1/public` | | MCP server | `https://mcp.querydeck.si/mcp` | ## What you can read [#what-you-can-read] Access is grouped into **data sets**. Organisation owners and admins choose which data sets each channel (REST API or MCP) may use under **Developers → Data access** in the app. A key or connection can never read more than that. | Data set | Contains | | --- | --- | | `properties` | Connected Search Console properties | | `search_performance` | Clicks, impressions, CTR and position reports | | `ga4_reports` | Landing pages, channels, conversions and LLM referrals | See [Reports](/docs/developers/reports/) for every report you can run. The developer platform is read-only today. Nothing you call through it can change your organisation's data. # Connect a client (/docs/developers/mcp/connect) Every client needs the same URL: ```text https://mcp.querydeck.si/mcp ``` After you add it, the client opens QueryDeck in your browser. Sign in, turn on the organisations the app may read, and approve. 1. Open **Settings → Connectors** in Claude. 2. Choose **Add custom connector**. 3. Name it `QueryDeck`, paste the server URL and save. 4. Choose **Connect** and approve the QueryDeck consent screen. ```bash claude mcp add --transport http querydeck https://mcp.querydeck.si/mcp ``` Then run `/mcp` inside Claude Code and pick **querydeck** to sign in. Add the server to `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (one project): ```json { "mcpServers": { "querydeck": { "url": "https://mcp.querydeck.si/mcp" } } } ``` Cursor shows a **Needs login** prompt for the server; follow it to sign in. Add the server to `.vscode/mcp.json`: ```json { "servers": { "querydeck": { "type": "http", "url": "https://mcp.querydeck.si/mcp" } } } ``` Start the server from the file or the MCP view, and sign in when prompted. Any client that supports **remote MCP servers over Streamable HTTP with OAuth** works. The server advertises its authorization server through the standard metadata, so clients discover sign-in on their own: ```text https://mcp.querydeck.si/.well-known/oauth-protected-resource/mcp ``` ## Try it [#try-it] Ask your agent something like: - *"List my QueryDeck properties."* - *"What were my top keywords on example.com over the last 28 days?"* - *"Compare this month with last month: which queries moved most?"* - *"How much traffic did AI assistants send to my site this quarter?"* ## Troubleshooting [#troubleshooting] | Problem | Fix | | --- | --- | | The agent sees no data tools | Your organisation shares no data sets over MCP. An owner or admin can turn them on under **Developers → Data access**. | | *"Pass organization"* | You connected several organisations. Name one, or ask the agent to call `list_organizations` first. | | *"… does not share … over MCP"* | That organisation turned off this data set for MCP. | | `429` errors | The connection sent more than 120 messages in a minute. Wait a moment. | # MCP server (/docs/developers/mcp) QueryDeck runs a remote [Model Context Protocol](https://modelcontextprotocol.io) server. Once an AI app is connected, you can ask it about your search performance in plain language, for example *"Which pages lost the most clicks this month?"*, and it calls QueryDeck tools to answer from your synced data. | Setting | Value | | --- | --- | | Server URL | `https://mcp.querydeck.si/mcp` | | Transport | Streamable HTTP | | Sign-in | OAuth 2.1, scope `mcp:read` | | Access | Read-only | ## How access works [#how-access-works] 1. You add the server URL to your AI app. 2. The app opens QueryDeck's consent screen. You sign in and choose which of your organisations it may read. 3. The app gets its own token. It never sees your password or an API key. Each organisation's **Developers → Data access** settings decide which data sets MCP may read. The server only lists tools for data sets that at least one connected organisation shares, so the agent never sees tools it can't use. Connected AI apps are listed under **Developers → MCP** in the app, where owners and admins can remove them. Removing a member from an organisation also removes the organisation from that member's connections within a minute. Setup for Claude, Claude Code, Cursor, VS Code and other clients. Every tool the server exposes and its inputs. # Tools (/docs/developers/mcp/tools) All tools are read-only (`readOnlyHint: true`) and return JSON. A tool appears only when at least one connected organisation shares its data set over MCP. ## The `organization` input [#the-organization-input] Data tools take an `organization`: an id or slug from `list_organizations`. - With **one** connected organisation it's optional. - With **several** it's required. ## `list_organizations` [#list_organizations] The organisations this connection can read, with the data sets each one shares. Needs no data set and takes no input. ```json [{ "id": "…", "name": "Acme", "slug": "acme", "datasets": ["properties", "search_performance"] }] ``` ## `list_properties` [#list_properties] Connected properties you can query. Data set: `properties`. | Input | Type | Required | | --- | --- | --- | | `organization` | string | With several organisations | ## `search_performance` [#search_performance] Clicks, impressions, CTR and position by query, page, country or device. Data set: `search_performance`. Same fields as `POST /v1/public/performance/query`. | Input | Type | Default | | --- | --- | --- | | `organization` | string | With one organisation, that one | | `property` | string | Required. Property id or Search Console URL | | `report` | string | `top_performing_keywords` ([all reports](/docs/developers/reports/#search-console-reports)) | | `days` | integer, 1–365 | `28` | ## `compare_periods` [#compare_periods] Diffs the window against the previous window of the same length, by query (the `keyword_movers` report). Data set: `search_performance`. | Input | Type | Default | | --- | --- | --- | | `organization` | string | With one organisation, that one | | `property` | string | Required | | `days` | integer, 1–365 | `28` | ## `ga4_report` [#ga4_report] GA4 landing, channel, conversion and LLM referral reports. Data set: `ga4_reports`. Same fields as `POST /v1/public/ga4/reports`. | Input | Type | Default | | --- | --- | --- | | `organization` | string | With one organisation, that one | | `property` | string | Required | | `report` | string | `landing_channel` ([all reports](/docs/developers/reports/#ga4-reports)) | | `days` | integer, 1–365 | `28` | ## Errors [#errors] A failed tool call returns an MCP tool error (`isError: true`) with a message the agent can read, for example `Organization not found` or `Property not found`. # Quickstart (/docs/developers/quickstart) ### Create an API key [#create-an-api-key] In the app, open **Developers → API keys** and choose **Create API key**. Pick the data sets and properties the key may read. Only organisation owners and admins can create keys. Copy the key when it appears. It starts with `qd_live_` and is **shown only once**. Store it in a secret manager or environment variable: ```bash export QUERYDECK_KEY="qd_live_…" ``` ### List your properties [#list-your-properties] ```bash curl https://api.querydeck.si/v1/public/properties \ -H "Authorization: Bearer $QUERYDECK_KEY" ``` ```json { "properties": [ { "id": "3f2c…", "siteUrl": "sc-domain:example.com", "ga4PropertyId": "properties/123456789" } ] } ``` ### Run a report [#run-a-report] Pass a property's `id` or its `siteUrl`, a [report](/docs/developers/reports/) name and a window in days (1–365, default 28): ```bash curl https://api.querydeck.si/v1/public/performance/query \ -H "Authorization: Bearer $QUERYDECK_KEY" \ -H "Content-Type: application/json" \ -d '{ "property": "sc-domain:example.com", "report": "top_performing_keywords", "days": 28 }' ``` Every report answers in the same envelope: ```json { "property": "sc-domain:example.com", "report": "top_performing_keywords", "days": 28, "rows": [ … ] } ``` ## Next steps [#next-steps] - Use the [TypeScript SDK](/docs/developers/sdk/) instead of raw HTTP. - Connect an AI agent with the [MCP server](/docs/developers/mcp/). - Learn how [keys and access](/docs/developers/authentication/) work. # Rate limits (/docs/developers/rate-limits) | Surface | Limit | Counted per | | --- | --- | --- | | REST API | 120 requests / minute | API key | | MCP | 120 messages / minute | Connection | Limits use fixed one-minute windows. Every REST response carries the current state: | Header | Meaning | | --- | --- | | `X-RateLimit-Limit` | Requests allowed in the window | | `X-RateLimit-Remaining` | Requests left in the window | | `X-RateLimit-Reset` | When the window resets, in Unix seconds | When the window is spent, the API answers `429 Too Many Requests` with a `Retry-After` header in seconds. Wait that long before trying again. The [SDK](/docs/developers/sdk/) does this for you. # Reports (/docs/developers/reports) All reports take the same three inputs: | Field | Type | Notes | | --- | --- | --- | | `property` | string | Property `id` or Search Console URL (`https://example.com/` or `sc-domain:example.com`) | | `report` | string | One of the names below | | `days` | integer | Window length, 1–365. Default `28` | They return `{ property, report, days, rows }`. The response `property` is the canonical Search Console URL, not the id you sent. `days` echoes the resolved window; `1` means yesterday only. Windows cover whole days and always end **yesterday in UTC**. Today's partial data is never included. All numbers are JSON numbers; `ctr` is a 0–1 ratio, not a percentage. ## Search Console reports [#search-console-reports] `POST /v1/public/performance/query`, needs the `search_performance` data set. | Report | What it shows | | --- | --- | | `top_performing_keywords` | Queries with the most impressions, with clicks, CTR and average position | | `top_performing_pages` | Your best-performing pages | | `daily_clicks_impressions` | Clicks and impressions per day | | `search_cannibalization` | Queries where more than one of your pages ranks | | `high_visibility_pages` | Pages with the most impressions, with clicks, CTR and average position | | `keyword_movers` | Queries whose clicks changed most against the previous window | | `position_distribution` | How many queries fall in each average-position band | | `country_breakdown` | Performance by country | | `device_breakdown` | Performance by device | ### Row shapes [#row-shapes] **`top_performing_keywords`** — up to 20 rows, by impressions. | Field | Type | | | --- | --- | --- | | `phrase` | string | Query text | | `clicks` | number | Sum over the window | | `impressions` | number | Sum over the window | | `position` | number | Average position across the days the query appeared | | `ctr` | number | Average CTR, 0–1 | **`top_performing_pages`** — up to 20 rows, one per page. | Field | Type | | | --- | --- | --- | | `page` | string | Page URL | | `phrase` | string | The query from the page's best-position row | | `clicks` | number | | | `impressions` | number | | | `position` | number | | | `ctr` | number | 0–1 | **`daily_clicks_impressions`** — one row per day in the window. ```json { "date": "2026-11-25", "clicks": 1842, "impressions": 48210 } ``` **`search_cannibalization`** — every query with two or more pages. ```json { "phrase": "seo reporting", "pages": ["https://example.com/a", "https://example.com/b"] } ``` **`high_visibility_pages`** — up to 20 rows, by impressions. | Field | Type | | | --- | --- | --- | | `page` | string | | | `clicks` | number | | | `impressions` | number | | | `position` | number | | | `ctr` | number | 0–1 | **`keyword_movers`** — up to 100 rows, by absolute click change. | Field | Type | | | --- | --- | --- | | `phrase` | string | | | `clicks` | number | Current window | | `previousClicks` | number | Equally long window immediately before | | `change` | number | Percent change; `100` when the previous window had no clicks | **`position_distribution`** — exactly one row. ```json { "top3": 120, "top4To10": 480, "top11Plus": 1350, "total": 1950 } ``` Counts are distinct queries by average position over the window. **`country_breakdown`** — up to 10 rows, by clicks. `dimension` is a country code as Google reports it (`usa`, `gbr`, …). ```json { "dimension": "usa", "clicks": 5210, "impressions": 128400 } ``` **`device_breakdown`** — up to three rows: `mobile`, `desktop`, `tablet`. ```json { "dimension": "mobile", "clicks": 7310, "impressions": 201400 } ``` ## GA4 reports [#ga4-reports] `POST /v1/public/ga4/reports`, needs the `ga4_reports` data set and a property linked to GA4. | Report | What it shows | | --- | --- | | `landing_channel` | Landing pages by channel | | `landing_only` | Landing pages | | `source_medium` | Traffic by source / medium | | `events_conversions` | Events and conversions | | `llm_referrals` | Visits referred by AI assistants and LLM chat apps | ### Row shape [#row-shape] Every GA4 report returns the same fields. Rows are aggregated over the window, ordered by sessions, and capped at **20**. | Field | Type | | | --- | --- | --- | | `dims` | object | Dimension values for the report (see below) | | `sessions` | number | | | `users` | number | | | `engagedSessions` | number | | | `conversions` | number | | | `revenue` | number | | | `averageSessionDuration` | number | Seconds, averaged over the window | Dimension keys by report: | Report | `dims` keys | | --- | --- | | `landing_channel` | `landingPagePlusQueryString`, `sessionDefaultChannelGroup` | | `landing_only` | `landingPagePlusQueryString` | | `source_medium` | `sessionSource`, `sessionMedium` | | `events_conversions` | `eventName` | | `llm_referrals` | `sessionSource` | ```json { "dims": { "sessionSource": "chatgpt.com" }, "sessions": 318, "users": 291, "engagedSessions": 214, "conversions": 12, "revenue": 940.5, "averageSessionDuration": 96.4 } ``` `events_conversions` keeps only events with conversions greater than zero. `llm_referrals` is filtered to a known list of AI assistants and chat apps, so its rows are a subset of all traffic, not a partition. Summing any GA4 non-partition report does not give the property total. ## Limits [#limits] | Limit | Value | | --- | --- | | `days` | 1–365 | | Top queries, top pages, high-visibility pages | 20 rows | | Countries | 10 rows | | Devices | Up to 3 rows | | Keyword movers | 100 rows | | GA4 rows | 20 dimensions, by sessions | | Cannibalisation, position distribution, daily series | Not capped | A report window can be longer than the history you synced. Unsynced days simply contribute no rows. Search Console syncs accept up to 180 days per run and GA4 syncs up to 900, while a report accepts at most 365. For the product-side explanation of these numbers, see [Analytics](/docs/product/analytics/) and [Keyword cloud](/docs/product/keywords/). # TypeScript SDK (/docs/developers/sdk) `@querydeck/sdk` wraps the [REST API](/docs/developers/quickstart/) with types for every report. It has no dependencies and runs anywhere `fetch` exists: Node.js 18+, Bun, Deno, and edge runtimes. ## Install [#install] ```bash npm install @querydeck/sdk ``` ```bash pnpm add @querydeck/sdk ``` ```bash yarn add @querydeck/sdk ``` ```bash bun add @querydeck/sdk ``` ## Create a client [#create-a-client] ```ts import { QueryDeck } from '@querydeck/sdk' const qd = new QueryDeck({ apiKey: process.env.QUERYDECK_KEY! }) ``` | Option | Default | | | --- | --- | --- | | `apiKey` | | Required. An [API key](/docs/developers/authentication/) | | `baseUrl` | `https://api.querydeck.si` | API origin; `/v1/public` is added for you | | `maxRetries` | `2` | Retries for `429`, `5xx` and network errors | | `fetch` | global `fetch` | Your own `fetch`, for tests or proxies | ## Methods [#methods] ### `properties.list()` [#propertieslist] ```ts const properties = await qd.properties.list() // [{ id, siteUrl, ga4PropertyId }] ``` ### `performance.query()` [#performancequery] Runs a [Search Console report](/docs/developers/reports/#search-console-reports). ```ts const { rows } = await qd.performance.query({ property: 'sc-domain:example.com', report: 'top_performing_keywords', days: 28, }) ``` ### `ga4.report()` [#ga4report] Runs a [GA4 report](/docs/developers/reports/#ga4-reports). ```ts const { rows } = await qd.ga4.report({ property: 'sc-domain:example.com', report: 'llm_referrals', }) ``` Rows are `Record` by default. Pass your own row type for stronger typing: ```ts type KeywordRow = { phrase: string; clicks: number; impressions: number; position: number; ctr: number } const { rows } = await qd.performance.query({ property, report: 'top_performing_keywords' }) ``` ## Errors and retries [#errors-and-retries] Failed calls throw `QueryDeckError`: ```ts import { QueryDeck, QueryDeckError } from '@querydeck/sdk' try { await qd.properties.list() } catch (error) { if (error instanceof QueryDeckError) { console.error(error.status, error.message, error.retryAfter) } } ``` | Field | | | --- | --- | | `status` | HTTP status, or `0` when the request never got a response | | `message` | The API's error message | | `retryAfter` | Seconds the server asked to wait on a `429`, or `null` | `429` and `5xx` responses and network failures are retried up to `maxRetries` times. The client honours `Retry-After`, and otherwise backs off exponentially from 500 ms. Other `4xx` errors throw immediately. See [Errors](/docs/developers/errors/). # Webhooks (/docs/developers/webhooks) QueryDeck sends signed HTTPS webhooks when a sync finishes. Use them to refresh a cache, start a downstream job or alert a channel without polling the API. The format follows Stripe's webhooks. If you have verified Stripe events before, the same code works here with a different header name. Configure endpoints in the app under **Developers → Webhooks**. Owners and admins can add up to five endpoints per organisation and subscribe each one to one or both events. ## Events [#events] | Event | Fires when | | --- | --- | | `sync.completed` | A Search Console or GA4 sync finished successfully | | `sync.failed` | A sync failed; `error` holds the message recorded on the job | | `webhook.test` | You pressed **Send test event** in the app. You can't subscribe to it | The event is delivered for the whole job, not per date shard. ## Payload [#payload] ```json { "id": "evt_3f9c2a7b1d4e8f60a2b5c7d9", "object": "event", "created": 1795641243, "type": "sync.completed", "livemode": true, "data": { "sync_job": { "id": "816f0f4e-2a2a-4a03-8a2f-2a9f4f1e3b21", "source": "gsc", "site_id": "4e0c4f3a-9b1a-4b7e-9d5f-7c8e2a1b6d40", "site_url": "sc-domain:example.com", "status": "succeeded", "rows_synced": 18422, "error": null } } } ``` - `id` is the same for every endpoint that receives the event. Use it to ignore duplicates. - `created` is a Unix timestamp in seconds. - `livemode` is `true` for real events and `false` for `webhook.test`. - The resource sits under a key named after it (`data.sync_job`), not under Stripe's generic `data.object`. - `source` is `gsc` or `ga4`, and `status` is `succeeded` or `failed`. A `webhook.test` event carries `"data": {"webhook_test": {"endpoint_id": "…", "message": "Webhook connection successful"}}`. ## Signing secret [#signing-secret] Each endpoint has its own secret, which starts with `whsec_`. The app shows it once, when you add the endpoint. Copy it then: QueryDeck can't show it again. Lost it, or think it leaked? Press **Rotate secret**. You get a new secret, and for 24 hours every delivery is signed with both the new and the old one, so you can deploy the new secret without dropping events. ## Signature [#signature] Every request carries: ```http QueryDeck-Signature: t=1795641243,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd Content-Type: application/json User-Agent: QueryDeck-Webhooks/1 ``` | Part | Meaning | | --- | --- | | `t` | Signing timestamp, Unix seconds | | `v1` | Hex HMAC-SHA256 of `"."`, keyed with your `whsec_` secret. During a rotation there are two `v1` values: accept the request if either matches | ### Verify a delivery [#verify-a-delivery] Verify against the **raw request body**, before parsing or re-serialising it. Compare in constant time, and reject timestamps outside a short window (five minutes is reasonable) to stop replays. ```ts import { createHmac, timingSafeEqual } from 'node:crypto' export function isValidDelivery(rawBody: string, header: string, secret: string): boolean { const parts = header.split(',').map((part) => part.split('=') as [string, string]) const timestamp = Number(parts.find(([key]) => key === 't')?.[1]) if (!Number.isFinite(timestamp) || Math.abs(Date.now() / 1000 - timestamp) > 300) return false const expected = createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest() return parts.some( ([key, value]) => key === 'v1' && value.length === 64 && timingSafeEqual(Buffer.from(value, 'hex'), expected), ) } ``` With Express, read the body with `express.raw({ type: 'application/json' })` so the bytes you verify are the bytes QueryDeck signed. Answer with any `2xx` to acknowledge. The response body is ignored. Redirects are not followed, so point the endpoint at the final URL. ## API versions [#api-versions] Each endpoint is pinned to an API version, shown next to its URL in the app. The current version is `2026-11-25`, and new endpoints start on the latest one. When a newer version ships, the app offers **Upgrade** on each endpoint. You upgrade when your handler is ready; there is no way back to an older version. Events already queued keep the version they were queued with, including their retries. Events after the upgrade use the new version. ## Delivery and retries [#delivery-and-retries] - Requests time out after 10 seconds. - A failed delivery is retried up to five times: after 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours. The sixth failure marks it `failed`. - If an endpoint keeps failing for 3 days, QueryDeck disables it and stops sending. The app shows **Disabled after repeated failures**. Fix the endpoint, check it with **Send test event**, then press **Re-enable**. - Deliveries and their attempts are listed on the endpoint in the app. Press **Redeliver** on a finished delivery to send the same event again; the body is identical and only the signature changes. - Events and delivery records are kept for 30 days. - Endpoint URLs must use HTTPS and resolve to public hosts; private and loopback addresses are rejected. Retries can arrive more than once for the same event, so make your handler idempotent on the event `id`. ## Recover missed events [#recover-missed-events] Your endpoint was down for longer than the retries cover? List what you missed with any API key: ```bash curl https://api.querydeck.si/v1/public/events?limit=20 \ -H "Authorization: Bearer $QUERYDECK_API_KEY" ``` ```json { "object": "list", "data": [{ "id": "evt_…", "object": "event", "…": "…" }], "has_more": true } ``` - Events are newest first. `limit` is 1–100 (default 20). - Pass the last `id` you received as `starting_after` to get the next page. - Filter with `type=sync.completed`, `sync.failed` or `webhook.test`. - `GET /v1/public/events/` returns one event. - Events are shown in the latest API version. A key limited to some properties only sees those properties' events. ## Managing endpoints [#managing-endpoints] From **Developers → Webhooks** you can: - add an HTTPS endpoint and choose its events; - send a test event and see the result at once; - rotate the signing secret; - upgrade the API version; - pause it with the **Active** switch, or re-enable it after an auto-disable; - redeliver a finished delivery; - delete it. Deleting an endpoint stops future deliveries and removes its delivery history. # Introduction (/docs) QueryDeck syncs your Google Search Console and Google Analytics 4 data and turns it into reports you can act on. These docs cover the product and the developer platform: the REST API, the MCP server for AI agents, and the TypeScript SDK. What QueryDeck is and how its features work. Read your QueryDeck data from code, scripts and AI agents. Give Claude, Cursor and other MCP clients read-only access to your reports. A typed client for the REST API with retries built in. ## For AI agents [#for-ai-agents] These docs are also published as plain Markdown: - [`/llms.txt`](/llms.txt) lists every page. - [`/llms-full.txt`](/llms-full.txt) holds every page in one file. - Each page has a **Copy Markdown** button and a Markdown copy under `/llms.mdx/docs/.md`. # Analytics (/docs/product/analytics) QueryDeck has two reporting views over the same synced data: - **Command Center** is the daily overview for the active property. - **Analytics** is the detailed board with ranking, geography, device and GA4 breakdowns. Both use the property switcher and the **7D / 28D / 90D** period control. A window covers whole days and ends yesterday in UTC. ## Command Center [#command-center] | Block | What it shows | | --- | --- | | Organic clicks | Total Search Console clicks in the period | | Impressions | Total impressions in the period | | Average CTR | Clicks ÷ impressions as a percentage | | Search momentum | Daily clicks or impressions, switchable, with total, daily average and peak | | Top performing pages | Pages with clicks, impressions, average position, CTR and the query that page ranks best for | | GA4 tiles | Sessions, users and conversions, only when the property has a linked GA4 property | The change line under a KPI is not a comparison with the previous period. QueryDeck splits the selected window in half and compares the recent half with the earlier half. The CTR change is in percentage points, not percent. This is useful for spotting direction inside the window, but it is not a true month-over-month comparison. Some Command Center panels are marked **Sample**: site health, opportunities, AI visibility, workspace activity and recommended next moves. They are illustrative placeholders and are not calculated from your data yet. The clicks, impressions, CTR, trend, top pages and GA4 tiles are real. ## Analytics board [#analytics-board] ### KPIs [#kpis] | KPI | Source | | --- | --- | | Organic clicks, impressions, CTR | Daily Search Console rows | | Average position | Impression-weighted mean across the pages returned by the top-pages report | | Queries | Number of distinct queries in the ranking distribution | | Sessions, conversions | GA4 `landing_channel` rows, only when GA4 is linked | ### Charts and tables [#charts-and-tables] - **Clicks & impressions** is the daily series for the period, with total, daily average and peak. - **Top pages** lists each page with clicks, impressions, average position and CTR. Search Console returns one stored row per page — the row with that page's best average position. - **Ranking distribution** groups distinct queries by average position: **Top 3**, **4–10** and **11+**, with the total query count. - **Countries** shows the top countries by clicks, with each country's share. Search Console reports country codes; QueryDeck displays names for the most common ones. - **Devices** splits mobile, desktop and tablet clicks, with each device's share and CTR. ### GA4 section [#ga4-section] When a property is linked, choose one of five dimension sets: | Option | Rows grouped by | | --- | --- | | Landing page × channel | Landing page and default channel group | | Landing pages | Landing page | | Source / medium | Session source and medium | | Events & conversions | Event name; only events with conversions are kept | | LLM referrals | Session source, limited to known AI assistants and chat apps | The tiles show sessions, users, engaged sessions, conversions, revenue and average session duration. Average session duration is weighted by sessions, so it is a property-level average rather than a sum of per-row seconds. ## Report limits [#report-limits] These limits come from the queries behind the boards. They keep pages fast; they are not plan restrictions. | Report | Limit | | --- | --- | | Top queries | 20, ranked by impressions | | Top pages | 20 pages | | Countries | 10, ranked by clicks | | Devices | Mobile, desktop and tablet | | GA4 table | 20 dimension rows, ranked by sessions | | Cannibalisation | Every query that matches more than one page | | Keyword movers | 100 rows; the keyword view shows the top 5 each way | KPI tiles use the daily series, so they can include traffic from pages or queries that the capped tables do not list. ## Reading the numbers [#reading-the-numbers] - Search Console query reports sum clicks and impressions per query for the period, and average position and CTR over the days the query appeared. Top-pages rows come from one stored query/page row per page, so they are a snapshot rather than a whole-window average. - A query with no impressions in a day contributes no row, so averages are over days where the query appeared. - GA4 report rows are summed over the window. `events_conversions` and `llm_referrals` are not partitions of all traffic, so their totals describe those rows only. - Reports read QueryDeck's stored copy. Run a sync to bring in newer days. For the same data over HTTP, see the [reports reference](/docs/developers/reports/). # Data sync (/docs/product/data-sync) Syncs pull Google data into QueryDeck's own store. Reports, the keyword cloud, the REST API, the SDK and MCP all read that store, so a sync is what makes new days visible everywhere. Syncs start only when someone selects a source and chooses **Sync now**. There is no nightly or hourly schedule today, and disconnecting Google does not delete data that was already imported. ## Run a sync [#run-a-sync] 1. Open **Data Sync**. 2. Select the row for one source: a Search Console property or a linked GA4 property. 3. Pick a **History** window. 4. Choose **Sync now**. Progress streams into the row and the sync log: the current date range, rows stored and the final count. A property's last-sync badge changes to **Up to date** when the run succeeds, or **Sync failed** when it doesn't. You can also sync from the per-property tables under **Integrations → Search Console** and **Integrations → Google Analytics 4**. ## History windows [#history-windows] | Source | Windows | What a run imports | | --- | --- | --- | | Search Console | 7, 30, 90 or 180 days | Daily query and page rows, plus daily country and device totals | | GA4 | 7, 30, 90, 180, 365 or 900 days | Five daily dimension sets: landing page × channel, landing pages, source/medium, events and conversions, and LLM referrals | Both sources stop at **yesterday in UTC**. Search Console windows are fetched one day at a time; GA4 windows are split into 30-day shards and walked dimension set by dimension set. A larger window imports more history but takes longer and uses more Google quota. Start with 30 days, confirm the data looks right, then extend the window when you need the history. ## Rules and limits [#rules-and-limits] - **One run per property at a time.** Starting a second sync for the same site returns a conflict until the first finishes. - **Verified Search Console sites only.** Unverified sites are listed but refused with a 403. - **Owners and admins only.** Editors and viewers can't start syncs. - **Idempotent.** Re-running a window refreshes those days instead of duplicating rows. - **Background continuation.** A long run can stop streaming before the whole window is stored. QueryDeck keeps working in the background and updates the source's last-sync status when the job finishes. - **Connection required.** If Google revoked or expired the credentials, the integration shows **Reconnect required** and syncs fail until you reconnect. ## GA4 quota [#ga4-quota] The GA4 Data API gives each property a daily token allowance. QueryDeck stops a GA4 run cleanly once less than 10% of the day's tokens remain, rather than failing the whole job. The rows fetched so far are kept. The page reports that quota was nearly exhausted and asks you to sync again later. After the daily tokens reset, run the same window again: stored days are refreshed as the sync fills in the rest. ## Failures [#failures] A failed run marks the source **Sync failed** and records the error in the sync log. Common causes and fixes: | Message or symptom | Fix | | --- | --- | | Site is not verified in Search Console | Verify the property in Google Search Console, then refresh the integration | | Not connected to Google Search Console | Reconnect the Google account | | Reconnect Google to grant Analytics access | Reconnect once so the GA4 scope is granted | | No GA4 property linked to this site | Link a property under **Integrations → Google Analytics 4** | | Sync already in progress | Wait for the current run to finish | | Interrupted by restart | Run the sync again | Retries use backoff for transient Google errors. A restart marks any job that was still running as failed, so it never blocks the next run. ## Freshness [#freshness] **Data Sync** shows a freshness strip with the last completed sync per source and its status. Check it before comparing reports or sharing a dashboard, and remember that even a fresh sync ends at yesterday. ## Notifications [#notifications] If your organisation configured webhooks, QueryDeck fires `sync.completed` and `sync.failed` deliveries for finished runs. See [Webhooks](/docs/developers/webhooks/) for the payload and signature check. # Developers area (/docs/product/developers) The **SDK, API & MCP** page in the app is the control room for the [developer platform](/docs/developers/). Owners and admins configure access here; every member can see what exists. ## Data access [#data-access] Access is grouped into data sets: | Data set | Contains | | --- | --- | | `properties` | Connected Search Console properties | | `search_performance` | Clicks, impressions, CTR and position reports | | `ga4_reports` | Landing pages, channels, conversions and LLM referrals | For each channel — **REST API** and **MCP** — the organisation decides: - which data sets the channel may read; - which properties the channel may read, or **All properties**, which also covers properties connected later. A key or MCP connection can only narrow that ceiling, never exceed it. The organisation's settings are checked on every request, so turning a data set or property off takes effect immediately on existing keys and connections. ## API keys [#api-keys] Owners and admins create keys under **API keys**: | Setting | Options | | --- | --- | | Scope | Read only | | Expiry | Never, 30 days or 90 days | | Data sets | Any of the three, or all | | Properties | Selected sites, or all properties | | Channels | REST API | The full token is shown **once**, when the key is created. After that the app shows a masked value (`qd_live_xxxx…last4`). QueryDeck stores only a hash, so a lost key must be revoked and replaced. Keys are read-only today. The write scope and the opportunities, annotations and keyword-cluster data sets are listed in the app as coming soon. ## Usage and request log [#usage-and-request-log] The usage tiles summarise the current month: - API calls, compared with last month; - p95 latency; - error rate and the most common error status; - MCP sessions, with the clients seen. **Calls by endpoint** ranks routes, and **Recent requests** shows a live log of method, route, status, duration, channel and key name. Use it to confirm a deployment is calling the API and to spot failing keys. ## Connected AI apps [#connected-ai-apps] The **MCP** tab lists AI clients connected with OAuth, when they connected and whether you or a teammate approved them. Disconnecting removes this organisation from that app's grant without affecting API keys. MCP connections never see an API key. They sign in through QueryDeck and get their own read-only token. See [Connect a client](/docs/developers/mcp/connect/). ## Webhooks [#webhooks] Owners and admins can add up to **five** HTTPS endpoints and subscribe each to: | Event | Fires when | | --- | --- | | `sync.completed` | A Search Console or GA4 sync finished successfully | | `sync.failed` | A sync failed | Each endpoint gets its own `whsec_` signing secret, shown once when you add it. Every request carries `QueryDeck-Signature`, an HMAC-SHA256 of the timestamp and raw body that you recompute with that secret, the same scheme Stripe uses. The app shows each endpoint's API version and recent deliveries, with attempt counts and response status. From there you can send a test event, rotate the secret and redeliver a finished delivery. Failed deliveries retry with increasing delays and stop after six attempts. An endpoint that keeps failing for 3 days is disabled until you re-enable it. Receivers should answer with a `2xx` within 10 seconds. For the payload, signature format and a verification example, see [Webhooks](/docs/developers/webhooks/). ## Related developer docs [#related-developer-docs] - [Quickstart](/docs/developers/quickstart/) — create a key and make a call. - [Authentication](/docs/developers/authentication/) — how keys and scopes combine. - [Reports](/docs/developers/reports/) — every report the API can run. - [TypeScript SDK](/docs/developers/sdk/) — typed client with retries. # Get started (/docs/product/getting-started) ### Create an organisation [#create-an-organisation] Open **Organisation → New organisation** (or `/org/new/` in the app). The wizard asks for a name and URL, your team size and time zone, then optionally invites teammates. Connecting Google during setup isn't available yet, so the last step just creates the workspace. You connect Google from **Integrations** afterwards. ### Connect Search Console [#connect-search-console] Open **Integrations → Search Console** and choose **Connect Google**. Sign in with a Google account that can read the Search Console properties you want. - QueryDeck asks for read-only access (`webmasters.readonly`). - Every property the account can see is listed, including unverified ones. - You can connect more than one Google account and see all their properties in one workspace. ### Run your first sync [#run-your-first-sync] Open **Data Sync**, select the Search Console row for a property, choose a history window and choose **Sync now**. Progress streams into the page. Pick the window for the data you need: | Window | Good for | | --- | --- | | 7 days | A quick check | | 30 days | The default view in the app | | 90 days | Quarter-over-quarter work | | 180 days | The longest window one GSC sync accepts | Unverified properties and properties whose Google credentials have expired can't sync. The app points at the fix in both cases. ### Link GA4 (optional) [#link-ga4-optional] Open **Integrations → Google Analytics 4**. If no Google account is connected yet, choose **Connect Google** and approve the Analytics read scope, then map each Search Console site to the GA4 property that serves it. If your existing consent predates GA4 support, reconnect once to add that scope. Then sync the GA4 row from **Data Sync**. GA4 windows can be longer than Search Console windows, up to 900 days. ### Open a report [#open-a-report] - **Command Center** summarises the active property over 7, 28 or 90 days. - **Analytics** has the full board, including rankings, countries, devices and the GA4 tables. - **Keyword Cloud** shows queries, branded splits, cannibalisation and movers. Pick a different property from the switcher at the top of each page. QueryDeck does not run a scheduled nightly sync yet. Data changes only when someone runs a sync, so check the freshness strip on **Data Sync** before you rely on a report. Every window ends yesterday in UTC. ## Who can do what [#who-can-do-what] Connecting Google, running syncs and inviting members is limited to owners and admins. Editors and viewers can read the dashboards and reports of every property in the organisation. See [Organisations and members](/docs/product/organisations/) for the full permission picture, or [Data sync](/docs/product/data-sync/) for how imports behave. # What is QueryDeck? (/docs/product) QueryDeck connects to **Google Search Console** and **Google Analytics 4**, syncs the data into your workspace, and gives your team one place to see what changed in search and why. The same synced data is available to code and AI agents through the [REST API](/docs/developers/), the [MCP server](/docs/developers/mcp/) and the [TypeScript SDK](/docs/developers/sdk/). ## How it fits together [#how-it-fits-together] - **Organisations** hold your team, connected properties and settings. Members get a role: Owner, Admin, Editor or Viewer. - **Properties** are your Search Console sites. Each one can be linked to a GA4 property. - **Syncs** import data from Google. Reports, the keyword cloud and the developer surfaces all read from the synced copy. - **Reports** turn the synced rows into the Command Center, the analytics board, the keyword cloud and the API responses. QueryDeck never writes to Google. Search Console access is read-only (`webmasters.readonly`), and GA4 access uses the read-only Analytics scope. ## What you can do [#what-you-can-do] Create a workspace, connect Google, run a sync and open your first report. Clicks, impressions, CTR, rankings, countries, devices and GA4 metrics. Queries sized by impressions, branded splits, cannibalisation and movers. What each sync imports, how long it takes and how failures behave. ## Where the data comes from [#where-the-data-comes-from] | Source | What QueryDeck stores | | --- | --- | | Search Console | Daily clicks, impressions, CTR and average position per query and page, plus daily country and device totals | | GA4 | Daily sessions, users, engaged sessions, conversions, revenue and average session duration per landing page, channel, source/medium, event or LLM referrer | Syncs cover whole days and stop at yesterday in UTC. Today's partial data is never included, so two reports run at different times of day agree with each other. ## Next steps [#next-steps] - New here? Start with [Get started](/docs/product/getting-started/). - Want to read the same data from code? Open the [developer platform](/docs/developers/). # Keyword cloud (/docs/product/keywords) The **Keyword Cloud** reads the Search Console rows already synced for the active property. It always covers the **last 28 days**; the page has no period control, so its window is fixed. ## The cloud and top queries [#the-cloud-and-top-queries] - Each word is sized by impressions over the window. - Selecting a word (or a table row) opens its detail panel: clicks, impressions, average position and CTR. - The table lists up to **20 queries**, ranked by impressions. Position and CTR are averages across the days the query appeared. - The search box filters the cloud and the table together. It matches any part of the query text. If a query is filtered out, its detail panel closes. That prevents the page from showing metrics for a query that is no longer in view. ## Branded and non-branded [#branded-and-non-branded] Branded rules are regular expressions stored **per property**. They power the **All / Branded / Non-branded** filter on the cloud and table. 1. Open **Branded rules** on the Keyword Cloud. 2. Enter one regular expression per line. Rules are case-insensitive. 3. Save. Constraints enforced by the server: | Constraint | Value | | --- | --- | | Rules per property | 20 | | Length of one rule | 200 characters | | Matching | Case-insensitive regular expression | | Invalid patterns | Rejected on save | A query is branded when **any** rule matches. Only owners and admins can save rules. Rules only change how the page filters queries; they do not change the synced data or API responses. ## Cannibalisation [#cannibalisation] The cannibalisation panel lists queries that ranked with **more than one page** in the 28-day window. Each entry shows the competing page paths. Use it to decide which page should own a query, then consolidate or redirect the others. Queries with a single page are omitted, and every multi-page query is listed. ## Movers [#movers] Movers compare the current 28 days with the 28 days immediately before it, per query. Each row shows current clicks, previous clicks and the percentage change. - **Rising** lists the five largest positive changes. - **Declining** lists the five largest negative changes. - The underlying report returns up to 100 queries. - A query with no clicks in the previous window is treated as a 100% increase. Movers explain *what* moved. Pair them with cannibalisation and the ranking distribution on [Analytics](/docs/product/analytics/) to see *why*. ## Freshness [#freshness] The cloud reads stored days, not Google directly. Run a sync to include newer data, and check the freshness strip on [Data sync](/docs/product/data-sync/) before drawing conclusions from a flat or missing series. # Organisations and members (/docs/product/organisations) An organisation (also called a workspace) is the unit that owns properties, members, billing and developer settings. A user can belong to several organisations and switch between them from the sidebar. ## Create and switch [#create-and-switch] - Create one from **Organisation → New organisation**. The creator becomes its Owner. - The organisation you are in is the active workspace. Every page, key and report reads from it. - Your **default workspace** is where you land after signing in. Only you see this setting. You can't delete or leave your default workspace; make another one default first. - Deleting an organisation removes its properties, synced history and membership, and cannot be undone. There is no workspace export yet, so keep your own copy of anything you need first. - Separate client work with separate organisations. Properties, data, developer keys and settings do not cross the boundary. ## Roles [#roles] | Role | Can do | Can't do | | --- | --- | --- | | **Owner** | Everything an Admin can, plus transfer ownership and delete the organisation | — | | **Admin** | Manage members and invitations, connect Google, run syncs, edit properties, manage API keys, data access and webhooks, and handle billing | Transfer ownership, delete the organisation | | **Editor** | Read dashboards, reports and the keyword cloud | Invite people, connect Google, run syncs or change developer settings | | **Viewer** | Read dashboards, reports and the keyword cloud | Everything that changes data or settings | Each organisation has exactly one Owner. Ownership can only be transferred to another Admin, and the transfer swaps the two roles: the old Owner becomes an Admin. The hand-off runs in the background through billing, so the Members page may take a moment to show the new roles. Editors and viewers have the same read access today. No write features are available to either role. ## Invitations [#invitations] 1. An Owner or Admin opens **Organisation → Members** and chooses **Invite member**. 2. They enter an email address and pick **Admin**, **Editor** or **Viewer**. 3. The invitation email is valid for **24 hours**. Pending invitations appear in the members table until they are accepted, resent or revoked. Members are free on every plan. ## Data visibility [#data-visibility] Every member sees every property in the organisation. Per-property member access is not available yet: **Management → Security** lists client data isolation as coming soon. Until it ships, treat an organisation as the access boundary. If two clients must not see each other's data, put them in separate organisations and invite each client only to theirs. ## Leaving an organisation [#leaving-an-organisation] A member who isn't the Owner can leave from **Organisation → Management**. Leaving removes access immediately; the organisation's data stays. The Owner must transfer ownership before leaving. # Properties (/docs/product/properties) A **property** is a Search Console site, stored with its verification level and an optional link to one GA4 property. Everything in the workspace — reports, syncs, keyword data, API responses — is scoped to a property. ## Connect Search Console [#connect-search-console] 1. Open **Integrations → Search Console**. 2. Choose **Connect Google** and approve the read-only request. 3. QueryDeck lists every site the account can access. The list shows the property's Google permission level: | Level | Meaning | | --- | --- | | **Owner** | Full control of the property in Search Console | | **Full user** | Can view most data and settings | | **Restricted** | Limited access; some data may be unavailable | | **Unverified** | The account can't read the property's search data | Sites are visible even when Google's permission is unverified, but QueryDeck refuses to sync them: the sync job returns a 403 and the app explains why. Fix verification in Search Console, then refresh the list. ### Multiple Google accounts [#multiple-google-accounts] Use **Add account** to connect additional Google accounts. All their properties appear together under the same organisation, which is useful when clients keep their own Search Console accounts. Owners and admins manage these connections. **Disconnect** removes one account or every Google connection for the organisation. Already imported data stays. To get fresh data again, reconnect and sync. If Google rejects or expires the stored credentials, the integration shows **Reconnect required**. Until you reconnect, syncs fail. ## Link a GA4 property [#link-a-ga4-property] Open **Integrations → Google Analytics 4** and choose a property for each Search Console site. Owners and admins manage links and Google connections. - Matching is per site. Use the property that serves the same domain or subdomain. - Linking uses the Google connection already on file. If that consent was granted before GA4 support, reconnect once to add the read-only Analytics scope. - Unlinked sites keep working; they simply show Search Console data only. - Removing links keeps the Google connection and already synced GA4 rows. GA4 data is only available after you run a GA4 sync for the linked site. See [Data sync](/docs/product/data-sync/). ## Switching properties [#switching-properties] The property switcher sits at the top of the Command Center, Analytics and Keyword Cloud. It lists the organisation's Search Console sites by host. Changing it reruns every card on the page for the new property. The Keyword Cloud disables the switcher when the organisation has only one site. ## What QueryDeck reads [#what-querydeck-reads] | Google API | Scope | Used for | | --- | --- | --- | | Search Console | `webmasters.readonly` | Queries, pages, countries, devices and verification | | GA4 Admin and Data | `analytics.readonly` | Property list and daily report rows | QueryDeck never requests write access, so it can't change anything in Google.