Skip to content

Authentication

After this page you can authenticate a request, find every endpoint, and read the headers and errors that come back. Calling a tool is on the next page: Call a tool.

Base URL: https://countviews.com/api/public/v1

Send the key as a bearer token. Nothing else is accepted: a request that also carries a session cookie is 401, and there is no CORS, so keep the key on a server.

curl https://countviews.com/api/public/v1/campaigns \
-H "Authorization: Bearer $COUNTVIEWS_KEY"
Key Looks like Works in
Live cvk_ + 43 characters The real workspace: real campaigns, real money.
Test cvk_test_ + 43 characters A separate test space with made-up money and creators. See Test everything.

A key belongs to a workspace, is shown once when made, and is stored only as a digest. A workspace holds at most 5 live keys. A key acts as the person who made it and never with more rights than they have. Revoke it in the workspace under Agent; the next request is 401.

Method and path Auth What it is
GET /openapi.json none OpenAPI 3.1 for all tools, cached 5 minutes
GET /tools.json key The tools this key can call, in OpenAI function format
POST /call key Run any tool: { "name", "arguments" }. See Call a tool.
POST /mcp key or OAuth The MCP server. Also at https://countviews.com/mcp. See Set up MCP.
GET /campaigns campaigns:read The workspace’s campaigns
GET /campaigns/{slug}/report campaigns:read One campaign’s report
GET /campaigns/{slug}/clips clips:read A campaign’s clips, 100 per page

https://countviews.com/llms.txt is the same API described for language models. A campaign that is not yours answers as one that does not exist.

Header Meaning
X-CountViews-Space test or live: which world the answer came from. Present whenever a key was accepted.
RateLimit-Policy, RateLimit Your read budget as standard fields: quota and window, then what is left and seconds to reset.
Retry-After Seconds to wait, on a 429 or a 503.
Idempotent-Replayed: true The write was already done; this is the first answer again.
Cache-Control: no-store On every answer.

You send, on writes: Idempotency-Key (or the idempotencyKey argument) and Prefer: dry-run (or dryRun: true). See Safe retries. Limits and numbers: Limits.

Every failure has the same shape. Branch on code; the message may be reworded, the code never is.

{
"error": {
"code": "invalid_token",
"message": "Send a valid API token as `Authorization: Bearer cvk_…`.",
"details": {
"next": "Stop. The key is wrong, revoked or its maker left. Tell the human to make a new key in the workspace (API access) or sign in again. Do not retry."
}
}
}

details.next says what to do about this code. A 429 also carries details.retryAfterSec; a 500 carries a reference number in the message. A launch waiting for a person is not an error: it is a 202 (see Call a tool). Every code: Errors.