{
  "name": "tur-credits",
  "description": "Prepaid micropayments for MCP tools and AI agents. Balance in öre, HTTP 402 and MCP error -32042 when payment is required.",
  "version": "0.1.0",
  "website": "/",
  "documentation": "/developers",
  "llms_txt": "/llms.txt",
  "base_url_env": "PUBLIC_CREDITS_BASE_URL",
  "base_url_note": "Configure the API host via env. Do not hardcode a workers.dev URL with a username.",
  "paywall": {
    "http_status": 402,
    "mcp_error_code": -32042,
    "code": "PAYMENT_REQUIRED"
  },
  "billing": {
    "currency": "öre",
    "starter_credit_ore": 1000,
    "trials_per_tool_per_agent_per_day": 3,
    "agent_client_id": {
      "header": "X-Credits-Client-Id",
      "body_field": "clientId",
      "format": "64 hex SHA-256",
      "fallback": "CF-Connecting-IP when missing or invalid"
    },
    "typical_price_ore": { "min": 100, "max": 200 },
    "topup": {
      "invoice": "live",
      "stripe_checkout_packages_sek": [50, 100, 250],
      "stripe_status": "coming soon"
    }
  },
  "endpoints": [
    {
      "method": "GET",
      "path": "/health",
      "auth": false,
      "description": "Liveness check"
    },
    {
      "method": "POST",
      "path": "/v1/charge",
      "auth": "optional Bearer API key",
      "description": "Atomically check balance and charge for a tool call (free, trial, or paid)"
    },
    {
      "method": "POST",
      "path": "/v1/keys",
      "auth": false,
      "description": "Create API key (balance 0). Starter credit after email verification."
    },
    {
      "method": "GET",
      "path": "/v1/keys/verify",
      "auth": false,
      "description": "Verify email token and grant starter credit when eligible"
    },
    {
      "method": "GET",
      "path": "/v1/:project/balance",
      "auth": "Bearer API key",
      "description": "Current prepaid balance for the project"
    },
    {
      "method": "GET",
      "path": "/v1/:project/usage",
      "auth": "Bearer API key",
      "description": "Usage aggregates by tool"
    },
    {
      "method": "POST",
      "path": "/v1/:project/top-ups",
      "auth": "Bearer API key",
      "description": "Create an invoice top-up request"
    },
    {
      "method": "GET",
      "path": "/v1/:project/trust",
      "auth": false,
      "description": "Trust / discovery block for mcp.json and llms.txt (single project)"
    },
    {
      "method": "POST",
      "path": "/v1/:project/service-orders",
      "auth": false,
      "description": "Service purchase event for service-billed projects"
    }
  ],
  "client": {
    "package": "@tur/credits-client",
    "exports": ["checkAndCharge", "CreditsClient", "withCreditsGate"]
  }
}
