{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentWeb Runtime API",
    "version": "0.9.0",
    "description": "AgentWeb is the action index for the web: real sites indexed as callable, verified actions for AI agents. Reliable web execution without browsing, with proof of every step. This API exposes supported workflows through protocol-native action maps, REST helpers, and MCP tools.",
    "contact": {
      "name": "AgentWeb workflow mapping",
      "url": "mailto:support@agentweb.us",
      "email": "support@agentweb.us"
    }
  },
  "servers": [
    {
      "url": "https://mcp.agentweb.us",
      "description": "AgentWeb production runtime"
    },
    {
      "url": "https://www.agentweb.us",
      "description": "AgentWeb public agent-discovery surface"
    },
    {
      "url": "https://agentweb-telemetry.andreymarey20.workers.dev",
      "description": "AgentWeb privacy-preserving agent traffic telemetry"
    }
  ],
  "security": [
    {
      "AgentWebApiKey": []
    }
  ],
  "tags": [
    {
      "name": "Discovery",
      "description": "Unauthenticated metadata for agents and integration scanners."
    },
    {
      "name": "Runtime",
      "description": "Runtime endpoints for reading pages and discovering mapped workflows."
    },
    {
      "name": "Onboarding",
      "description": "Agent-native registration and API key bootstrap."
    },
    {
      "name": "MCP",
      "description": "MCP Streamable HTTP transport and public tool metadata."
    },
    {
      "name": "Agent Traffic",
      "description": "Privacy-preserving attribution for agent-originated discovery and conversion events."
    },
    {
      "name": "Billing",
      "description": "Dodo hosted checkout, signed fulfillment, customer billing, credit balances, and execution-credit contracts."
    },
    {
      "name": "Policy",
      "description": "Policy, sandbox, action catalog, and schema map metadata for agents."
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "Runtime health check",
        "description": "Returns runtime status and version. Agents may call this before attempting MCP or REST integration.",
        "operationId": "getHealth",
        "security": [],
        "responses": {
          "200": {
            "description": "Runtime is healthy.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "examples": {
                  "ok": {
                    "value": {
                      "status": "ok",
                      "version": "0.9.0"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/mcp/server-card.json": {
      "get": {
        "tags": [
          "Discovery",
          "MCP"
        ],
        "summary": "Public MCP server card",
        "description": "Machine-readable MCP server identity, auth model, tool manifest URL, and onboarding links. This endpoint is public so agents can understand AgentWeb before authenticating.",
        "operationId": "getMcpServerCard",
        "security": [],
        "responses": {
          "200": {
            "description": "MCP server metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpServerCard"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/mcp": {
      "get": {
        "tags": [
          "Discovery",
          "MCP"
        ],
        "summary": "Well-known MCP discovery alias",
        "description": "Alias that returns the AgentWeb MCP server card with mcpUrl, serverUrl, transport, OAuth metadata, and public tool manifest links.",
        "operationId": "getMcpWellKnown",
        "security": [],
        "responses": {
          "200": {
            "description": "MCP server metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpServerCard"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/mcp.json": {
      "get": {
        "tags": [
          "Discovery",
          "MCP"
        ],
        "summary": "Well-known MCP discovery JSON",
        "description": "JSON alias that exposes the AgentWeb MCP URL for scanners that probe /.well-known/mcp.json.",
        "operationId": "getMcpWellKnownJson",
        "security": [],
        "responses": {
          "200": {
            "description": "MCP server metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpServerCard"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/mcp/tools.json": {
      "get": {
        "tags": [
          "Discovery",
          "MCP"
        ],
        "summary": "Public MCP tool manifest",
        "description": "Lists safe metadata for AgentWeb MCP tools, including input schemas, output schemas, auth requirements, and example calls. Tool metadata is public; execution may require credentials.",
        "operationId": "getMcpTools",
        "security": [],
        "responses": {
          "200": {
            "description": "MCP tool metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpToolsManifest"
                }
              }
            }
          }
        }
      }
    },
    "/api/read": {
      "get": {
        "tags": [
          "Runtime"
        ],
        "summary": "Read a public page as structured content",
        "description": "Fetches a public URL and returns clean text, links, forms, and metadata. Use this instead of generic fetch when an agent needs structured web context. Free up to 20 reads an hour per account, then priced like one action and refunded if the fetch fails. Requires an aw_ API key \u2014 anonymous calls receive 401.",
        "operationId": "readPage",
        "security": [
          {
            "AgentWebApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "Public URL to fetch.",
            "schema": {
              "type": "string",
              "format": "uri"
            },
            "example": "https://example.com/pricing"
          },
          {
            "name": "selector",
            "in": "query",
            "required": false,
            "description": "Optional CSS selector for focused extraction.",
            "schema": {
              "type": "string"
            },
            "example": "main"
          }
        ],
        "responses": {
          "200": {
            "description": "Structured page content.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PageReadResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "Not enough balance for a metered read (error.code INSUFFICIENT_CREDITS with the top-up URL in error.credits). Nothing was charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The account is restricted from billed actions (error.code BILLING_ACCOUNT_RESTRICTED), or the user is over a usage cap set in the partner dashboard (USAGE_CAP_EXCEEDED, standing in error.usage_cap). Nothing was charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamFailure"
          },
          "503": {
            "description": "The billing ledger could not document a metered read, so it did not run (error.code BILLING_UNAVAILABLE). Nothing was charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Runtime"
        ],
        "summary": "Read a public page as structured content",
        "description": "POST variant for clients that prefer JSON request bodies. Free up to 20 reads an hour per account, then priced like one action and refunded if the fetch fails. Requires an aw_ API key \u2014 anonymous calls receive 401.",
        "operationId": "readPagePost",
        "security": [
          {
            "AgentWebApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PageReadRequest"
              },
              "examples": {
                "pricing": {
                  "value": {
                    "url": "https://example.com/pricing",
                    "selector": "main"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured page content.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PageReadResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "Not enough balance for a metered read (error.code INSUFFICIENT_CREDITS with the top-up URL in error.credits). Nothing was charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The account is restricted from billed actions (error.code BILLING_ACCOUNT_RESTRICTED), or the user is over a usage cap set in the partner dashboard (USAGE_CAP_EXCEEDED, standing in error.usage_cap). Nothing was charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamFailure"
          },
          "503": {
            "description": "The billing ledger could not document a metered read, so it did not run (error.code BILLING_UNAVAILABLE). Nothing was charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/discover": {
      "get": {
        "tags": [
          "Runtime"
        ],
        "summary": "Discover mapped workflow context for a domain",
        "description": "Returns AgentWeb's learned and/or curated action-map context for a domain. The response keeps the documented top-level map shape; when a curated (verified, executable) map exists it is additionally summarized under the additive `curated` key. Use before execution to determine whether a workflow is supported. Requires an aw_ API key \u2014 anonymous calls receive 401.",
        "operationId": "discoverDomain",
        "security": [
          {
            "AgentWebApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "example.com"
          }
        ],
        "responses": {
          "200": {
            "description": "Known map context or an explicit unmapped response.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ActionMap"
                    },
                    {
                      "$ref": "#/components/schemas/DiscoverEmptyResponse"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": [
          "Runtime"
        ],
        "summary": "Discover mapped workflow context for a domain",
        "operationId": "discoverDomainPost",
        "security": [
          {
            "AgentWebApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiscoverRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Known map context or an explicit unmapped response.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ActionMap"
                    },
                    {
                      "$ref": "#/components/schemas/DiscoverEmptyResponse"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "description": "Returns AgentWeb's learned and/or curated action-map context for a domain. The response keeps the documented top-level map shape; when a curated (verified, executable) map exists it is additionally summarized under the additive `curated` key. Use before execution to determine whether a workflow is supported. Requires an aw_ API key \u2014 anonymous calls receive 401."
      }
    },
    "/api/execute": {
      "post": {
        "tags": [
          "Runtime"
        ],
        "summary": "Execute a mapped site action",
        "description": "Runs one of the verified actions AgentWeb has learned for a supported domain and returns a typed result. Get exact action names and parameter keys from /api/discover first. Costs ~1 credit per completed action; failed actions are refunded. Requires an aw_ API key \u2014 there is no anonymous lane.",
        "operationId": "executeAction",
        "security": [
          {
            "AgentWebApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Idempotent retry identity. Retries with the same key map to the same billing task, so a retried call can never be charged twice. Takes precedence over the body's idempotency_key.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExecuteRequest"
              },
              "examples": {
                "search": {
                  "value": {
                    "domain": "example.com",
                    "action": "search_products",
                    "params": {
                      "query": "desk lamp",
                      "page": 1
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The action completed. Billing fields report the real charge and post-settlement balance when the account is metered.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body (bad domain/action/params shapes), or the action rejected its parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "Not enough credits (error.code INSUFFICIENT_CREDITS). Nothing ran and nothing was charged; error.credits carries the checkout guidance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The action needs a connected account (error.code AUTH_REQUIRED with a connect URL in error.auth), the account is restricted from billed actions (BILLING_ACCOUNT_RESTRICTED), or the user is over a usage cap set in the partner dashboard (USAGE_CAP_EXCEEDED, standing in error.usage_cap).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ExecuteErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "No action map for the domain (error.code MAP_NOT_FOUND) or no such action on it (error.code ACTION_NOT_FOUND, with did-you-mean suggestions in the message).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "A name in an id param could not be resolved to one id (error.code PARAM_UNRESOLVED). The action never ran and its credit was refunded; error.resolve names the param, its status (ambiguous, no_match, unresolvable, budget, step_failed) and the candidates to choose from, resolved.steps lists the reads that ran and were charged, and credits_charged / balance_remaining report them.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "description": "The upstream site failed the action (error.code UPSTREAM_ERROR / UPSTREAM_APP_ERROR / PAGE_CHANGED / PARSE_ERROR). The reservation was refunded; error carries a trace_id for support.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/sites": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "List supported sites' maps, A to Z",
        "description": "Every map AgentWeb supports, one row per map: a site's own map and each of its regional maps (e.g. ikea.com/de/de) are separate rows sharing host. Sorted by brand name, then host, then the host's own map before its regions; group rows by host to show one entry per site. Walk pages with cursor, or fetch one letter's pages for an A-Z view. The cursor is the position after the last row served, so a walk stays complete when maps are published between calls. Counts come in pairs: maps (what the cursor walks) and sites (distinct hosts, what a grouped list shows). Public: no API key, any origin may call it from a browser (CORS preflights are answered for any origin). Answers are cached for about a minute.",
        "operationId": "listSites",
        "security": [],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Case-insensitive substring of the name or map key."
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Category key, from categories in any page."
          },
          {
            "name": "letter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z#]$"
            },
            "description": "A-Z, or # (URL-encoded as %23) for names starting with a digit or symbol."
          }
        ],
        "responses": {
          "200": {
            "description": "One page of sites.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SiteDirectoryPage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/api/sites/{map_key}": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "Get one map",
        "description": "Exactly the requested map (a host's own map, or a regional key such as ikea.com%2Fde%2Fde), with every action's full parameter list. 404 when that map does not exist. Public: no API key, any origin may call it from a browser (CORS preflights are answered for any origin). Answers are cached for about a minute.",
        "operationId": "getSiteMap",
        "security": [],
        "parameters": [
          {
            "name": "map_key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "A map_key from the list, URL-encoded.",
            "example": "ikea.com%2Fde%2Fde"
          }
        ],
        "responses": {
          "200": {
            "description": "The map.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SiteDirectoryMapDetail"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "No such map."
          }
        }
      }
    },
    "/api/usage": {
      "get": {
        "tags": [
          "Runtime"
        ],
        "summary": "Check balance, action price and metering policy",
        "description": "Returns the spendable balance of the account that pays for this key (the org pool under shared billing), the unit and price of one action, the effective plan, and the account-level metering mode.",
        "operationId": "getUsage",
        "security": [
          {
            "AgentWebApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current balance and billing policy.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/register": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Start agent-native API key registration",
        "description": "Sends a verification code to the provided email and returns a deviceId needed for /api/verify. Show the human AgentWeb's Terms and Privacy Policy before completing signup. MCP callers should prefer agentweb_start_api_key_signup, which wraps this endpoint. This allows compatible agents to bootstrap API access without guessing the signup flow.",
        "operationId": "registerEmail",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterRequest"
              },
              "examples": {
                "email": {
                  "value": {
                    "email": "operator@example.com"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification code sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RegisterResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/api/verify": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Verify registration and return API key",
        "description": "Verifies an email code and returns an AgentWeb API key plus MCP setup command when provisioning is available. Complete only after the human has reviewed AgentWeb's Terms and Privacy Policy. MCP callers should prefer agentweb_complete_api_key_signup, which wraps this endpoint.",
        "operationId": "verifyEmail",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyRequest"
              },
              "examples": {
                "code": {
                  "value": {
                    "email": "operator@example.com",
                    "code": "123456",
                    "deviceId": "6f86a0d4-4f91-42e6-8cf6-8bf8922d64aa"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Email verified and credentials returned or dashboard fallback supplied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerifyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/agent/identity": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Start one-link agent onboarding",
        "description": "Returns a device_code, user_code, and verification URI. The agent shows only the verification URI to the human, then polls /oauth2/token with the device_code while the customer signs in once. Email-only agent signup is not supported.",
        "operationId": "startAgentIdentity",
        "security": [],
        "responses": {
          "200": {
            "description": "One-link onboarding started.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentIdentityStartResponse"
                }
              }
            }
          }
        }
      }
    },
    "/agent/identity/claim": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Connect an agent signup code",
        "description": "Called by the AgentWeb browser app after the user signs in. It approves the pending device_code for the authenticated user so the original agent conversation can resume by polling.",
        "operationId": "claimAgentIdentity",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentIdentityClaimRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Code connected.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentIdentityClaimResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/oauth2/token": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Exchange connected device code",
        "description": "Exchanges a connected device_code for an AgentWeb aw_ key and welcome_message. Pending devices return authorization_pending.",
        "operationId": "exchangeAgentIdentityToken",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentIdentityTokenRequest"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/AgentIdentityTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Credential returned once.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentIdentityTokenResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "tags": [
          "MCP"
        ],
        "summary": "MCP Streamable HTTP endpoint",
        "description": "Handles MCP Streamable HTTP requests. Unauthenticated callers receive one-link onboarding JSON. OAuth-capable clients also receive a WWW-Authenticate challenge, while Claude Code receives the one-link flow without that header. Use /.well-known/mcp/tools.json for unauthenticated tool metadata.",
        "operationId": "mcp",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MCP response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Authentication required. The response body includes one-link onboarding instructions. OAuth-capable clients also receive WWW-Authenticate; Claude Code does not.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/telemetry/agent-event": {
      "post": {
        "tags": [
          "Agent Traffic"
        ],
        "summary": "Record an agent-originated attribution event",
        "description": "Records how an agent discovered AgentWeb, which protocol and discovery surface it used, what business it asked about, and the conversion state. Raw prompts, raw IPs, payment credentials, and private customer payloads are not stored.",
        "operationId": "recordAgentTrafficEvent",
        "servers": [
          {
            "url": "https://agentweb-telemetry.andreymarey20.workers.dev"
          }
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentTrafficEvent"
              },
              "examples": {
                "event": {
                  "value": {
                    "event_id": "evt_123",
                    "session_id": "5d87c8e2-0f16-46ef-9cc1-9b0cc742f441",
                    "agent_protocol": "a2a",
                    "discovery_surface": "a2a_agent_card",
                    "task_type": "execute_curated_action",
                    "business_domain": "example.com",
                    "conversion_state": "scan_requested",
                    "privacy_redactions": [
                      "ip_hashed_server_side",
                      "raw_prompt_not_stored",
                      "payment_details_not_stored"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/billing/account": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Read the authenticated customer's plan, credits, and action receipts",
        "description": "Returns the authoritative Supabase credit account for the signed-in customer. Responses are private and never cached.",
        "operationId": "getBillingAccount",
        "servers": [
          {
            "url": "https://www.agentweb.us"
          }
        ],
        "security": [
          {
            "CustomerAccessToken": []
          }
        ],
        "parameters": [
          {
            "name": "checkout_intent",
            "in": "query",
            "required": false,
            "description": "Opaque checkout-intent UUID added by the server to a successful Dodo return URL. Confirmation is resolved only for this authenticated customer's exact intent.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current billing account and recent action receipts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "account"
                  ],
                  "properties": {
                    "account": {
                      "$ref": "#/components/schemas/BillingAccount"
                    },
                    "checkout_confirmation": {
                      "$ref": "#/components/schemas/BillingCheckoutConfirmation"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/UpstreamFailure"
          }
        }
      }
    },
    "/api/billing/catalog": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Read the active public billing catalog",
        "description": "Returns Supabase-authoritative SKUs, prices, credit grants, intervals, and slider tiers. Provider product and add-on IDs are never exposed.",
        "operationId": "getBillingCatalog",
        "servers": [
          {
            "url": "https://www.agentweb.us"
          }
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Active customer-safe catalog.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "catalog"
                  ],
                  "properties": {
                    "catalog": {
                      "$ref": "#/components/schemas/BillingPublicCatalog"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/UpstreamFailure"
          }
        }
      }
    },
    "/api/billing/customer-portal": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Create a Dodo customer portal session",
        "description": "Creates a Dodo-hosted portal URL for the authenticated customer's server-resolved billing customer. Callers cannot submit customer IDs or return URLs.",
        "operationId": "createBillingCustomerPortal",
        "servers": [
          {
            "url": "https://www.agentweb.us"
          }
        ],
        "security": [
          {
            "CustomerAccessToken": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "maxProperties": 0,
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dodo-hosted customer portal URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "portal_url"
                  ],
                  "properties": {
                    "portal_url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "No billing customer exists for the authenticated account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/UpstreamFailure"
          }
        }
      }
    },
    "/api/billing/auto-topup": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Read auto top-up settings and saved cards",
        "description": "Returns the authenticated customer's server-resolved billing account auto top-up settings, the card on file behind its mandate, this month's auto top-up spend and any refill in flight. Pass ?mandate=<reference> after returning from the mandate checkout to drain pending Dodo events first. Organization members without billing rights are refused.",
        "operationId": "getBillingAutoTopup",
        "servers": [
          {
            "url": "https://www.agentweb.us"
          }
        ],
        "security": [
          {
            "CustomerAccessToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Auto top-up state for the billing account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingAutoTopupState"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/UpstreamFailure"
          }
        },
        "parameters": [
          {
            "name": "mandate",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The mandate reference returned by /api/billing/auto-topup-mandate; drains the webhook queue before reading."
          }
        ]
      },
      "put": {
        "tags": [
          "Billing"
        ],
        "summary": "Save auto top-up settings",
        "description": "Stores when the balance refills, to what amount and under which monthly cap (before tax), for the authenticated customer's server-resolved billing account. Turning auto top-up on requires an active mandate, evaluates the balance at once and may start a refill; turning it off never needs the provider.",
        "operationId": "putBillingAutoTopup",
        "servers": [
          {
            "url": "https://www.agentweb.us"
          }
        ],
        "security": [
          {
            "CustomerAccessToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingAutoTopupSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Auto top-up state after the save, with the outcome of the immediate evaluation when auto top-up is on.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingAutoTopupState"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "The chosen card is not saved for the billing customer, or the ledger refused the settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "auto_topup_mandate_required",
                        "auto_topup_customer_required",
                        "auto_topup_unmetered_account",
                        "auto_topup_requires_cents",
                        "auto_topup_canary_only",
                        "auto_topup_threshold_invalid",
                        "auto_topup_target_invalid",
                        "auto_topup_monthly_limit_invalid"
                      ]
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/UpstreamFailure"
          }
        }
      }
    },
    "/api/billing/auto-topup-mandate": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Start saving a card for auto top-up",
        "description": "Creates a Dodo-hosted mandate checkout for the authenticated customer's server-resolved billing account: the customer enters a card once and nothing is charged. The webhook activates the mandate; the Credits page polls GET /api/billing/auto-topup?mandate=<reference> on return. Organization members without billing rights are refused.",
        "operationId": "startBillingAutoTopupMandate",
        "servers": [
          {
            "url": "https://www.agentweb.us"
          }
        ],
        "security": [
          {
            "CustomerAccessToken": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "maxProperties": 0,
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dodo-hosted mandate checkout URL and the reference the Credits page polls for.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "checkout_url",
                    "reference"
                  ],
                  "properties": {
                    "checkout_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "reference": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "A card is already on file, or the ledger refused the mandate.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "auto_topup_mandate_active",
                        "auto_topup_canary_only"
                      ]
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/UpstreamFailure"
          }
        }
      }
    },
    "/api/billing/auto-topup-card": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Change the card behind auto top-up",
        "description": "Creates a Dodo-hosted page to replace the payment method on the authenticated customer's active auto top-up mandate. Refused without an active mandate.",
        "operationId": "changeBillingAutoTopupCard",
        "servers": [
          {
            "url": "https://www.agentweb.us"
          }
        ],
        "security": [
          {
            "CustomerAccessToken": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "maxProperties": 0,
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dodo-hosted payment method URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "payment_url"
                  ],
                  "properties": {
                    "payment_url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "No active auto top-up mandate exists for the billing account.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "auto_topup_mandate_required"
                      ]
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/UpstreamFailure"
          }
        }
      }
    },
    "/api/billing/refund": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Request an audited Dodo refund",
        "description": "Requests a refund for an authenticated customer's exact payment. Only entirely unspent top-ups can be automated. Partial, consumed, duplicate, and review-required cases are recorded without caller-directed credit mutation.",
        "operationId": "requestBillingRefund",
        "servers": [
          {
            "url": "https://www.agentweb.us"
          }
        ],
        "security": [
          {
            "CustomerAccessToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Stable key for one customer-authorized mutation. Reuse it only for the same request.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 160,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "payment_id",
                  "reason"
                ],
                "properties": {
                  "payment_id": {
                    "type": "string",
                    "pattern": "^pay_[A-Za-z0-9_-]+$"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 1000
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Refund completed or an idempotent completed request returned.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingRefundResult"
                }
              }
            }
          },
          "202": {
            "description": "Refund processing or audited operator review is pending.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingRefundResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamFailure"
          },
          "503": {
            "$ref": "#/components/responses/UpstreamFailure"
          }
        }
      }
    },
    "/api/billing/create-checkout-session": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Create a Dodo hosted checkout session",
        "description": "Accepts only the customer-safe SKU of a pay-as-you-go balance block. Product IDs, prices, currencies, quantities, discounts, tax values, and cart hashes are resolved server-side from the versioned Supabase catalog.",
        "operationId": "createBillingCheckoutSession",
        "servers": [
          {
            "url": "https://www.agentweb.us"
          }
        ],
        "security": [
          {
            "CustomerAccessToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Stable key for one checkout attempt. Reuse it only for the same SKU.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 160,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingCheckoutRequest"
              },
              "examples": {
                "payg500": {
                  "value": {
                    "sku": "payg_500"
                  }
                },
                "payg1000": {
                  "value": {
                    "sku": "payg_1000"
                  }
                },
                "payg2000": {
                  "value": {
                    "sku": "payg_2000"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dodo-hosted checkout session.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingCheckoutResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamFailure"
          },
          "503": {
            "$ref": "#/components/responses/UpstreamFailure"
          }
        }
      }
    },
    "/api/billing/webhook": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Receive signed Dodo billing webhook events",
        "description": "Dodo webhook-id, webhook-signature, and webhook-timestamp headers are verified against the exact raw body before durable inbox ingestion, idempotent processing, and Supabase-authoritative credit fulfillment.",
        "operationId": "handleDodoBillingWebhook",
        "servers": [
          {
            "url": "https://www.agentweb.us"
          }
        ],
        "security": [
          {
            "DodoWebhookSignature": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DodoWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dodo signature verified and event accepted or already processed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DodoWebhookResponse"
                }
              }
            }
          },
          "202": {
            "description": "Signed Dodo event durably queued for processing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DodoWebhookResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/UpstreamFailure"
          }
        }
      }
    },
    "/.well-known/action-catalog.json": {
      "get": {
        "tags": [
          "Discovery",
          "Policy"
        ],
        "summary": "Public action catalog",
        "description": "Lists allowed and disallowed AgentWeb action families, fields, auth requirements, and verification semantics.",
        "operationId": "getActionCatalog",
        "security": [],
        "responses": {
          "200": {
            "description": "Action catalog.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/sandbox.json": {
      "get": {
        "tags": [
          "Discovery",
          "Policy"
        ],
        "summary": "Public sandbox metadata",
        "description": "Self-serve and sandbox signals for public scans, tool metadata, and registration.",
        "operationId": "getSandboxMetadata",
        "security": [],
        "responses": {
          "200": {
            "description": "Sandbox metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/api-catalog": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "RFC 9727 API catalog linkset",
        "description": "Linkset catalog of AgentWeb OpenAPI, MCP, and action catalog resources.",
        "operationId": "getApiCatalog",
        "security": [],
        "responses": {
          "200": {
            "description": "API catalog linkset.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "linkset"
                  ],
                  "properties": {
                    "linkset": {
                      "type": "array"
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/http-message-signatures-directory": {
      "get": {
        "tags": [
          "Discovery",
          "Policy"
        ],
        "summary": "HTTP Message Signatures directory",
        "description": "Web Bot Auth compatible public signing-key directory for AgentWeb-originated agent discovery messages.",
        "operationId": "getHttpMessageSignaturesDirectory",
        "security": [],
        "responses": {
          "200": {
            "description": "HTTP message signatures directory.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "keys"
                  ],
                  "properties": {
                    "keys": {
                      "type": "array"
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/schemamap.xml": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "NLWeb schema map",
        "description": "XML schema map linking the AgentWeb OpenAPI and action-map schemas with the MCP tool and action catalog feeds.",
        "operationId": "getSchemaMap",
        "security": [],
        "responses": {
          "200": {
            "description": "Schema map XML.",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/mcp/apps.json": {
      "get": {
        "tags": [
          "Discovery",
          "MCP"
        ],
        "summary": "Public MCP Apps manifest",
        "description": "MCP Apps resources and recommended AgentWeb tools for delegated auth and Agent Map execution.",
        "operationId": "getMcpAppsManifest",
        "security": [],
        "responses": {
          "200": {
            "description": "MCP Apps metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "AgentWebApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "aw_<key>",
        "description": "Use Authorization: Bearer aw_<key>. Agents can create free aw_ keys through one-link onboarding after the customer signs in once. Existing OAuth tokens may still authenticate as awo_ tokens.",
        "x-scopes": {
          "read.public": "Read public pages and metadata.",
          "actions.list": "List approved mapped actions.",
          "actions.execute": "Execute approved mapped actions.",
          "verification.read": "Read receipt and status proof."
        }
      },
      "CustomerAccessToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Supabase JWT",
        "description": "Short-lived authenticated customer session. Email and account identity are derived from this token."
      },
      "DodoWebhookSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "webhook-signature",
        "description": "Dodo signature verified together with webhook-id and webhook-timestamp against the exact raw body."
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid or missing request data.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "string"
            },
            "description": "Seconds until retry is recommended."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "rateLimited": {
                "value": {
                  "error": "Rate limit exceeded. Max 60 requests per hour."
                }
              }
            }
          }
        }
      },
      "UpstreamFailure": {
        "description": "The target URL could not be fetched or parsed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Forbidden origin or caller.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid authorization.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "HealthResponse": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok"
            ]
          },
          "version": {
            "type": "string"
          }
        }
      },
      "PageReadRequest": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "selector": {
            "type": "string"
          }
        }
      },
      "PageReadResponse": {
        "type": "object",
        "required": [
          "title",
          "text",
          "links",
          "forms",
          "metadata"
        ],
        "properties": {
          "title": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PageLink"
            }
          },
          "forms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PageForm"
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "billing": {
            "$ref": "#/components/schemas/BillingBlock",
            "description": "Free while the hourly allowance lasts (free_reads), then charged like one action."
          }
        }
      },
      "PageLink": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "href": {
            "type": "string"
          },
          "rel": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "PageForm": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string"
          },
          "method": {
            "type": "string"
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        },
        "additionalProperties": true
      },
      "DiscoverRequest": {
        "type": "object",
        "required": [
          "domain"
        ],
        "properties": {
          "domain": {
            "type": "string"
          }
        }
      },
      "DiscoverEmptyResponse": {
        "type": "object",
        "required": [
          "domain",
          "message"
        ],
        "properties": {
          "domain": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ActionMap": {
        "type": "object",
        "required": [
          "domain"
        ],
        "properties": {
          "domain": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "auth_model": {
            "type": "object",
            "additionalProperties": true
          },
          "verification": {
            "type": "object",
            "additionalProperties": true
          },
          "curated": {
            "type": "object",
            "description": "Present when a curated (verified, executable) map exists for the domain. Summary shape: domain, version, and actions[{name, description, params}]. Curated actions are callable via /api/execute.",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "ExecuteRequest": {
        "type": "object",
        "required": [
          "domain",
          "action"
        ],
        "properties": {
          "domain": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048,
            "description": "The mapped website domain or regional URL (e.g. \"example.com/it\")."
          },
          "action": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160,
            "description": "Exact action name from the domain's action map (see /api/discover)."
          },
          "params": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "description": "Flat action parameters. Numbers and booleans are coerced to strings."
          },
          "idempotency_key": {
            "type": "string",
            "description": "Idempotent retry identity; the Idempotency-Key header takes precedence when both are sent."
          },
          "fresh": {
            "type": "boolean",
            "description": "true skips a saved copy and reads the site again. Only results whose notes include \"cached\" come from a saved copy; every other read is live."
          }
        },
        "additionalProperties": false
      },
      "ExecuteResponse": {
        "type": "object",
        "required": [
          "ok",
          "result",
          "credits_charged",
          "balance_remaining"
        ],
        "properties": {
          "ok": {
            "const": true
          },
          "result": {
            "$ref": "#/components/schemas/ExecuteResult"
          },
          "credits_charged": {
            "type": "integer",
            "description": "Alias of charged, kept until 2027-01-07."
          },
          "balance_remaining": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Spendable balance after this call, in charge_unit; null when the balance could not be read or the account is unmetered."
          },
          "support_id": {
            "type": "string",
            "description": "Billing receipt id for this action \u2014 quote it in support requests. Present only on metered calls."
          },
          "charge_unit": {
            "type": "string",
            "enum": [
              "credit",
              "cent"
            ],
            "description": "Unit of charged and balance_remaining."
          },
          "charged": {
            "type": "integer",
            "description": "Units settled for this action; 0 when the runtime did not meter this call."
          },
          "balance_usd": {
            "type": "number",
            "description": "Dollar value of balance_remaining."
          },
          "unmetered": {
            "type": "boolean",
            "description": "Present and true when the account that pays is unmetered: nothing is charged, charged is 0 and there is no balance to report."
          },
          "usage_caps": {
            "type": "object",
            "description": "Present when the user has usage caps: session and day standings with cap_cents, used_cents and resets_at."
          }
        }
      },
      "ExecuteResult": {
        "type": "object",
        "required": [
          "domain",
          "action",
          "data",
          "duration_ms",
          "map_version"
        ],
        "properties": {
          "domain": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "data": {
            "type": [
              "object",
              "null"
            ],
            "description": "Typed action result: {\"kind\": \"table\", \"results\": [...], \"count\": n} for tabular parsers, {\"kind\": \"json\", \"value\": ...} for JSON projections; null when the payload lives in raw."
          },
          "outcome": {
            "type": "object",
            "description": "Job-level outcome truth for actions whose step-success can diverge from job completion (status complete/partial/unavailable, missing_step, proof)."
          },
          "raw": {
            "type": "object",
            "description": "Raw upstream body, status, and headers when the action's parser is \"raw\"."
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "fetched_at": {
            "type": "string",
            "format": "date-time",
            "description": "Reads only: when the site's answer was received. For a result whose notes include \"cached\", when the saved copy was read."
          },
          "source_url": {
            "type": "string",
            "description": "Only on a successful read whose action names a public page: the page on the site where a person can check the answer, filled from your own params. It is not the address the answer was fetched from. Absent on failures and on every other result."
          },
          "duration_ms": {
            "type": "integer"
          },
          "map_version": {
            "type": "string",
            "description": "Version of the curated action map that served this call."
          },
          "resolved": {
            "$ref": "#/components/schemas/ResolvedBlock"
          }
        },
        "additionalProperties": true
      },
      "ResolvedBlock": {
        "type": "object",
        "description": "In-call resolution of name-shaped params: present only when a param was resolved or a producer read ran.",
        "required": [
          "params",
          "steps",
          "duration_ms"
        ],
        "properties": {
          "params": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "param",
                "from",
                "via",
                "value",
                "confidence"
              ],
              "properties": {
                "param": {
                  "type": "string"
                },
                "from": {
                  "type": "string",
                  "description": "action.output the value came from."
                },
                "via": {
                  "type": "string",
                  "enum": [
                    "value",
                    "exact",
                    "exact_first",
                    "memory",
                    "constant",
                    "paired",
                    "jev",
                    "passthrough"
                  ]
                },
                "value": {
                  "type": "string",
                  "description": "The id that replaced the caller's value; pass it next time to skip the resolution."
                },
                "label": {
                  "type": "string"
                },
                "confidence": {
                  "type": "number"
                },
                "alternatives": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ResolveCandidate"
                  }
                }
              }
            }
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "action",
                "ok",
                "credits"
              ],
              "properties": {
                "action": {
                  "type": "string"
                },
                "ok": {
                  "type": "boolean"
                },
                "duration_ms": {
                  "type": "integer"
                },
                "cached": {
                  "type": "boolean"
                },
                "credits": {
                  "type": "integer"
                },
                "receipt_id": {
                  "type": "string"
                },
                "error": {
                  "type": "string"
                }
              }
            }
          },
          "duration_ms": {
            "type": "integer"
          }
        }
      },
      "ResolveCandidate": {
        "type": "object",
        "required": [
          "value",
          "label"
        ],
        "properties": {
          "value": {
            "type": "string"
          },
          "label": {
            "type": "string"
          }
        }
      },
      "ExecuteErrorResponse": {
        "type": "object",
        "required": [
          "ok",
          "error"
        ],
        "properties": {
          "ok": {
            "const": false
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "MAP_NOT_FOUND",
                  "ACTION_NOT_FOUND",
                  "INVALID_PARAMS",
                  "PARAM_UNRESOLVED",
                  "CURATED_MAP_STALE",
                  "RATE_LIMITED",
                  "UPSTREAM_ERROR",
                  "UPSTREAM_APP_ERROR",
                  "PAGE_CHANGED",
                  "TIMEOUT",
                  "PARSE_ERROR",
                  "AUTH_REQUIRED",
                  "AUTH_MISCONFIGURED",
                  "PAYMENT_DECLINED",
                  "PAYMENT_NOT_SUPPORTED",
                  "INSUFFICIENT_CREDITS",
                  "BILLING_ACCOUNT_RESTRICTED",
                  "BILLING_UNAVAILABLE",
                  "USAGE_CAP_EXCEEDED"
                ]
              },
              "message": {
                "type": "string"
              },
              "auth": {
                "type": "object",
                "description": "AUTH_REQUIRED only: provider id and connect URL \u2014 show the URL to the user, then retry."
              },
              "credits": {
                "type": "object",
                "description": "INSUFFICIENT_CREDITS only: balance_remaining, credits_required, charge_unit, checkout_url, safe_to_retry."
              },
              "usage_cap": {
                "type": "object",
                "description": "USAGE_CAP_EXCEEDED only: scope (session or day), cap_cents, used_cents, resets_at, safe_to_retry. A per-user cap set in the partner dashboard; nothing ran and nothing was charged."
              },
              "resolve": {
                "type": "object",
                "description": "PARAM_UNRESOLVED only (and a producer step's own failure): param, value, from, status (ambiguous, no_match, unresolvable, budget, step_failed), candidates (value plus label), of, needs, step.",
                "required": [
                  "param",
                  "status"
                ],
                "properties": {
                  "param": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string"
                  },
                  "from": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "ambiguous",
                      "no_match",
                      "unresolvable",
                      "budget",
                      "step_failed"
                    ]
                  },
                  "candidates": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ResolveCandidate"
                    }
                  },
                  "of": {
                    "type": "integer"
                  },
                  "needs": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "step": {
                    "type": "object"
                  }
                }
              }
            },
            "additionalProperties": true
          },
          "resolved": {
            "$ref": "#/components/schemas/ResolvedBlock"
          },
          "credits_charged": {
            "type": "integer",
            "description": "Present when resolver steps ran before the failure: the credits those reads charged (the action itself was refunded)."
          },
          "balance_remaining": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Present with credits_charged: spendable credits after those reads."
          },
          "unmetered": {
            "type": "boolean",
            "description": "Present and true when the account that pays is unmetered: nothing is charged, credits_charged is 0 and balance_remaining is null."
          },
          "trace_id": {
            "type": "string",
            "description": "Post-mortem trace id (7-day retention) \u2014 quote it in bug reports."
          },
          "support_id": {
            "type": "string"
          }
        }
      },
      "UsageResponse": {
        "type": "object",
        "required": [
          "balance",
          "plan",
          "metering_mode",
          "balance_source",
          "charge_unit",
          "action_price"
        ],
        "properties": {
          "balance": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Spendable balance of the account that pays for this key, in charge_unit; null when the balance could not be read or the account is unmetered."
          },
          "plan": {
            "type": "string",
            "description": "Effective (payer-aware) plan tier \u2014 org members report their payer's plan."
          },
          "metering_mode": {
            "type": "string",
            "enum": [
              "legacy",
              "canary",
              "all",
              "blocked"
            ],
            "description": "Account-level charging gate: legacy = not yet metered, canary/all = metered, blocked = executes refused."
          },
          "balance_source": {
            "type": "string",
            "enum": [
              "live",
              "session_snapshot",
              "unavailable"
            ],
            "description": "Whether balance is a live ledger read, the key's profile-read snapshot, or unknown."
          },
          "charge_unit": {
            "type": "string",
            "enum": [
              "credit",
              "cent"
            ],
            "description": "Unit of balance and action_price: credits until the balance is converted, US cents after."
          },
          "action_price": {
            "type": "integer",
            "description": "What one completed action costs, in charge_unit."
          },
          "balance_usd": {
            "type": [
              "number",
              "null"
            ],
            "description": "Dollar value of balance."
          },
          "unmetered": {
            "type": "boolean",
            "description": "Present and true when the account that pays is unmetered: nothing is charged, charged is 0 and there is no balance to report."
          },
          "policy": {
            "type": "string",
            "description": "Unmetered accounts only: a sentence to pass on to the user."
          }
        }
      },
      "AgentIdentityStartResponse": {
        "type": "object",
        "required": [
          "device_code",
          "user_code",
          "verification_uri",
          "verification_uri_complete",
          "token_endpoint",
          "expires_in",
          "interval"
        ],
        "properties": {
          "device_code": {
            "type": "string"
          },
          "user_code": {
            "type": "string"
          },
          "verification_uri": {
            "type": "string",
            "format": "uri"
          },
          "verification_uri_complete": {
            "type": "string",
            "format": "uri"
          },
          "token_endpoint": {
            "type": "string",
            "format": "uri"
          },
          "grant_type": {
            "type": "string"
          },
          "expires_in": {
            "type": "integer"
          },
          "interval": {
            "type": "integer"
          },
          "next_tool": {
            "type": "string",
            "example": "agentweb_poll_claim_link_signup"
          },
          "minimum_human_step": {
            "type": "string"
          },
          "customer_instruction": {
            "type": "string"
          },
          "completion_behavior": {
            "type": "string",
            "example": "agent_resumes_by_polling"
          },
          "agent_resume": {
            "type": "object",
            "additionalProperties": true
          },
          "email_only_agent_signup": {
            "type": "string",
            "enum": [
              "not_supported"
            ]
          },
          "security_note": {
            "type": "string"
          },
          "tier": {
            "type": "string",
            "enum": [
              "free"
            ]
          },
          "customer_message": {
            "type": "string"
          },
          "next_step": {
            "type": "string"
          }
        }
      },
      "AgentIdentityClaimRequest": {
        "type": "object",
        "required": [
          "user_code",
          "supabase_access_token"
        ],
        "properties": {
          "user_code": {
            "type": "string"
          },
          "supabase_access_token": {
            "type": "string"
          }
        }
      },
      "AgentIdentityClaimResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "claimed": {
            "type": "boolean"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "tier": {
            "type": "string",
            "enum": [
              "free"
            ]
          }
        }
      },
      "AgentIdentityTokenRequest": {
        "type": "object",
        "required": [
          "device_code"
        ],
        "properties": {
          "grant_type": {
            "type": "string",
            "default": "urn:ietf:params:oauth:grant-type:device_code"
          },
          "device_code": {
            "type": "string"
          }
        }
      },
      "AgentIdentityTokenResponse": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string"
          },
          "token_type": {
            "type": "string",
            "enum": [
              "Bearer"
            ]
          },
          "api_key": {
            "type": "string",
            "description": "Returned once when provisioning succeeds."
          },
          "mcp_url": {
            "type": "string",
            "format": "uri"
          },
          "setup_command": {
            "type": "string"
          },
          "welcome_message": {
            "type": "string"
          },
          "tier": {
            "type": "string",
            "enum": [
              "free"
            ]
          }
        }
      },
      "RegisterRequest": {
        "type": "object",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          }
        }
      },
      "RegisterResponse": {
        "type": "object",
        "required": [
          "ok",
          "deviceId",
          "message"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "deviceId": {
            "type": "string"
          },
          "terms_url": {
            "type": "string",
            "format": "uri"
          },
          "privacy_url": {
            "type": "string",
            "format": "uri"
          },
          "human_acceptance_required": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "VerifyRequest": {
        "type": "object",
        "required": [
          "email",
          "code",
          "deviceId"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "code": {
            "type": "string"
          },
          "deviceId": {
            "type": "string"
          }
        }
      },
      "VerifyResponse": {
        "type": "object",
        "required": [
          "ok",
          "verified",
          "mcp_url",
          "message"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "verified": {
            "type": "boolean"
          },
          "api_key": {
            "type": "string",
            "description": "Returned once when provisioning succeeds."
          },
          "mcp_url": {
            "type": "string",
            "format": "uri"
          },
          "setup_command": {
            "type": "string"
          },
          "terms_url": {
            "type": "string",
            "format": "uri"
          },
          "privacy_url": {
            "type": "string",
            "format": "uri"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "McpServerCard": {
        "type": "object",
        "required": [
          "name",
          "description",
          "url",
          "transport",
          "auth",
          "tool_manifest"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "transport": {
            "type": "string"
          },
          "auth": {
            "type": "object",
            "additionalProperties": true
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tool_manifest": {
            "type": "string",
            "format": "uri"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          }
        },
        "additionalProperties": true
      },
      "McpToolsManifest": {
        "type": "object",
        "required": [
          "name",
          "server",
          "transport",
          "tools"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "server": {
            "type": "string",
            "format": "uri"
          },
          "transport": {
            "type": "string"
          },
          "tools": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/McpTool"
            }
          }
        }
      },
      "McpTool": {
        "type": "object",
        "required": [
          "name",
          "description",
          "auth",
          "input_schema"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "auth": {
            "type": "string",
            "enum": [
              "none",
              "optional",
              "api_key",
              "oauth"
            ]
          },
          "input_schema": {
            "type": "object",
            "additionalProperties": true
          },
          "output_schema": {
            "type": "object",
            "additionalProperties": true
          },
          "example": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "error_description": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "AgentTrafficEvent": {
        "type": "object",
        "required": [
          "session_id",
          "agent_protocol",
          "discovery_surface",
          "conversion_state",
          "privacy_redactions"
        ],
        "properties": {
          "event_id": {
            "type": "string"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "session_id": {
            "type": "string"
          },
          "agent_id": {
            "type": "string",
            "description": "Optional pseudonymous ID; server stores a hash."
          },
          "agent_name": {
            "type": "string"
          },
          "agent_provider": {
            "type": "string"
          },
          "agent_protocol": {
            "type": "string"
          },
          "discovery_surface": {
            "type": "string"
          },
          "entry_url": {
            "type": "string"
          },
          "landing_capability": {
            "type": "string"
          },
          "task_type": {
            "type": "string"
          },
          "business_domain": {
            "type": "string"
          },
          "package_quoted": {
            "type": "string"
          },
          "payment_state": {
            "type": "string"
          },
          "conversion_state": {
            "type": "string"
          },
          "referrer": {
            "type": "string"
          },
          "host": {
            "type": "string"
          },
          "privacy_redactions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": true
      },
      "BillingCheckoutRequest": {
        "type": "object",
        "required": [
          "sku"
        ],
        "properties": {
          "sku": {
            "type": "string",
            "enum": [
              "payg_500",
              "payg_1000",
              "payg_2000"
            ]
          }
        },
        "additionalProperties": false
      },
      "BillingCheckoutResponse": {
        "$ref": "#/components/schemas/DodoBillingCheckoutResponse"
      },
      "DodoBillingCheckoutResponse": {
        "type": "object",
        "required": [
          "checkout_url",
          "checkout_session_id"
        ],
        "properties": {
          "checkout_url": {
            "type": "string",
            "format": "uri"
          },
          "checkout_session_id": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "BillingCheckoutConfirmation": {
        "type": "object",
        "required": [
          "checkout_intent_id",
          "status"
        ],
        "properties": {
          "checkout_intent_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "confirmed",
              "failed"
            ]
          }
        },
        "additionalProperties": false
      },
      "BillingAccount": {
        "type": "object",
        "required": [
          "profile_id",
          "plan",
          "billing_interval",
          "subscription_status",
          "spendable_credits",
          "expiring_credits",
          "non_expiring_credits",
          "reserved_credits",
          "extra_credits_monthly",
          "subscription_change",
          "latest_checkout",
          "recent_actions"
        ],
        "properties": {
          "profile_id": {
            "type": "string",
            "format": "uuid"
          },
          "plan": {
            "type": "string",
            "enum": [
              "free",
              "payg",
              "starter",
              "pro",
              "max",
              "enterprise"
            ]
          },
          "billing_interval": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "monthly",
              "annual",
              null
            ]
          },
          "subscription_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null for pay-as-you-go and enterprise accounts. Only historical subscription rows ever carried a value."
          },
          "spendable_credits": {
            "type": "integer",
            "minimum": 0,
            "description": "Spendable balance in charge_unit."
          },
          "expiring_credits": {
            "type": "integer",
            "minimum": 0
          },
          "non_expiring_credits": {
            "type": "integer",
            "minimum": 0
          },
          "reserved_credits": {
            "type": "integer",
            "minimum": 0
          },
          "extra_credits_monthly": {
            "type": "integer",
            "minimum": 0,
            "maximum": 0,
            "description": "Always 0. Recurring extra credits are no longer sold; the key stays so existing clients keep parsing the account."
          },
          "subscription_change": {
            "type": "null",
            "description": "Always null. Recurring plan changes are no longer sold; the key stays so existing clients keep parsing the account."
          },
          "latest_checkout": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "id",
                  "kind",
                  "sku",
                  "status",
                  "created_at",
                  "updated_at"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "subscription",
                      "topup"
                    ]
                  },
                  "sku": {
                    "type": "string",
                    "enum": [
                      "starter_monthly",
                      "starter_annual",
                      "pro_monthly",
                      "pro_annual",
                      "max_monthly",
                      "max_annual",
                      "topup_400",
                      "topup_1250",
                      "topup_5000",
                      "payg_500",
                      "payg_1000",
                      "payg_2000"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "creating",
                      "created",
                      "succeeded",
                      "failed",
                      "expired"
                    ]
                  },
                  "created_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "updated_at": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "recent_actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ActionReceipt"
            }
          },
          "charge_unit": {
            "type": "string",
            "enum": [
              "credit",
              "cent"
            ],
            "description": "Unit of spendable_credits, expiring_credits, non_expiring_credits, reserved_credits and action_price: credits until the balance is converted, US cents after."
          },
          "action_price": {
            "type": "integer",
            "minimum": 1,
            "description": "What one completed action costs, in charge_unit."
          },
          "unmetered": {
            "type": "boolean",
            "description": "True for comped workspaces: actions are recorded at the price but nothing is deducted."
          }
        },
        "additionalProperties": false
      },
      "ActionReceipt": {
        "type": "object",
        "required": [
          "support_id",
          "action_id",
          "status",
          "credits",
          "started_at",
          "completed_at",
          "verification",
          "provider",
          "error_code"
        ],
        "properties": {
          "support_id": {
            "type": "string",
            "pattern": "^awr_[a-f0-9]{24}$"
          },
          "action_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "reserved",
              "running",
              "completed",
              "failed",
              "reconciliation_required"
            ]
          },
          "credits": {
            "type": "object",
            "required": [
              "quoted",
              "charged"
            ],
            "properties": {
              "quoted": {
                "type": "integer",
                "minimum": 1
              },
              "charged": {
                "type": "integer",
                "minimum": 0
              }
            },
            "additionalProperties": false
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "verification": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "method"
                ],
                "properties": {
                  "method": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "provider": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "reference",
                  "url"
                ],
                "properties": {
                  "reference": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "url": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uri"
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "error_code": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "BillingPublicCatalog": {
        "type": "object",
        "required": [
          "catalog_version_id",
          "catalog_sha256",
          "base_currency",
          "products",
          "addons"
        ],
        "properties": {
          "catalog_version_id": {
            "type": "string",
            "format": "uuid"
          },
          "catalog_sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "base_currency": {
            "type": "string",
            "const": "USD"
          },
          "products": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "sku",
                "kind",
                "plan",
                "billing_interval",
                "amount_cents",
                "credits"
              ],
              "properties": {
                "sku": {
                  "type": "string",
                  "enum": [
                    "starter_monthly",
                    "starter_annual",
                    "pro_monthly",
                    "pro_annual",
                    "max_monthly",
                    "max_annual",
                    "topup_400",
                    "topup_1250",
                    "topup_5000"
                  ]
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "subscription",
                    "topup"
                  ]
                },
                "plan": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "enum": [
                    "starter",
                    "pro",
                    "max",
                    null
                  ]
                },
                "billing_interval": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "enum": [
                    "monthly",
                    "annual",
                    null
                  ]
                },
                "amount_cents": {
                  "type": "integer",
                  "minimum": 1
                },
                "credits": {
                  "type": "integer",
                  "minimum": 1
                }
              },
              "additionalProperties": false
            }
          },
          "addons": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "billing_interval",
                "tier",
                "max_quantity",
                "credits_per_unit",
                "amount_cents_per_unit"
              ],
              "properties": {
                "billing_interval": {
                  "type": "string",
                  "enum": [
                    "monthly",
                    "annual"
                  ]
                },
                "tier": {
                  "type": "string",
                  "enum": [
                    "tier1",
                    "tier2",
                    "tier3"
                  ]
                },
                "max_quantity": {
                  "type": "integer",
                  "minimum": 1
                },
                "credits_per_unit": {
                  "type": "integer",
                  "minimum": 1
                },
                "amount_cents_per_unit": {
                  "type": "integer",
                  "minimum": 1
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      },
      "BillingRefundResult": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string"
          },
          "disposition": {
            "type": "string",
            "enum": [
              "full_unspent_topup",
              "review_required",
              "duplicate"
            ]
          },
          "support_case_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "refund_id": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "DodoWebhookResponse": {
        "type": "object",
        "required": [
          "received"
        ],
        "properties": {
          "received": {
            "type": "boolean"
          },
          "duplicate": {
            "type": "boolean",
            "description": "True when the signed Dodo webhook ID was already processed."
          },
          "queued": {
            "type": "boolean",
            "description": "True when the signed event is durably stored for later processing."
          },
          "quarantined": {
            "type": "boolean",
            "description": "True when signed evidence or immutable commercial terms failed validation and no credits were granted."
          }
        },
        "additionalProperties": false
      },
      "DodoWebhookEvent": {
        "type": "object",
        "description": "Signed Dodo event envelope. AgentWeb verifies the exact raw body before parsing or fulfilling it.",
        "required": [
          "type",
          "timestamp",
          "data"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object"
          }
        },
        "additionalProperties": true
      },
      "BillingBlock": {
        "type": "object",
        "description": "How this call was billed, in the ledger's own unit (charge_unit). credits_charged is an alias of charged kept until 2027-01-07.",
        "properties": {
          "charge_unit": {
            "type": "string",
            "enum": [
              "credit",
              "cent"
            ],
            "description": "Unit of charged, balance_remaining and action_price: credits until the balance is converted, US cents after."
          },
          "charged": {
            "type": "integer",
            "description": "Units settled for this call; 0 when nothing was charged."
          },
          "charged_usd": {
            "type": "number"
          },
          "credits_charged": {
            "type": "integer",
            "description": "Alias of charged."
          },
          "balance_remaining": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Spendable balance in charge_unit; null when it could not be read or the account is unmetered."
          },
          "balance_usd": {
            "type": "number",
            "description": "Dollar value of balance_remaining."
          },
          "action_price": {
            "type": "integer",
            "description": "What one completed action costs, in charge_unit."
          },
          "billing_status": {
            "type": "string",
            "enum": [
              "metered",
              "not_metered"
            ],
            "description": "metered when the call went through a ledger reservation (including an unmetered account's, where charged is 0 and unmetered is true); not_metered otherwise."
          },
          "unmetered": {
            "type": "boolean",
            "description": "Present and true when the account that pays is unmetered: nothing is charged, charged is 0 and there is no balance to report."
          },
          "receipt_id": {
            "type": "string"
          },
          "policy": {
            "type": "string"
          },
          "free_reads": {
            "type": "object",
            "description": "Page reads only: this hour's free allowance.",
            "properties": {
              "used": {
                "type": "integer"
              },
              "limit": {
                "type": "integer"
              },
              "window": {
                "type": "string",
                "enum": [
                  "hour"
                ]
              },
              "resets_at": {
                "type": "string",
                "format": "date-time",
                "description": "When this hour's free allowance resets."
              }
            }
          },
          "usage_caps": {
            "type": "object",
            "description": "Present when the user has usage caps: session and day standings with cap_cents, used_cents and resets_at."
          }
        }
      },
      "BillingAutoTopupSettingsRequest": {
        "type": "object",
        "required": [
          "enabled",
          "threshold_cents",
          "target_cents"
        ],
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "threshold_cents": {
            "type": "integer",
            "minimum": 100,
            "maximum": 100000,
            "description": "Refill when the balance falls below this amount, in US cents."
          },
          "target_cents": {
            "type": "integer",
            "minimum": 600,
            "maximum": 200000,
            "description": "Refill up to this balance, in US cents. At least 500 above threshold_cents."
          },
          "monthly_limit_cents": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 500,
            "maximum": 10000000,
            "description": "Most auto top-up may charge in a UTC calendar month, before tax. Null means no limit."
          }
        },
        "additionalProperties": false
      },
      "BillingAutoTopupSettings": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "threshold_cents": {
            "type": "integer"
          },
          "target_cents": {
            "type": "integer"
          },
          "monthly_limit_cents": {
            "type": [
              "integer",
              "null"
            ]
          },
          "mandate_status": {
            "type": "string",
            "enum": [
              "none",
              "pending",
              "active",
              "cancelled"
            ]
          },
          "mandate_reference": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "dodo_subscription_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "paused_reason": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "payment_failed",
              "payment_method_missing",
              "customer_missing",
              null
            ]
          },
          "consecutive_failures": {
            "type": "integer"
          },
          "next_attempt_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_attempt_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_succeeded_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BillingAutoTopupIntent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "amount_cents": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "creating",
              "created",
              "succeeded",
              "failed",
              "expired"
            ]
          },
          "failure_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BillingAutoTopupState": {
        "type": "object",
        "required": [
          "available",
          "settings",
          "card_label"
        ],
        "properties": {
          "available": {
            "type": "boolean"
          },
          "unavailable_reason": {
            "type": "string",
            "enum": [
              "not_configured",
              "checkout_disabled",
              "canary_only",
              "credits_unit",
              "unmetered"
            ]
          },
          "settings": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BillingAutoTopupSettings"
              },
              {
                "type": "null"
              }
            ]
          },
          "card_label": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer-facing name of the card behind the active mandate, for example Visa ending 4242."
          },
          "charge_unit": {
            "type": "string",
            "enum": [
              "credit",
              "cent"
            ]
          },
          "spendable_cents": {
            "type": "integer"
          },
          "month_start": {
            "type": "string",
            "format": "date-time"
          },
          "month_total_cents": {
            "type": "integer",
            "description": "Auto top-up charges begun or settled since month_start, in US cents."
          },
          "pending_intent": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BillingAutoTopupIntent"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_intent": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BillingAutoTopupIntent"
              },
              {
                "type": "null"
              }
            ]
          },
          "run": {
            "type": "object",
            "description": "Present after a save that turned auto top-up on: what the immediate evaluation did.",
            "properties": {
              "outcome": {
                "type": "string",
                "enum": [
                  "charged",
                  "skipped",
                  "failed",
                  "unavailable"
                ]
              },
              "reason": {
                "type": "string"
              },
              "amount_cents": {
                "type": "integer"
              },
              "paused": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "SiteDirectoryAction": {
        "type": "object",
        "required": [
          "name",
          "kind",
          "description"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The action's name, as passed to execute (and listed by the MCP tools).",
            "example": "search_products"
          },
          "kind": {
            "type": "string",
            "enum": [
              "read",
              "write"
            ]
          },
          "description": {
            "type": "string"
          },
          "outcome": {
            "$ref": "#/components/schemas/SiteDirectoryActionOutcome"
          }
        }
      },
      "SiteDirectoryPage": {
        "type": "object",
        "required": [
          "total",
          "total_sites",
          "count",
          "next_cursor",
          "letters",
          "categories",
          "maps"
        ],
        "properties": {
          "total": {
            "type": "integer",
            "description": "Maps matching q, category and letter, across all pages."
          },
          "total_sites": {
            "type": "integer",
            "description": "Distinct sites (hosts) among them."
          },
          "count": {
            "type": "integer",
            "description": "Maps on this page."
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass as cursor for the next page; null on the last page."
          },
          "letters": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/SiteDirectoryCount"
            },
            "description": "Per letter, maps and sites matching q and category (letter filter ignored): draw an A-Z rail without walking the catalog.",
            "example": {
              "A": {
                "maps": 97,
                "sites": 95
              },
              "#": {
                "maps": 4,
                "sites": 4
              }
            }
          },
          "categories": {
            "type": "array",
            "description": "Categories of the maps matching q, with counts.",
            "items": {
              "allOf": [
                {
                  "type": "object",
                  "required": [
                    "key",
                    "label"
                  ],
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    }
                  }
                },
                {
                  "$ref": "#/components/schemas/SiteDirectoryCount"
                }
              ]
            }
          },
          "maps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SiteDirectoryMap"
            }
          }
        }
      },
      "SiteDirectoryActionOutcome": {
        "type": "object",
        "required": [
          "status"
        ],
        "description": "Present only when the action cannot do its whole job. Absent means the action does what its description says.",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "partial",
              "unavailable"
            ],
            "description": "partial: the action stops short of the job; unavailable: it cannot serve the job right now."
          },
          "missing_step": {
            "type": "string",
            "description": "The exact step the action cannot perform.",
            "example": "Out-of-band payment authorization (3D Secure)."
          }
        }
      },
      "SiteDirectoryCount": {
        "type": "object",
        "required": [
          "maps",
          "sites"
        ],
        "properties": {
          "maps": {
            "type": "integer",
            "minimum": 0,
            "description": "Map rows (what the cursor walks)."
          },
          "sites": {
            "type": "integer",
            "minimum": 0,
            "description": "Distinct sites (hosts): a site with regional maps counts once."
          }
        }
      },
      "SiteDirectoryMapRegion": {
        "type": "object",
        "required": [
          "path",
          "label"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "The map key's path.",
            "example": "/de/de"
          },
          "label": {
            "type": "string",
            "description": "Chip label with the whole locale, so regions stay apart: EN-GB, EN-US, DE-AT; a repeated part collapses (/de/de is DE).",
            "example": "DE"
          }
        }
      },
      "SiteDirectoryMap": {
        "type": "object",
        "required": [
          "map_key",
          "host",
          "name",
          "category",
          "category_label",
          "letter",
          "region",
          "version",
          "action_count",
          "requires_login",
          "connect_providers",
          "partial",
          "actions"
        ],
        "properties": {
          "map_key": {
            "type": "string",
            "description": "The map's key: pass it as the domain to discover/execute and to GET /api/sites/{map_key}.",
            "example": "ikea.com/de/de"
          },
          "host": {
            "type": "string",
            "description": "The site's host. A site's own map and its regional maps share it: group rows by host to show one entry per site.",
            "example": "ikea.com"
          },
          "name": {
            "type": "string",
            "description": "Brand name; derived from the host when the site has no catalog entry.",
            "example": "IKEA"
          },
          "category": {
            "type": [
              "string",
              "null"
            ],
            "description": "Category key; null when the site is uncategorized.",
            "example": "home_lifestyle"
          },
          "category_label": {
            "type": [
              "string",
              "null"
            ],
            "example": "Home & lifestyle"
          },
          "letter": {
            "type": "string",
            "description": "A-Z bucket the name files under, or \"#\" for names starting with a digit or symbol.",
            "example": "I"
          },
          "region": {
            "description": "null for the host's own map; a regional map's path and label.",
            "oneOf": [
              {
                "$ref": "#/components/schemas/SiteDirectoryMapRegion"
              },
              {
                "type": "null"
              }
            ]
          },
          "version": {
            "type": "string",
            "description": "Version of the map.",
            "example": "1.4.0"
          },
          "action_count": {
            "type": "integer",
            "minimum": 0,
            "description": "This map's actions (equals actions.length once loaded)."
          },
          "requires_login": {
            "type": "boolean",
            "description": "Some action runs as the user's own account on the site (see connect_providers)."
          },
          "connect_providers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Account ids to connect with agentweb_start_connection before running signed-in actions."
          },
          "partial": {
            "type": "boolean",
            "description": "Some action does not finish its job end-to-end (see each action's outcome)."
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SiteDirectoryAction"
            }
          }
        }
      },
      "SiteDirectoryMapDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SiteDirectoryMap"
          },
          {
            "type": "object",
            "properties": {
              "actions": {
                "type": "array",
                "items": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SiteDirectoryAction"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "params": {
                          "type": "array",
                          "description": "Every parameter, required first.",
                          "items": {
                            "type": "object",
                            "required": [
                              "name"
                            ],
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "required": {
                                "type": "boolean"
                              },
                              "description": {
                                "type": "string"
                              },
                              "default": {}
                            }
                          }
                        },
                        "auth_provider": {
                          "type": "string",
                          "description": "Account this action runs as, when it needs one."
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        ]
      }
    }
  },
  "externalDocs": {
    "description": "AgentWeb full agent reference",
    "url": "https://www.agentweb.us/llms-full.txt"
  }
}
