← Back to docs

Agency API

The Agency plan includes a REST API for reading site, widget, analytics, and loop data from AskBadge.

Authentication

Generate an API key from /dashboard/settings, then send it in the authorization header.

Authorization: Bearer sk_live_xxxxxxxxxxxxxxxxxxxxx

Rate limit: 1000 requests per day per key. Responses include X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset.

The same Agency API key also works with the AskBadge MCP server for Claude Desktop, Cursor, and other MCP clients.

Endpoints

MethodPathDescription
GET/api/v1/sitesList all sites for the authenticated Agency account.
GET/api/v1/sites/:siteIdReturn one site with widget config and usage counts.
GET/api/v1/sites/:siteId/analytics?days=30Return click analytics, daily trend, and summary stats.
GET/api/v1/sites/:siteId/analytics/loop?days=30Return outbound-to-inbound AI traffic loop data.
GET/api/v1/sites/:siteId/widgetReturn the current widget configuration for that site.

Examples

cURL

curl https://askbadge.com/api/v1/sites \
  -H "Authorization: Bearer sk_live_xxxxxxxxxxxxxxxxxxxxx"

JavaScript

const res = await fetch("https://askbadge.com/api/v1/sites", {
  headers: {
    Authorization: "Bearer " + process.env.ASKBADGE_API_KEY,
  },
})

const data = await res.json()

Python

import os
import requests

res = requests.get(
    "https://askbadge.com/api/v1/sites",
    headers={"Authorization": f"Bearer {os.environ['ASKBADGE_API_KEY']}"},
)

print(res.json())

MCP server

AskBadge ships as a local MCP server so AI assistants can read site, analytics, loop, and widget data directly from your Agency account without browser copy-paste.

Available tools

ToolDescription
list_sitesList all sites in your AskBadge Agency account.
get_siteGet full details for a site, including widget config and counts.
get_analyticsGet click analytics for 7, 30, or 90 days.
get_loop_dataGet AI loop metrics showing outbound clicks and return visits.
get_widget_configGet the current widget configuration for a site.

Claude Desktop

{
  "mcpServers": {
    "askbadge": {
      "command": "npx",
      "args": ["-y", "askbadge-mcp"],
      "env": {
        "ASKBADGE_API_KEY": "sk_live_your_key_here"
      }
    }
  }
}

Cursor

{
  "mcpServers": {
    "askbadge": {
      "command": "npx",
      "args": ["-y", "askbadge-mcp"],
      "env": {
        "ASKBADGE_API_KEY": "sk_live_your_key_here"
      }
    }
  }
}

Local development

cd mcp
pnpm install --ignore-workspace
pnpm build
ASKBADGE_API_KEY=sk_live_your_key_here node dist/index.js

The MCP server is read-only today. Account signup, checkout, verification changes, and site creation still happen in the dashboard or browser flows.