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 MCP clients such as Claude and Claude 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 Create 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

The MCP server accepts OAuth sign-in: clients that support MCP authorization with Client ID Metadata Documents, such as Claude and Claude Code, connect to https://api.databuddy.cc/v1/mcp without a key and the user approves access in Databuddy. See the MCP server docs. The REST API and other MCP clients, including Cursor and Windsurf, use scoped API keys sent with x-api-key or Authorization: Bearer.

API key scopes

Scopes control what actions an API key can perform:

ScopePermission
read:dataQuery analytics data and list accessible websites: covers POST /v1/query, POST /v1/query/compile, and GET /v1/query/websites
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 unlocks POST /v1/query for uptime query types
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.

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
Claude and Claude Code (MCP)Databuddy account sign-in (OAuth)
Cursor, Windsurf, and other MCP clientsAPI 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?