API reference

Authentication

Protected API operations require authentication. Operations explicitly documented as public, such as query-type discovery and public status-page reads, do not. Databuddy supports API keys for server-side integrations, session cookies for browser-based apps, and Databuddy account sign-in (OAuth) for interactive MCP clients such as Claude, Claude Code, Codex, Cursor, and VS Code.

API key authentication

Use your API key in the x-api-key header:

bash
curl -H "x-api-key: dbdy_your_api_key_here" \
https://api.databuddy.cc/v1/query/websites

Alternatively, use Bearer token format:

bash
curl -H "Authorization: Bearer dbdy_your_api_key_here" \
https://api.databuddy.cc/v1/query/websites

Getting an API key

  1. Go to Dashboard → Organization settings → API keys
  2. Click Add API key
  3. Enter a descriptive name (e.g. "Production Server", "CI Pipeline")
  4. Select the required scopes
  5. Optionally restrict access to specific websites
  6. Copy and securely store your key. It won't be shown again.

Security note: Store API keys securely. Never commit them to version control or expose them in client-side code.

Agent auth discovery

AI agents can discover Databuddy authentication without scraping this page:

ResourceURL
auth.md walkthroughhttps://www.databuddy.cc/auth.md
API cataloghttps://api.databuddy.cc/.well-known/api-catalog
MCP OAuth metadatahttps://api.databuddy.cc/.well-known/oauth-protected-resource

Interactive MCP clients, such as Claude, Claude Code, Codex, Cursor, and VS Code, sign in with a Databuddy account over OAuth. The authorization server supports MCP authorization with Client ID Metadata Documents, so these clients connect to https://api.databuddy.cc/v1/mcp without a key, and the user approves an organization, websites, and permissions in Databuddy. Scoped API keys sent with x-api-key or Authorization: Bearer remain the way to authenticate the REST API, and they work on MCP for headless use such as scripts, CI jobs, and custom agents built on an MCP SDK. The MCP server does not accept dashboard session cookies. See the MCP server docs for per-client setup.

API key scopes

Scopes control what actions an API key can perform:

ScopePermission
read:dataQuery analytics data, list accessible websites, and read session replays: covers POST /v1/query, POST /v1/query/compile, GET /v1/query/websites, and POST /replays/*
track:eventsSend custom events via POST /track
read:linksRead short links via the link management routes. Link analytics via POST /v1/query with link_id instead requires read:data on a key with global access
write:linksCreate, update, and delete short links
read:monitorsRead uptime monitors and their analytics; also allows uptime query types on POST /v1/query
write:monitorsCreate, update, pause, resume, and delete uptime monitors
read:status_pagesRead status pages, incidents, and monitor visibility
write:status_pagesManage status pages, incidents, and monitor visibility
manage:websitesCreate, update, publish, and delete websites. MCP uses it for goals, funnels, annotations, and investigation replies
manage:flagsManage feature flags and targeting rules
manage:configIntegration config and organization settings

Most integrations only need read:data. Add track:events if you also send events server-side.

The REST reporting recipe uses only read access and shows how to select a website and verify a complete response before scheduling a report.

Access levels

API keys can have two access levels:

Global access

Access all websites in your account or organization. Best for:

  • Internal dashboards
  • Automated reporting
  • Organization-wide analytics

Website-specific access

Access only specified websites. Best for:

  • Third-party integrations
  • Client-specific keys
  • Least-privilege security

Browser-based applications using the Databuddy dashboard session can authenticate automatically via cookies. This works when:

  • Users are logged into the Databuddy dashboard
  • Requests include credentials: 'include'
  • Requests originate from *.databuddy.cc domains
typescript
fetch('https://api.databuddy.cc/v1/query/websites', {
credentials: 'include'
})

Choosing an authentication method

Use caseRecommended method
Server-to-server integrationAPI key (x-api-key)
CI/CD pipelinesAPI key (x-api-key)
Custom dashboards (server-side)API key (x-api-key)
Browser apps on your domainSession Cookie
Third-party applicationsAPI key with limited scope
Interactive MCP clients (Claude, Claude Code, Codex, Cursor, VS Code, ChatGPT)Databuddy account sign-in (OAuth)
MCP from scripts, CI, and custom agentsAPI key (x-api-key)

Authentication errors

Error codeMeaning
AUTH_REQUIREDThe operation needs authentication and none was accepted
ACCESS_DENIEDAuthentication succeeded but the key cannot access the resource or operation

Example error response:

json
{
"success": false,
"error": "Authentication required",
"code": "AUTH_REQUIRED",
"requestId": "req_abc123def456"
}

Best practices

  1. Use environment variables for API keys in code
  2. Rotate keys regularly, especially when team members leave
  3. Use minimal scopes: only request permissions you need
  4. Set expiration dates for temporary integrations
  5. Monitor usage: check API key activity in the dashboard

How is this guide?