# GENERATED FILE. Do not edit.
#
# Projected from the Zod MCP tool registry in product/mcp/gs.mcp.
# Regenerate:  cd product/mcp/gs.mcp && pnpm openapi:public
# Verify:      cd product/mcp/gs.mcp && pnpm openapi:public:check
openapi: 3.0.3
info:
  title: "GetSales public contract: gs.service.integrations"
  description: |-
    The integrations service: the integration platform (the team's credentials for its own APIs and its CRM grants, the HTTP tools it defines over them, the execution log and the priced catalog of every outbound provider call) and the event plane (the platform-wide webhook subscriptions and the delivery state of each event).

    GENERATED. This document is projected from the Zod MCP tool registry in `product/mcp/gs.mcp` (one tool per public endpoint, 1:1). Do not edit it by hand; edit the tool definition and regenerate with `pnpm openapi:public`.

    Surface: the public `/api` contract of `gs.service.integrations`, 26 operations. This is the only OpenAPI document the platform publishes. Internal (`/internal`) and health endpoints are deliberately absent: they are not part of any contract, they can change without notice, and the service source is their only description.

    Conventions:
    - Auth is a bearer JWT, optionally narrowed by the `Team-SID` header.
    - Every success body is an MCP envelope: `success: true` plus one typed `operation` shape (`search`, `get`, `create`, `update`, `delete`, `metrics`, `group_by`, `action`), and a `meta` block with `trace_id` for support.
    - Every failure is the same `McpError` envelope with a code from a fixed 16-code taxonomy, so a client maps errors once.
    - Lists page with `page_size` (0 to 500, default 50) plus an opaque forward `cursor`; `page_size: 0` returns counts only.
    - On `GET` and `DELETE`, object-valued query parameters (`filter`, `sort`) travel as JSON text and array-valued ones repeat as `name[]=value`.
    - The MCP-only `_meta` field (usage analytics) never reaches the backend and is not part of this contract.
  version: "1.0"
  contact:
    name: GetSales
    url: https://getsales.io
    email: support@getsales.io
  license:
    name: Proprietary
    url: https://getsales.io/terms
servers:
  - url: https://beta.getsales.io/integrations/v1
    description: Production (the gateway path on the beta ring; the origin is provisioned per DEPLOY_MAP.md)
security:
  - BearerJwt: []
    TeamSid: []
tags:
  - name: custom_tools
    description: Registry package `mcp.integrations/custom_tools`, served on MCP mount `integrations.providers`.
  - name: provider_calls
    description: Registry package `mcp.integrations/provider_calls`, served on MCP mount `integrations.providers`.
  - name: provider_connections
    description: Registry package `mcp.integrations/provider_connections`, served on MCP mount `integrations.providers`.
  - name: webhook_logs
    description: Registry package `mcp.integrations/webhook_logs`, served on MCP mount `integrations.webhooks`.
  - name: webhooks
    description: Registry package `mcp.integrations/webhooks`, served on MCP mount `integrations.webhooks`.
paths:
  /api/custom-tools:
    post:
      operationId: create_custom_tool
      summary: Create custom tool
      description: |-
        Define a team HTTP tool in one write, validated whole so the executor can trust the row: the request template (https, a literal public host, placeholders {{key}} in the path, query, header values and body strings), the input_schema that declares every placeholder, the output_mapping of names to dot-paths into the response, and the connection the tool authenticates with (provider custom; omit it for a public API). A vendor the platform ships (OpenAI, Hunter...) is a catalog operation, not a custom tool; an API key goes on a provider connection, never into a header. 422 on an undeclared placeholder, a placeholder in the host, a private or non-https target, an auth-shaped header name; 409 on a duplicate name. Then test_custom_tool.

        Contract:
        - MCP tool `create_custom_tool`, registry package `mcp.integrations/custom_tools`, mount `integrations.providers`.
        - Operation `create`, response envelope `create`.
        - Flags: none.
      tags:
        - custom_tools
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCustomToolRequest"
      responses:
        "200":
          description: "`create` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateCustomToolResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: create_custom_tool
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: custom_tools
      x-gs-operation: create
      x-gs-envelope: create
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: complex
  /api/custom-tools/search:
    post:
      operationId: search_custom_tools
      summary: Search custom tools
      description: |-
        The team's own HTTP tools (in_tl_): the definitions a playtables column, a workflow node or an agent calls as in:tool.{sid}. sid.eq is the point lookup (there is no get), status for the switched-off ones, provider_connection_sid for the tools on one credential; include provider_connection. page_size 0 returns the counts only. Call history and spend are on search_provider_calls (tool_type custom_tool).

        Contract:
        - MCP tool `search_custom_tools`, registry package `mcp.integrations/custom_tools`, mount `integrations.providers`.
        - Operation `search`, response envelope `search`.
        - Flags: read only.
      tags:
        - custom_tools
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SearchCustomToolsRequest"
      responses:
        "200":
          description: "`search` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SearchCustomToolsResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: search_custom_tools
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: custom_tools
      x-gs-operation: search
      x-gs-envelope: search
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/custom-tools/{sid}:
    patch:
      operationId: update_custom_tool
      summary: Update custom tool
      description: |-
        Edit a tool: name, description, the connection, status, and the definition blocks, where a supplied request, input_schema or output_mapping replaces that block WHOLE (templates never merge) and the merged definition is validated again as at create. Callers pick the new definition on their next call: the row is read per execute, never snapshotted. At least one field, else 422 nothing_to_update.

        Contract:
        - MCP tool `update_custom_tool`, registry package `mcp.integrations/custom_tools`, mount `integrations.providers`.
        - Operation `update`, response envelope `update`.
        - Flags: none.
      tags:
        - custom_tools
      parameters:
        - name: sid
          in: path
          required: true
          description: Custom tool sid (in_tl_...).
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^in_tl_
            description: Custom tool sid (in_tl_...).
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateCustomToolRequest"
      responses:
        "200":
          description: "`update` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UpdateCustomToolResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: update_custom_tool
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: custom_tools
      x-gs-operation: update
      x-gs-envelope: update
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: complex
    delete:
      operationId: delete_custom_tool
      summary: Delete custom tool
      description: |-
        Soft-delete a tool: the columns and nodes still naming it fail forward with a custom_tool_not_found row on their next call. Its call history and its connection stay. Idempotent.

        Contract:
        - MCP tool `delete_custom_tool`, registry package `mcp.integrations/custom_tools`, mount `integrations.providers`.
        - Operation `delete`, response envelope `delete_simple`.
        - Flags: dangerous: the MCP layer gates it behind a preview/commit token, and the effect cannot be undone through this API.
      tags:
        - custom_tools
      parameters:
        - name: sid
          in: path
          required: true
          description: The in_tl_* sid of the row to delete.
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^in_tl_
            description: The in_tl_* sid of the row to delete.
      responses:
        "200":
          description: "`delete_simple` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeleteCustomToolResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: delete_custom_tool
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: custom_tools
      x-gs-operation: delete
      x-gs-envelope: delete_simple
      x-gs-availability: ga
      x-gs-dangerous: true
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: trivial
  /api/custom-tools/{sid}/test:
    post:
      operationId: test_custom_tool
      summary: Test custom tool
      description: |-
        Execute the tool FOR REAL with the given params, through the same executor a production call takes: one HTTP call to the target, logged as a provider_calls row (source_service api, tool_type custom_tool), 0 credits, a fresh idempotency key per press. result carries the outcome verbatim: status, output {status, body, extracted}, the classified error_code and a message that opens with the token of a tool-level failure (custom_tool_disabled, input_binding...), and provider_call_sid for the snapshots. Use it to see what a column would get, or why a tool returns nothing (compare output.body with output_mapping). A dry-run that does not hit the target would validate nothing. Throttled 10 a minute.

        Contract:
        - MCP tool `test_custom_tool`, registry package `mcp.integrations/custom_tools`, mount `integrations.providers`.
        - Operation `action`, response envelope `action`.
        - Flags: none.
      tags:
        - custom_tools
      parameters:
        - name: sid
          in: path
          required: true
          description: Custom tool sid (in_tl_...).
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^in_tl_
            description: Custom tool sid (in_tl_...).
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TestCustomToolRequest"
      responses:
        "200":
          description: "`action` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TestCustomToolResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: test_custom_tool
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: custom_tools
      x-gs-operation: action
      x-gs-envelope: action
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: complex
  /api/provider-calls/metrics:
    post:
      operationId: get_provider_calls_metrics
      summary: Provider calls metrics
      description: |-
        Period-bound spend, latency and reliability over the calls: credits_charged_sum (what did we spend on AI and enrichment this month), total_tokens_sum, avg_duration_ms, error_rate and cache_hit_rate. period {from, to} is required and capped at 90 days; filter is the search filter; group_by splits by operation, provider, model (the LLM spend axis), status, error_code, source_service, cache_hit or created_date (spend by day). Run budgets and receipts are playtables' credit ledger, not this meter.

        Contract:
        - MCP tool `get_provider_calls_metrics`, registry package `mcp.integrations/provider_calls`, mount `integrations.providers`.
        - Operation `metrics`, response envelope `metrics`.
        - Flags: read only.
      tags:
        - provider_calls
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/GetProviderCallsMetricsRequest"
      responses:
        "200":
          description: "`metrics` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetProviderCallsMetricsResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: get_provider_calls_metrics
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: provider_calls
      x-gs-operation: metrics
      x-gs-envelope: metrics
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/provider-calls/search:
    post:
      operationId: search_provider_calls
      summary: Search provider calls
      description: |-
        The execution log of the integration platform, for a drill-down: by connection (provider_connection_sid with error_code.eq auth_error: is this key working), by caller (tool_type and tool_sid: one cell's attempts), by object, by failure class. Rows carry coordinates, status, error, money and tokens, the snapshots nulled (get_provider_call has them). The scan must be bounded: one of the sid filters, or a created_at lower bound (422 bounded_scan_required). page_size 0 returns the counts only.

        Contract:
        - MCP tool `search_provider_calls`, registry package `mcp.integrations/provider_calls`, mount `integrations.providers`.
        - Operation `search`, response envelope `search`.
        - Flags: read only.
      tags:
        - provider_calls
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SearchProviderCallsRequest"
      responses:
        "200":
          description: "`search` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SearchProviderCallsResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: search_provider_calls
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: provider_calls
      x-gs-operation: search
      x-gs-envelope: search
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/provider-calls/{sid}:
    get:
      operationId: get_provider_call
      summary: Get provider call
      description: |-
        One call with its capped snapshots: the sanitized request (the rendered prompt), the raw response, the normalized output, the tokens and the price. Why did this cell produce that.

        Contract:
        - MCP tool `get_provider_call`, registry package `mcp.integrations/provider_calls`, mount `integrations.providers`.
        - Operation `get`, response envelope `get`.
        - Flags: read only.
      tags:
        - provider_calls
      parameters:
        - name: sid
          in: path
          required: true
          description: The in_pc_* sid of the row to read.
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^in_pc_
            description: The in_pc_* sid of the row to read.
        - name: include[]
          in: query
          required: false
          description: Relations to attach to the row; omit for the bare row.
          style: form
          explode: true
          schema:
            type: array
            items:
              type: string
              enum:
                - provider_connection
            description: Relations to attach to the row; omit for the bare row.
      responses:
        "200":
          description: "`get` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetProviderCallResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: get_provider_call
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: provider_calls
      x-gs-operation: get
      x-gs-envelope: get
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: trivial
  /api/provider-catalog:
    get:
      operationId: list_provider_catalog
      summary: List provider catalog
      description: |-
        The priced operation registry: every (operation, provider, model) the platform can run, with its name, whether a platform key is configured (callable now), its pricing unit and the price triple (min, expected, max) in credits, whether it is cached, and the web search prices of a model that can search. What a run estimate multiplies (price_expected times the rows) and what the tool pickers render. Team-independent; the platform runs every vendor on its own key and resells the credits.

        Contract:
        - MCP tool `list_provider_catalog`, registry package `mcp.integrations/provider_calls`, mount `integrations.providers`.
        - Operation `action`, response envelope `action`.
        - Flags: read only.
      tags:
        - provider_calls
      responses:
        "200":
          description: "`action` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ListProviderCatalogResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: list_provider_catalog
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: provider_calls
      x-gs-operation: action
      x-gs-envelope: action
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/provider-connections:
    post:
      operationId: create_provider_connection
      summary: Create provider connection
      description: |-
        Store a credential of the team's OWN API (provider custom): name, auth_type (api_key or bearer inject Authorization Bearer; basic; header; query) and the write-only auth payload, never echoed back. No verification at create: test_provider_connection checks the shape, a custom tool's test exercises it. A vendor is refused (422 provider_not_connectable: the platform holds those keys); hubspot comes only through the OAuth connect (422 auth_type_invalid_for_provider). 409 on a duplicate name.

        Contract:
        - MCP tool `create_provider_connection`, registry package `mcp.integrations/provider_connections`, mount `integrations.providers`.
        - Operation `create`, response envelope `create`.
        - Flags: none.
      tags:
        - provider_connections
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateProviderConnectionRequest"
      responses:
        "200":
          description: "`create` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateProviderConnectionResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: create_provider_connection
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: provider_connections
      x-gs-operation: create
      x-gs-envelope: create
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/provider-connections/oauth/authorize:
    post:
      operationId: start_provider_connection_oauth
      summary: Start provider OAuth connect
      description: |-
        Leg 1 of connecting HubSpot: mint the consent URL to open in a browser and a signed state (15 minutes, single-use). Nothing is written: a connection exists only once a grant does. The browser lands in the app, which relays the code and the state to complete_provider_connection_oauth. 422 oauth_app_not_configured on a plane without the HubSpot app.

        Contract:
        - MCP tool `start_provider_connection_oauth`, registry package `mcp.integrations/provider_connections`, mount `integrations.providers`.
        - Operation `action`, response envelope `action`.
        - Flags: none.
      tags:
        - provider_connections
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StartProviderConnectionOauthRequest"
      responses:
        "200":
          description: "`action` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StartProviderConnectionOauthResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: start_provider_connection_oauth
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: provider_connections
      x-gs-operation: action
      x-gs-envelope: action
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/provider-connections/oauth/complete:
    post:
      operationId: complete_provider_connection_oauth
      summary: Complete provider OAuth connect
      description: |-
        Leg 2: exchange the relayed authorization code and land the HubSpot connection. Upserts by portal (team, provider, external_account_id): re-consenting a portal already held rotates that row in place (result.reconnected true; same sid, the counter cleared, a failed row revived) instead of colliding with the name guard; a new portal is created (result.created true). The state is checked against the caller's team and spent once (422 oauth_state_invalid, _replayed, _expired, _team_mismatch); a refused code is 422 oauth_exchange_failed; a provider that gave no answer is 409 oauth_exchange_unconfirmed: start the connect again. The grant itself never appears in any response.

        Contract:
        - MCP tool `complete_provider_connection_oauth`, registry package `mcp.integrations/provider_connections`, mount `integrations.providers`.
        - Operation `action`, response envelope `action`.
        - Flags: none.
      tags:
        - provider_connections
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CompleteProviderConnectionOauthRequest"
      responses:
        "200":
          description: "`action` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompleteProviderConnectionOauthResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: complete_provider_connection_oauth
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: provider_connections
      x-gs-operation: action
      x-gs-envelope: action
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: complex
  /api/provider-connections/search:
    post:
      operationId: search_provider_connections
      summary: Search provider connections
      description: |-
        The team's credentials: its own API keys (provider custom) and its HubSpot grants (provider hubspot), with their health. status.eq failed answers why the HubSpot export stopped (auto-disabled after five auth failures); provider.eq hubspot is the reliable axis, q matches the name only; sid.eq is the point lookup (there is no get). The vendors (OpenAI, Hunter...) are never here: the platform runs them on its own keys. page_size 0 returns the counts only.

        Contract:
        - MCP tool `search_provider_connections`, registry package `mcp.integrations/provider_connections`, mount `integrations.providers`.
        - Operation `search`, response envelope `search`.
        - Flags: read only.
      tags:
        - provider_connections
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SearchProviderConnectionsRequest"
      responses:
        "200":
          description: "`search` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SearchProviderConnectionsResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: search_provider_connections
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: provider_connections
      x-gs-operation: search
      x-gs-envelope: search
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/provider-connections/{sid}:
    patch:
      operationId: update_provider_connection
      summary: Update provider connection
      description: |-
        Rename, pause or resume (status on | off), or rotate the secret: auth_type and auth together replace it in place, same sid, so the tools naming it keep working, and the failure counter resets. Reviving a failed connection (status on) resets it too. A HubSpot grant is not rotatable here (422 oauth_grant_not_client_rotatable: reconnect through the OAuth pair); provider is immutable. At least one field, else 422 nothing_to_update.

        Contract:
        - MCP tool `update_provider_connection`, registry package `mcp.integrations/provider_connections`, mount `integrations.providers`.
        - Operation `update`, response envelope `update`.
        - Flags: none.
      tags:
        - provider_connections
      parameters:
        - name: sid
          in: path
          required: true
          description: Provider connection sid (in_cn_...).
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^in_cn_
            description: Provider connection sid (in_cn_...).
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateProviderConnectionRequest"
      responses:
        "200":
          description: "`update` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UpdateProviderConnectionResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: update_provider_connection
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: provider_connections
      x-gs-operation: update
      x-gs-envelope: update
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
    delete:
      operationId: delete_provider_connection
      summary: Delete provider connection
      description: |-
        Soft-delete a connection: the secret is scrubbed in the same transaction, the executor refuses it at once (connection_not_found), a HubSpot grant is revoked at the portal first. Blocked while a custom tool references it (409 delete_blocked, connection_in_use: repoint or delete the tools). The call history stays. No restore: re-creating mints a new sid.

        Contract:
        - MCP tool `delete_provider_connection`, registry package `mcp.integrations/provider_connections`, mount `integrations.providers`.
        - Operation `delete`, response envelope `delete_simple`.
        - Flags: dangerous: the MCP layer gates it behind a preview/commit token, and the effect cannot be undone through this API.
      tags:
        - provider_connections
      parameters:
        - name: sid
          in: path
          required: true
          description: The in_cn_* sid of the row to delete.
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^in_cn_
            description: The in_cn_* sid of the row to delete.
      responses:
        "200":
          description: "`delete_simple` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeleteProviderConnectionResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: delete_provider_connection
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: provider_connections
      x-gs-operation: delete
      x-gs-envelope: delete_simple
      x-gs-availability: ga
      x-gs-dangerous: true
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/provider-connections/{sid}/test:
    post:
      operationId: test_provider_connection
      summary: Test provider connection
      description: |-
        One unbilled verification of the stored secret, no row written, no status change: for a HubSpot grant it introspects the refresh token (a green answer means the grant is alive); for a custom connection it is a shape check only, since the real probe is the tool's test_custom_tool. result: ok, http_code, error_kind (none, auth, network, timeout, provider), duration_ms. Reviving a failed row is update_provider_connection.

        Contract:
        - MCP tool `test_provider_connection`, registry package `mcp.integrations/provider_connections`, mount `integrations.providers`.
        - Operation `action`, response envelope `action`.
        - Flags: read only.
      tags:
        - provider_connections
      parameters:
        - name: sid
          in: path
          required: true
          description: Provider connection sid (in_cn_...).
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^in_cn_
            description: Provider connection sid (in_cn_...).
      responses:
        "200":
          description: "`action` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TestProviderConnectionResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: test_provider_connection
      x-gs-mcp-mount: integrations.providers
      x-gs-entity: provider_connections
      x-gs-operation: action
      x-gs-envelope: action
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/webhook-logs/metrics:
    post:
      operationId: get_webhook_logs_metrics
      summary: Webhook logs metrics
      description: |-
        Period-bound delivery health: success_rate, failure_rate, p50 / p95 / p99 latency, total_retries, last_success_at and last_failure_at. The rates count terminal rows only (a delivery still on its ladder is in counts.groups.status.retrying, not here); a period with nothing terminal reads null. period {from, to} is required; filter is the search filter (created_at inside it is ignored, period is the window); group_by splits by status, event_type, response_code, webhook_sid or account_sid.

        Contract:
        - MCP tool `get_webhook_logs_metrics`, registry package `mcp.integrations/webhook_logs`, mount `integrations.webhooks`.
        - Operation `metrics`, response envelope `metrics`.
        - Flags: read only.
      tags:
        - webhook_logs
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/GetWebhookLogsMetricsRequest"
      responses:
        "200":
          description: "`metrics` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetWebhookLogsMetricsResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: get_webhook_logs_metrics
      x-gs-mcp-mount: integrations.webhooks
      x-gs-entity: webhook_logs
      x-gs-operation: metrics
      x-gs-envelope: metrics
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/webhook-logs/search:
    post:
      operationId: search_webhook_logs
      summary: Search webhook logs
      description: |-
        The deliveries of the team's webhooks, one row per event per subscription, from every producing service: per webhook, per sending identity, per event type, per status or response code; include webhook. The auditing and outage-debugging read (why did the integrator not get the event). Period-bound success rates are get_webhook_logs_metrics. page_size 0 returns the counts only.

        Contract:
        - MCP tool `search_webhook_logs`, registry package `mcp.integrations/webhook_logs`, mount `integrations.webhooks`.
        - Operation `search`, response envelope `search`.
        - Flags: read only.
      tags:
        - webhook_logs
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SearchWebhookLogsRequest"
      responses:
        "200":
          description: "`search` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SearchWebhookLogsResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: search_webhook_logs
      x-gs-mcp-mount: integrations.webhooks
      x-gs-entity: webhook_logs
      x-gs-operation: search
      x-gs-envelope: search
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/webhook-logs/{sid}/cancel:
    post:
      operationId: cancel_webhook_log
      summary: Cancel webhook delivery
      description: |-
        Cancel a delivery (status cancelled, reason manual): no further attempts. From pending, retrying or in_progress; a terminal row is 422. On an in_progress row the attempt in flight may still land as success, which wins over the cancel (result.in_flight_attempt_pending true: read the row again). expected_status is a compare-and-set guard (409 on a mismatch).

        Contract:
        - MCP tool `cancel_webhook_log`, registry package `mcp.integrations/webhook_logs`, mount `integrations.webhooks`.
        - Operation `action`, response envelope `action`.
        - Flags: dangerous: the MCP layer gates it behind a preview/commit token, and the effect cannot be undone through this API.
      tags:
        - webhook_logs
      parameters:
        - name: sid
          in: path
          required: true
          description: Webhook log (delivery) sid (wh_lg_...).
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^wh_lg_
            description: Webhook log (delivery) sid (wh_lg_...).
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CancelWebhookLogRequest"
      responses:
        "200":
          description: "`action` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CancelWebhookLogResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: cancel_webhook_log
      x-gs-mcp-mount: integrations.webhooks
      x-gs-entity: webhook_logs
      x-gs-operation: action
      x-gs-envelope: action
      x-gs-availability: ga
      x-gs-dangerous: true
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/webhook-logs/{sid}/retry:
    post:
      operationId: retry_webhook_log
      summary: Retry webhook delivery
      description: |-
        Re-arm one delivery by hand: status back to pending, scheduled_at now, cancel_reason cleared; retry_count stays (it counts executed attempts) and the original envelope goes to the original URL. Refused on an in_progress row (409: cancel or wait), on a cancelled one (that was a decision), and while the parent is deleted or off (422). expected_status is a compare-and-set guard: 409 invalid_transition when the row moved since it was read. Re-delivers to the integrator.

        Contract:
        - MCP tool `retry_webhook_log`, registry package `mcp.integrations/webhook_logs`, mount `integrations.webhooks`.
        - Operation `action`, response envelope `action`.
        - Flags: dangerous: the MCP layer gates it behind a preview/commit token, and the effect cannot be undone through this API.
      tags:
        - webhook_logs
      parameters:
        - name: sid
          in: path
          required: true
          description: Webhook log (delivery) sid (wh_lg_...).
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^wh_lg_
            description: Webhook log (delivery) sid (wh_lg_...).
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RetryWebhookLogRequest"
      responses:
        "200":
          description: "`action` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RetryWebhookLogResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: retry_webhook_log
      x-gs-mcp-mount: integrations.webhooks
      x-gs-entity: webhook_logs
      x-gs-operation: action
      x-gs-envelope: action
      x-gs-availability: ga
      x-gs-dangerous: true
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: complex
  /api/webhooks:
    post:
      operationId: create_webhook
      summary: Create webhook
      description: |-
        Subscribe an https endpoint to platform events: the server mints a 32-hex secret and returns it in this response ONLY (masked afterwards); the receiver verifies X-Webhook-Signature with it. target_url must be https on a public host, unique per team (409 duplicate_rejected); events is an exact list of catalog types (no wildcard); filters.account_sid narrows to one sending identity. Every producing service delivers through this one subscription.

        Contract:
        - MCP tool `create_webhook`, registry package `mcp.integrations/webhooks`, mount `integrations.webhooks`.
        - Operation `create`, response envelope `create`.
        - Flags: dangerous: the MCP layer gates it behind a preview/commit token, and the effect cannot be undone through this API.
      tags:
        - webhooks
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateWebhookRequest"
      responses:
        "200":
          description: "`create` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateWebhookResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: create_webhook
      x-gs-mcp-mount: integrations.webhooks
      x-gs-entity: webhooks
      x-gs-operation: create
      x-gs-envelope: create
      x-gs-availability: ga
      x-gs-dangerous: true
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/webhooks/search:
    post:
      operationId: search_webhooks
      summary: Search webhooks
      description: |-
        The team's webhook subscriptions: which endpoints get which events, their status and failure counters. events.eq finds who listens to one type, status.eq failed the endpoints the plane switched off, consecutive_failed_attempts the ones close to it; include latest_webhook_logs for the recent deliveries. The secret is null on every read. page_size 0 returns the counts only.

        Contract:
        - MCP tool `search_webhooks`, registry package `mcp.integrations/webhooks`, mount `integrations.webhooks`.
        - Operation `search`, response envelope `search`.
        - Flags: read only.
      tags:
        - webhooks
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SearchWebhooksRequest"
      responses:
        "200":
          description: "`search` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SearchWebhooksResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: search_webhooks
      x-gs-mcp-mount: integrations.webhooks
      x-gs-entity: webhooks
      x-gs-operation: search
      x-gs-envelope: search
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
  /api/webhooks/{sid}:
    get:
      operationId: get_webhook
      summary: Get webhook
      description: |-
        One subscription by sid; include latest_webhook_logs for its recent deliveries. The secret is null on a read.

        Contract:
        - MCP tool `get_webhook`, registry package `mcp.integrations/webhooks`, mount `integrations.webhooks`.
        - Operation `get`, response envelope `get`.
        - Flags: read only.
      tags:
        - webhooks
      parameters:
        - name: sid
          in: path
          required: true
          description: The wh_hk_* sid of the row to read.
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^wh_hk_
            description: The wh_hk_* sid of the row to read.
        - name: include[]
          in: query
          required: false
          description: Relations to attach to the row; omit for the bare row.
          style: form
          explode: true
          schema:
            type: array
            items:
              type: string
              enum:
                - latest_webhook_logs
            description: Relations to attach to the row; omit for the bare row.
      responses:
        "200":
          description: "`get` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GetWebhookResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: get_webhook
      x-gs-mcp-mount: integrations.webhooks
      x-gs-entity: webhooks
      x-gs-operation: get
      x-gs-envelope: get
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: trivial
    patch:
      operationId: update_webhook
      summary: Update webhook
      description: |-
        Edit a subscription: name, target_url, events and filters are full replacements; status on | off switches it (off cancels its pending deliveries; on after a failed revives it and resets the counter, but re-issues nothing). failed is never set by hand and the secret is not writable (rotation is admin-internal). At least one field.

        Contract:
        - MCP tool `update_webhook`, registry package `mcp.integrations/webhooks`, mount `integrations.webhooks`.
        - Operation `update`, response envelope `update`.
        - Flags: dangerous: the MCP layer gates it behind a preview/commit token, and the effect cannot be undone through this API.
      tags:
        - webhooks
      parameters:
        - name: sid
          in: path
          required: true
          description: Webhook sid (wh_hk_...).
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^wh_hk_
            description: Webhook sid (wh_hk_...).
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateWebhookRequest"
      responses:
        "200":
          description: "`update` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UpdateWebhookResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: update_webhook
      x-gs-mcp-mount: integrations.webhooks
      x-gs-entity: webhooks
      x-gs-operation: update
      x-gs-envelope: update
      x-gs-availability: ga
      x-gs-dangerous: true
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
    delete:
      operationId: delete_webhook
      summary: Delete webhook
      description: |-
        Soft-delete a subscription: it matches no new events, its pending and retrying deliveries are cancelled, its log stays readable. One-way (no undo through the API). Idempotent.

        Contract:
        - MCP tool `delete_webhook`, registry package `mcp.integrations/webhooks`, mount `integrations.webhooks`.
        - Operation `delete`, response envelope `delete_simple`.
        - Flags: dangerous: the MCP layer gates it behind a preview/commit token, and the effect cannot be undone through this API.
      tags:
        - webhooks
      parameters:
        - name: sid
          in: path
          required: true
          description: The wh_hk_* sid of the row to delete.
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^wh_hk_
            description: The wh_hk_* sid of the row to delete.
      responses:
        "200":
          description: "`delete_simple` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeleteWebhookResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: delete_webhook
      x-gs-mcp-mount: integrations.webhooks
      x-gs-entity: webhooks
      x-gs-operation: delete
      x-gs-envelope: delete_simple
      x-gs-availability: ga
      x-gs-dangerous: true
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: trivial
  /api/webhooks/{sid}/test:
    post:
      operationId: test_webhook
      summary: Test webhook
      description: |-
        POST one signed synthetic envelope (type webhooks.test, or override_event_type) to the endpoint now and answer what came back: http_status, duration_ms, error_kind (none, http_error, network). Verifies the endpoint and its signature check without waiting for a real event; writes no log row, moves no counter, fires no event. Allowed on a failed webhook (the revival check), refused on one switched off (409). Throttled 10 a minute per webhook.

        Contract:
        - MCP tool `test_webhook`, registry package `mcp.integrations/webhooks`, mount `integrations.webhooks`.
        - Operation `action`, response envelope `action`.
        - Flags: none.
      tags:
        - webhooks
      parameters:
        - name: sid
          in: path
          required: true
          description: Webhook sid (wh_hk_...).
          schema:
            type: string
            minLength: 18
            maxLength: 18
            pattern: ^wh_hk_
            description: Webhook sid (wh_hk_...).
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TestWebhookRequest"
      responses:
        "200":
          description: "`action` success envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TestWebhookResponse"
        4XX:
          $ref: "#/components/responses/McpClientError"
        5XX:
          $ref: "#/components/responses/McpServerError"
      x-gs-mcp-tool: test_webhook
      x-gs-mcp-mount: integrations.webhooks
      x-gs-entity: webhooks
      x-gs-operation: action
      x-gs-envelope: action
      x-gs-availability: ga
      x-gs-dangerous: false
      x-gs-mass-action: false
      x-gs-step-eligible: false
      x-gs-schedule-required: false
      x-gs-tool-class: typical
components:
  securitySchemes:
    BearerJwt:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Access token issued by gs.service.id. Its `access_identity` claim carries `team_sid`, `actor_sid` and `actor_type`, and that team scope is authoritative.
    TeamSid:
      type: apiKey
      in: header
      name: Team-SID
      description: Team scope for tokens that do not carry one. Ignored when the token already names a team.
  responses:
    McpClientError:
      description: MCP error envelope. `error.code` is one of validation_failed, nothing_to_update, not_found, relation_not_found, invalid_transition, limit_exceeded, payment_required, duplicate_rejected, conflict, delete_blocked, unauthorized, forbidden, rate_limited, not_implemented.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/McpError"
    McpServerError:
      description: MCP error envelope with `error.code` internal_error or service_unavailable.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/McpError"
  schemas:
    CancelWebhookLogRequest:
      type: object
      description: Request body of `cancel_webhook_log`.
      properties:
        expected_status:
          type: string
          enum:
            - pending
            - in_progress
            - retrying
            - success
            - failed
            - cancelled
          description: "Optional guard: the cancel only runs when the row still has this status."
    CancelWebhookLogResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - action
        action:
          type: string
          description: kebab-case verb; matches the route segment.
        item:
          type: object
          nullable: true
          properties:
            sid:
              type: string
              description: Delivery sid (wh_lg_...).
            team_sid:
              type: string
              description: The subscribing workspace (ts_tm_...).
            webhook_sid:
              type: string
              description: The parent subscription (wh_hk_...).
            account_sid:
              type: string
              nullable: true
              description: The sending identity the subscription matched on (ub_sp_...); null on a team-wide event.
            source_service:
              type: string
              nullable: true
              description: Which service produced the event (playtables, unibox, signals, integrations); observability only.
            event_type:
              type: string
              description: The event type (a WebhookEventTypeEnum value).
            event_source_sid:
              type: string
              nullable: true
              description: The row whose state change produced the event; null when none.
            status:
              type: string
              enum:
                - pending
                - in_progress
                - retrying
                - success
                - failed
                - cancelled
              description: pending or retrying = waiting for the tick; in_progress = leased by a worker; success; failed (the ladder ran out, or a 4xx); cancelled.
            retry_count:
              type: integer
              description: Executed attempts; a manual re-arm does not move it.
            cancel_reason:
              type: string
              nullable: true
              enum:
                - manual
                - webhook_deleted
                - webhook_disabled
                - webhook_failed
              description: manual, or the cascade of a deleted, disabled or failed webhook; null unless cancelled.
            request_method:
              type: string
              enum:
                - POST
              description: POST.
            request_url:
              type: string
              description: "The target URL at insert: a retry replays it."
            request_headers:
              type: object
              additionalProperties:
                type: string
              description: The X-Webhook-* and X-Trace-Id headers as sent.
            request_payload:
              type: object
              properties:
                webhook_log_sid:
                  type: string
                  description: "This row's own sid: the receiver's dedup key."
                type:
                  type: string
                  description: The event type (a WebhookEventTypeEnum value).
                emitted_at:
                  type: string
                  description: ISO 8601 UTC of the state change.
                team_sid:
                  type: string
                  description: The workspace (ts_tm_...).
                trace_id:
                  type: string
                  description: The trace of the write that produced the event.
                payload:
                  type: object
                  additionalProperties: {}
                  description: The event-specific payload.
              required:
                - webhook_log_sid
                - type
                - emitted_at
                - team_sid
                - trace_id
                - payload
              description: The stored envelope.
            response_code:
              type: integer
              nullable: true
              description: The receiver's status; null on a network error.
            error_message:
              type: string
              nullable: true
              description: The last attempt's error.
            duration_ms:
              type: integer
              nullable: true
              description: The last attempt's wall clock; null before one ran.
            scheduled_at:
              type: string
              description: ISO 8601 UTC when the next (or last) attempt is due.
            executed_at:
              type: string
              nullable: true
              description: ISO 8601 UTC of the last attempt; null before one ran.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
          required:
            - sid
            - team_sid
            - webhook_sid
            - account_sid
            - source_service
            - event_type
            - event_source_sid
            - status
            - retry_count
            - cancel_reason
            - request_method
            - request_url
            - request_headers
            - request_payload
            - response_code
            - error_message
            - duration_ms
            - scheduled_at
            - executed_at
            - created_at
            - updated_at
        result:
          type: object
          properties:
            previous_status:
              type: string
              enum:
                - pending
                - in_progress
                - retrying
                - success
                - failed
                - cancelled
              description: The status before the cancel.
            cancel_reason:
              type: string
              enum:
                - manual
                - webhook_deleted
                - webhook_disabled
                - webhook_failed
              description: manual.
            cancelled_at:
              type: string
              nullable: true
              description: ISO 8601 UTC.
            in_flight_attempt_pending:
              type: boolean
              description: "true: a worker held the row; its attempt may still land as success."
          required:
            - previous_status
            - cancel_reason
            - cancelled_at
            - in_flight_attempt_pending
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - action
        - item
        - result
        - meta
    CompleteProviderConnectionOauthRequest:
      type: object
      description: Request body of `complete_provider_connection_oauth`.
      properties:
        provider:
          type: string
          enum:
            - hubspot
          description: hubspot.
        authorization_code:
          type: string
          minLength: 1
          maxLength: 2048
          description: The code the provider redirect carried.
        state:
          type: string
          minLength: 1
          maxLength: 8192
          description: The state from start_provider_connection_oauth.
      required:
        - provider
        - authorization_code
        - state
    CompleteProviderConnectionOauthResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - action
        action:
          type: string
          description: kebab-case verb; matches the route segment.
        item:
          type: object
          nullable: true
          properties:
            sid:
              type: string
              description: Connection sid (in_cn_...).
            team_sid:
              type: string
              description: The owning workspace (ts_tm_...).
            name:
              type: string
              description: Display name, unique within the team among live rows.
            provider:
              type: string
              enum:
                - openai
                - anthropic
                - google
                - deepseek
                - xai
                - voyage
                - cohere
                - hunter
                - findymail
                - anymailfinder
                - emaillistverify
                - custom
                - hubspot
                - serper
              description: custom (the team's own API) or hubspot (a CRM grant); immutable.
            auth_type:
              type: string
              enum:
                - api_key
                - bearer
                - basic
                - header
                - query
                - oauth
              description: The shape of the stored secret; oauth on a HubSpot grant.
            external_account_id:
              type: string
              nullable: true
              description: "The provider-side account of an OAuth grant (the HubSpot portal id): the reconnect key; null on key auth."
            status:
              type: string
              enum:
                - "on"
                - "off"
                - failed
              description: on; off (paused by hand); failed (auto-disabled after five auth failures in a row, revived by update or a reconnect).
            consecutive_failed_attempts:
              type: integer
              description: Auth-classified failures in a row; any non-cache success or a rotation resets it.
            last_failure_at:
              type: string
              nullable: true
              description: ISO 8601 UTC of the last auth failure.
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who stored it.
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who deleted it; null while live.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
            deleted_at:
              type: string
              nullable: true
              description: ISO 8601 UTC; the secret is scrubbed with it.
          required:
            - sid
            - team_sid
            - name
            - provider
            - auth_type
            - external_account_id
            - status
            - consecutive_failed_attempts
            - last_failure_at
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        result:
          type: object
          properties:
            created:
              type: boolean
              description: true = a new connection; false = an existing portal connection was rotated.
            reconnected:
              type: boolean
              description: The opposite of created.
            external_account_id:
              type: string
              nullable: true
              description: The portal this grant belongs to.
          required:
            - created
            - reconnected
            - external_account_id
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - action
        - item
        - result
        - meta
    CreateCustomToolRequest:
      type: object
      description: Request body of `create_custom_tool`.
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: Unique within the team, 1..255 chars.
        description:
          type: string
          nullable: true
          maxLength: 2000
          description: Free text, up to 2000 chars.
        provider_connection_sid:
          type: string
          nullable: true
          minLength: 18
          maxLength: 18
          pattern: ^in_cn_
          description: A provider connection of provider custom this tool authenticates with (in_cn_...); null = a public API, no auth injected.
        request:
          type: object
          properties:
            method:
              type: string
              enum:
                - GET
                - POST
                - PUT
                - PATCH
                - DELETE
              description: The HTTP method.
            url:
              type: string
              maxLength: 2048
              pattern: ^https:\/\/
              description: https URL; scheme and host literal (no placeholders, default port, public DNS), placeholders in the path and query only.
            headers:
              type: object
              additionalProperties:
                type: string
                maxLength: 1024
              description: "Up to 20 headers; values may hold placeholders. Auth-shaped names (authorization, cookie, token, key...) and Content-Type are refused: auth comes from the connection."
            body:
              type: object
              nullable: true
              additionalProperties: {}
              description: A JSON template; null on GET and DELETE. String leaves may hold placeholders; a leaf that IS {{key}} renders with the input's native type.
          required:
            - method
            - url
          description: "The request template: method, https URL with a literal host, headers and a JSON body, placeholders {{key}} in the path, query, header values and body strings."
        input_schema:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
                maxLength: 64
                pattern: ^[a-z][a-z0-9_]*$
                description: "The placeholder name: lowercase, digits and underscores."
              type:
                type: string
                enum:
                  - string
                  - number
                  - boolean
                description: string | number | boolean.
              required:
                type: boolean
                description: "true: a call without it fails as invalid_input."
            required:
              - key
              - type
          maxItems: 30
          description: The declared inputs, up to 30; default none.
        output_mapping:
          type: object
          additionalProperties:
            type: string
            maxLength: 255
          description: name to dot-path (person.title), up to 20 entries; default {} = the raw body.
        status:
          type: string
          enum:
            - "on"
            - "off"
          description: Default on.
      required:
        - name
        - request
    CreateCustomToolResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - create
        item:
          type: object
          properties:
            sid:
              type: string
              description: Custom tool sid (in_tl_...).
            team_sid:
              type: string
              description: The owning workspace (ts_tm_...).
            name:
              type: string
              description: Unique within the team among live rows; what the tool pickers show.
            description:
              type: string
              nullable: true
              description: Free text, up to 2000 chars.
            provider_connection_sid:
              type: string
              nullable: true
              description: The connection the tool authenticates with (in_cn_...); null = no auth.
            request:
              type: object
              properties:
                method:
                  type: string
                  enum:
                    - GET
                    - POST
                    - PUT
                    - PATCH
                    - DELETE
                  description: The HTTP method.
                url:
                  type: string
                  maxLength: 2048
                  pattern: ^https:\/\/
                  description: https URL; scheme and host literal (no placeholders, default port, public DNS), placeholders in the path and query only.
                headers:
                  type: object
                  additionalProperties:
                    type: string
                    maxLength: 1024
                  description: "Up to 20 headers; values may hold placeholders. Auth-shaped names (authorization, cookie, token, key...) and Content-Type are refused: auth comes from the connection."
                body:
                  type: object
                  nullable: true
                  additionalProperties: {}
                  description: A JSON template; null on GET and DELETE. String leaves may hold placeholders; a leaf that IS {{key}} renders with the input's native type.
              required:
                - method
                - url
              description: The request template.
            input_schema:
              type: array
              items:
                type: object
                properties:
                  key:
                    type: string
                    description: The placeholder name.
                  type:
                    type: string
                    description: string | number | boolean.
                  required:
                    type: boolean
                    description: Whether a call must bind it.
                required:
                  - key
                  - type
                  - required
              description: The declared inputs (up to 30).
            output_mapping:
              type: object
              additionalProperties:
                type: string
              description: name to dot-path into the response body (up to 20); {} = the raw body only.
            status:
              type: string
              enum:
                - "on"
                - "off"
              description: off = the executor refuses it with a failed row (custom_tool_disabled).
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who defined the tool.
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who deleted it; null while live.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
            deleted_at:
              type: string
              nullable: true
              description: ISO 8601 UTC; null = live.
          required:
            - sid
            - team_sid
            - name
            - description
            - provider_connection_sid
            - request
            - input_schema
            - output_mapping
            - status
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        already_exists:
          type: boolean
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - item
        - already_exists
        - meta
    CreateProviderConnectionRequest:
      type: object
      description: Request body of `create_provider_connection`.
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: Display name, 1..255 chars, unique within the team.
        provider:
          type: string
          enum:
            - custom
            - hubspot
          description: custom in practice; hubspot passes the rule and is refused (its grant comes from the OAuth connect).
        auth_type:
          type: string
          enum:
            - api_key
            - bearer
            - basic
            - header
            - query
          description: Default api_key.
        auth:
          type: object
          additionalProperties:
            type: string
            maxLength: 4096
          description: "WRITE-ONLY, never echoed: {key} for api_key or bearer, {username, password} for basic, {header_name, value} for header, {param_name, value} for query."
        status:
          type: string
          enum:
            - "on"
            - "off"
          description: Default on.
      required:
        - name
        - provider
        - auth
    CreateProviderConnectionResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - create
        item:
          type: object
          properties:
            sid:
              type: string
              description: Connection sid (in_cn_...).
            team_sid:
              type: string
              description: The owning workspace (ts_tm_...).
            name:
              type: string
              description: Display name, unique within the team among live rows.
            provider:
              type: string
              enum:
                - openai
                - anthropic
                - google
                - deepseek
                - xai
                - voyage
                - cohere
                - hunter
                - findymail
                - anymailfinder
                - emaillistverify
                - custom
                - hubspot
                - serper
              description: custom (the team's own API) or hubspot (a CRM grant); immutable.
            auth_type:
              type: string
              enum:
                - api_key
                - bearer
                - basic
                - header
                - query
                - oauth
              description: The shape of the stored secret; oauth on a HubSpot grant.
            external_account_id:
              type: string
              nullable: true
              description: "The provider-side account of an OAuth grant (the HubSpot portal id): the reconnect key; null on key auth."
            status:
              type: string
              enum:
                - "on"
                - "off"
                - failed
              description: on; off (paused by hand); failed (auto-disabled after five auth failures in a row, revived by update or a reconnect).
            consecutive_failed_attempts:
              type: integer
              description: Auth-classified failures in a row; any non-cache success or a rotation resets it.
            last_failure_at:
              type: string
              nullable: true
              description: ISO 8601 UTC of the last auth failure.
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who stored it.
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who deleted it; null while live.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
            deleted_at:
              type: string
              nullable: true
              description: ISO 8601 UTC; the secret is scrubbed with it.
          required:
            - sid
            - team_sid
            - name
            - provider
            - auth_type
            - external_account_id
            - status
            - consecutive_failed_attempts
            - last_failure_at
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        already_exists:
          type: boolean
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - item
        - already_exists
        - meta
    CreateWebhookRequest:
      type: object
      description: Request body of `create_webhook`.
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: Free text, 1..255 chars.
        target_url:
          type: string
          maxLength: 2048
          description: https only, a public host (no private or local address).
        events:
          type: array
          items:
            type: string
            enum:
              - data-sources.completed
              - data-sources.failed
              - data-sources.paused
              - data-sources.deleted
              - playtable-runs.finished
              - playtable-runs.cancelled
              - workflows.published
              - workflow-records.entered
              - workflow-records.completed
              - workflow-records.failed
              - workflow-records.exited
              - workflow-records.paused
              - workflow-records.resumed
              - messages.sent
              - messages.received
              - messages.bounced
              - conversations.created
              - conversations.state-changed
              - conversations.scenario-changed
              - conversations.merged
              - conversations.person-linked
              - conversations.person-unlinked
              - conversations.signals-changed
              - tasks.created
              - tasks.completed
              - sender-profiles.created
              - sender-profiles.deleted
              - sender-profiles.health-changed
              - agents.mode-changed
              - signals.website-visited
              - website-sites.broken
              - website-sites.recovered
              - webhooks.failed
          minItems: 1
          description: At least one catalog event type; exact membership.
        filters:
          type: object
          properties:
            account_sid:
              type: string
              nullable: true
              minLength: 18
              maxLength: 18
              description: Deliver only the events of this sending identity (18 chars, e.g. a sender profile ub_sp_...); null = no narrowing.
          description: Optional narrowing by sending identity.
      required:
        - name
        - target_url
        - events
    CreateWebhookResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - create
        item:
          type: object
          properties:
            sid:
              type: string
              description: Webhook sid (wh_hk_...).
            team_sid:
              type: string
              description: The subscribing workspace (ts_tm_...).
            name:
              type: string
              description: Free text, 1..255 chars.
            target_url:
              type: string
              description: The https endpoint events are POSTed to; one subscription per team per URL.
            events:
              type: array
              items:
                type: string
              description: The subscribed event types (WebhookEventTypeEnum values), exact membership.
            filters:
              type: object
              nullable: true
              properties:
                account_sid:
                  type: string
                  nullable: true
                  minLength: 18
                  maxLength: 18
                  description: Deliver only the events of this sending identity (18 chars, e.g. a sender profile ub_sp_...); null = no narrowing.
              description: The narrowing by sending identity; null or {} = every subscribed event.
            secret:
              type: string
              nullable: true
              description: "The 32-hex HMAC secret: in the create response only, null on every other read."
            status:
              type: string
              enum:
                - "on"
                - "off"
                - failed
              description: "on; off (switched off by hand); failed (20 failed deliveries in a row or one 410: revive with update status on)."
            consecutive_failed_attempts:
              type: integer
              description: Failed deliveries in a row, driven by the log; 20 trips the auto-disable.
            last_failure_at:
              type: string
              nullable: true
              description: ISO 8601 UTC of the most recent failed delivery.
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who subscribed.
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who deleted it; null while live.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
            deleted_at:
              type: string
              nullable: true
              description: ISO 8601 UTC; null = live.
          required:
            - sid
            - team_sid
            - name
            - target_url
            - events
            - filters
            - status
            - consecutive_failed_attempts
            - last_failure_at
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        already_exists:
          type: boolean
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - item
        - already_exists
        - meta
    DeleteCustomToolResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - delete
        item:
          type: object
          additionalProperties: {}
        already_deleted:
          type: boolean
        soft_deleted:
          type: boolean
        retained:
          type: array
          items:
            type: string
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - item
        - already_deleted
        - soft_deleted
        - retained
        - meta
    DeleteProviderConnectionResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - delete
        item:
          type: object
          additionalProperties: {}
        already_deleted:
          type: boolean
        soft_deleted:
          type: boolean
        retained:
          type: array
          items:
            type: string
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - item
        - already_deleted
        - soft_deleted
        - retained
        - meta
    DeleteWebhookResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - delete
        item:
          type: object
          additionalProperties: {}
        already_deleted:
          type: boolean
        soft_deleted:
          type: boolean
        retained:
          type: array
          items:
            type: string
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - item
        - already_deleted
        - soft_deleted
        - retained
        - meta
    GetProviderCallResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - get
        item:
          type: object
          properties:
            sid:
              type: string
              description: Call sid (in_pc_...).
            team_sid:
              type: string
              description: The workspace (ts_tm_...).
            source_service:
              type: string
              description: "Who asked: playtables, unibox, agents, api, app."
            tool_type:
              type: string
              nullable: true
              description: "The caller's tool kind: playtable_field (a cell), playtable_action, workflow_task, agent_run, custom_tool, dictation."
            tool_sid:
              type: string
              nullable: true
              description: The invoking row (a field pt_fd_, a run...); opaque, may dangle.
            object_type:
              type: string
              nullable: true
              description: "The row the call was about: people, company, conversation."
            object_sid:
              type: string
              nullable: true
              description: Its sid; opaque, may dangle.
            operation:
              type: string
              enum:
                - llm.generate
                - llm.embed
                - email.find
                - email.verify
                - http.request
                - crm.contact_upsert
                - crm.company_upsert
                - crm.associate
                - crm.properties_list
                - serp.search
                - audio.transcribe
              description: What was called.
            provider:
              type: string
              enum:
                - openai
                - anthropic
                - google
                - deepseek
                - xai
                - voyage
                - cohere
                - hunter
                - findymail
                - anymailfinder
                - emaillistverify
                - custom
                - hubspot
                - serper
              description: The adapter that ran it.
            model:
              type: string
              nullable: true
              description: "The model on an llm or audio call: the price axis; null elsewhere."
            custom_tool_sid:
              type: string
              nullable: true
              description: The custom tool of an http.request (in_tl_...); null elsewhere.
            provider_connection_sid:
              type: string
              nullable: true
              description: The team grant of a crm call or the tool's connection; null = the platform key.
            status:
              type: string
              enum:
                - pending
                - in_progress
                - success
                - failed
                - retrying
                - cancelled
              description: success | failed for a finished call; pending = an http.request claimed and never finalized (outcome unknown).
            http_code:
              type: integer
              nullable: true
              description: The provider's answer; null on a network error or timeout.
            duration_ms:
              type: integer
              nullable: true
              description: Wall clock of the attempt.
            error_code:
              type: string
              nullable: true
              enum:
                - auth_error
                - rate_limited
                - timeout
                - network_error
                - invalid_input
                - provider_error
                - not_found
              description: The classified failure; not_found = an operation-level miss (no email exists); null on success.
            error_message:
              type: string
              nullable: true
              description: A tenant-readable rendering; the raw body is in response.
            request:
              type: object
              nullable: true
              additionalProperties: {}
              description: The sanitized provider request (no auth material); capped at 64 KB; null on search rows.
            response:
              type: object
              nullable: true
              additionalProperties: {}
              description: The raw provider body, truncated to 16 KB; null on search rows.
            output:
              type: object
              nullable: true
              additionalProperties: {}
              description: The normalized result the caller received; null on search rows.
            prompt_tokens:
              type: integer
              nullable: true
              description: llm calls only.
            completion_tokens:
              type: integer
              nullable: true
              description: llm calls only.
            total_tokens:
              type: integer
              nullable: true
              description: llm calls only.
            cache_hit:
              type: boolean
              description: true = answered from the cross-team result cache, no round-trip, 0 credits.
            credits_charged:
              anyOf:
                - type: number
                - type: string
              description: Credits priced at call time (a decimal); 0 on a failure, a cache hit, a bundled call.
            billing:
              type: string
              nullable: true
              enum:
                - standard
                - bundled
                - caller
              description: standard = the catalog rate, held and settled on the team wallet by the platform (the billing bus, 2026-10-22); bundled = folded into a charge the caller already made (0); caller = the caller meters it against the wallet itself under the same key (the email finder and verifier of a waterfall); null on rows before the column.
            idempotency_key:
              type: string
              description: The caller's end-to-end dedup key; a replay returns the stored outcome.
            created_at:
              type: string
              description: "ISO 8601 UTC: the metrics period column."
            updated_at:
              type: string
              description: ISO 8601 UTC.
          required:
            - sid
            - team_sid
            - source_service
            - tool_type
            - tool_sid
            - object_type
            - object_sid
            - operation
            - provider
            - model
            - custom_tool_sid
            - provider_connection_sid
            - status
            - http_code
            - duration_ms
            - error_code
            - error_message
            - request
            - response
            - output
            - prompt_tokens
            - completion_tokens
            - total_tokens
            - cache_hit
            - credits_charged
            - billing
            - idempotency_key
            - created_at
            - updated_at
        included:
          type: object
          properties:
            provider_connection:
              type: object
              nullable: true
              additionalProperties: {}
              description: The connection the call ran through (ProviderConnectionDomain); null for platform-key calls and dangling refs.
        includes:
          type: array
          items:
            type: string
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - item
        - included
        - includes
        - meta
    GetProviderCallsMetricsRequest:
      type: object
      description: Request body of `get_provider_calls_metrics`.
      properties:
        filter:
          type: object
          properties:
            sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: Call sid(s).
            operation:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - llm.generate
                    - llm.embed
                    - email.find
                    - email.verify
                    - http.request
                    - crm.contact_upsert
                    - crm.company_upsert
                    - crm.associate
                    - crm.properties_list
                    - serp.search
                    - audio.transcribe
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - llm.generate
                      - llm.embed
                      - email.find
                      - email.verify
                      - http.request
                      - crm.contact_upsert
                      - crm.company_upsert
                      - crm.associate
                      - crm.properties_list
                      - serp.search
                      - audio.transcribe
              additionalProperties: false
              description: llm.generate, email.find, http.request, crm.*...
            provider:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - openai
                    - anthropic
                    - google
                    - deepseek
                    - xai
                    - voyage
                    - cohere
                    - hunter
                    - findymail
                    - anymailfinder
                    - emaillistverify
                    - custom
                    - hubspot
                    - serper
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - openai
                      - anthropic
                      - google
                      - deepseek
                      - xai
                      - voyage
                      - cohere
                      - hunter
                      - findymail
                      - anymailfinder
                      - emaillistverify
                      - custom
                      - hubspot
                      - serper
              additionalProperties: false
              description: The adapter.
            model:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
                is_null:
                  type: boolean
              additionalProperties: false
              description: The model of llm and audio calls.
            provider_connection_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
                is_null:
                  type: boolean
              additionalProperties: false
              description: Calls through one connection (is this key working); is_null true = platform-key calls.
            custom_tool_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: One custom tool's calls.
            source_service:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: playtables | unibox | agents | api | app.
            tool_type:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: playtable_field, workflow_task, agent_run, custom_tool, dictation.
            tool_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: "One cell's or one run's attempts (with object_sid: one cell)."
            object_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: What was called about one person or company.
            status:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - pending
                    - in_progress
                    - success
                    - failed
                    - retrying
                    - cancelled
                ne:
                  type: string
                  enum:
                    - pending
                    - in_progress
                    - success
                    - failed
                    - retrying
                    - cancelled
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - pending
                      - in_progress
                      - success
                      - failed
                      - retrying
                      - cancelled
              additionalProperties: false
              description: success | failed | pending.
            error_code:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - auth_error
                    - rate_limited
                    - timeout
                    - network_error
                    - invalid_input
                    - provider_error
                    - not_found
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - auth_error
                      - rate_limited
                      - timeout
                      - network_error
                      - invalid_input
                      - provider_error
                      - not_found
                is_null:
                  type: boolean
              additionalProperties: false
              description: auth_error is the evidence behind a failed connection.
            cache_hit:
              type: object
              properties:
                eq:
                  type: boolean
              additionalProperties: false
              description: true = served from the cache.
            idempotency_key:
              type: object
              properties:
                eq:
                  type: string
              additionalProperties: false
              description: The call behind one exact charge.
            credits_charged:
              type: object
              properties:
                eq:
                  type: number
                gte:
                  type: number
                lte:
                  type: number
                gt:
                  type: number
                lt:
                  type: number
              additionalProperties: false
              description: gt 0 = the paid subset.
            created_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds; a lower bound makes the scan bounded.
          description: "Scopes the rows the metrics are computed over: the search filter operators. Omit for all rows."
        period:
          type: object
          properties:
            from:
              type: string
              description: ISO 8601 UTC window start (inclusive).
            to:
              type: string
              description: ISO 8601 UTC window end; at most 90 days after from.
          required:
            - from
            - to
          description: Required metrics window.
        group_by:
          type: string
          nullable: true
          enum:
            - operation
            - provider
            - model
            - status
            - error_code
            - source_service
            - cache_hit
            - created_date
          description: One split axis; omit for one total.
      required:
        - period
    GetProviderCallsMetricsResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - metrics
        metrics:
          type: object
          properties:
            filter:
              type: object
              additionalProperties: {}
            period:
              type: object
              properties:
                from:
                  type: string
                to:
                  type: string
              required:
                - from
                - to
            aggregated:
              type: object
              properties:
                counts:
                  type: object
                  additionalProperties: {}
                metrics:
                  type: object
                  properties:
                    credits_charged_sum:
                      type: number
                      description: The spend of the window in credits.
                    total_tokens_sum:
                      type: number
                      nullable: true
                      description: LLM token volume; null when no llm rows are in scope.
                    avg_duration_ms:
                      type: number
                      nullable: true
                      description: Mean over rows with a duration.
                    error_rate:
                      type: number
                      description: failed over total, 0..1.
                    cache_hit_rate:
                      type: number
                      description: cache hits over the rows of cacheable operations, 0..1.
                  required:
                    - credits_charged_sum
                    - total_tokens_sum
                    - avg_duration_ms
                    - error_rate
                    - cache_hit_rate
            metrics:
              type: object
              properties:
                credits_charged_sum:
                  type: number
                  description: The spend of the window in credits.
                total_tokens_sum:
                  type: number
                  nullable: true
                  description: LLM token volume; null when no llm rows are in scope.
                avg_duration_ms:
                  type: number
                  nullable: true
                  description: Mean over rows with a duration.
                error_rate:
                  type: number
                  description: failed over total, 0..1.
                cache_hit_rate:
                  type: number
                  description: cache hits over the rows of cacheable operations, 0..1.
              required:
                - credits_charged_sum
                - total_tokens_sum
                - avg_duration_ms
                - error_rate
                - cache_hit_rate
        applied_filters:
          type: object
          additionalProperties: {}
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - metrics
        - meta
    GetWebhookLogsMetricsRequest:
      type: object
      description: Request body of `get_webhook_logs_metrics`.
      properties:
        filter:
          type: object
          properties:
            sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: Delivery sid(s).
            webhook_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: One subscription's deliveries.
            account_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
                is_null:
                  type: boolean
              additionalProperties: false
              description: One sending identity; is_null true = team-wide events.
            source_service:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: playtables | unibox | signals | integrations.
            event_type:
              type: object
              properties:
                eq:
                  type: string
                ne:
                  type: string
                in:
                  type: array
                  items:
                    type: string
                nin:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: The event type.
            event_source_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: The row that produced the event.
            status:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - pending
                    - in_progress
                    - retrying
                    - success
                    - failed
                    - cancelled
                ne:
                  type: string
                  enum:
                    - pending
                    - in_progress
                    - retrying
                    - success
                    - failed
                    - cancelled
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - pending
                      - in_progress
                      - retrying
                      - success
                      - failed
                      - cancelled
                nin:
                  type: array
                  items:
                    type: string
                    enum:
                      - pending
                      - in_progress
                      - retrying
                      - success
                      - failed
                      - cancelled
              additionalProperties: false
              description: in [pending, retrying] = still in flight.
            cancel_reason:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - manual
                    - webhook_deleted
                    - webhook_disabled
                    - webhook_failed
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - manual
                      - webhook_deleted
                      - webhook_disabled
                      - webhook_failed
                is_null:
                  type: boolean
              additionalProperties: false
              description: Why a row was cancelled.
            retry_count:
              type: object
              properties:
                eq:
                  type: number
                ne:
                  type: number
                gte:
                  type: number
                lte:
                  type: number
                gt:
                  type: number
                lt:
                  type: number
              additionalProperties: false
              description: Executed attempts.
            response_code:
              type: object
              properties:
                eq:
                  type: number
                ne:
                  type: number
                gte:
                  type: number
                lte:
                  type: number
                gt:
                  type: number
                lt:
                  type: number
                is_null:
                  type: boolean
              additionalProperties: false
              description: is_null true = no HTTP answer (network, timeout).
            duration_ms:
              type: object
              properties:
                eq:
                  type: number
                ne:
                  type: number
                gte:
                  type: number
                lte:
                  type: number
                gt:
                  type: number
                lt:
                  type: number
                is_null:
                  type: boolean
              additionalProperties: false
              description: The last attempt's latency.
            scheduled_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds.
            executed_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
                is_null:
                  type: boolean
              additionalProperties: false
              description: ISO 8601 bounds; is_null true = never attempted.
            created_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds.
          description: "Scopes the rows the metrics are computed over: the search filter operators. Omit for all rows."
        period:
          type: object
          properties:
            from:
              type: string
              description: ISO 8601 UTC window start (inclusive).
            to:
              type: string
              description: ISO 8601 UTC window end (exclusive).
          required:
            - from
            - to
          description: Required metrics window.
        group_by:
          type: string
          enum:
            - status
            - event_type
            - response_code
            - webhook_sid
            - account_sid
          description: One split axis; omit for one total.
      required:
        - period
    GetWebhookLogsMetricsResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - metrics
        metrics:
          type: object
          properties:
            filter:
              type: object
              additionalProperties: {}
            period:
              type: object
              properties:
                from:
                  type: string
                to:
                  type: string
              required:
                - from
                - to
            aggregated:
              type: object
              properties:
                counts:
                  type: object
                  additionalProperties: {}
                metrics:
                  type: object
                  properties:
                    success_rate:
                      type: number
                      nullable: true
                      description: 0..1 over the terminal rows; null when none.
                    failure_rate:
                      type: number
                      nullable: true
                      description: 0..1, the mirror of success_rate.
                    avg_duration_ms:
                      type: number
                      nullable: true
                      description: Mean over timed rows.
                    p50_duration_ms:
                      type: number
                      nullable: true
                      description: Median latency over terminal rows.
                    p95_duration_ms:
                      type: number
                      nullable: true
                      description: 95th percentile.
                    p99_duration_ms:
                      type: number
                      nullable: true
                      description: 99th percentile.
                    total_retries:
                      type: number
                      description: Sum of retry_count over the set.
                    last_success_at:
                      type: string
                      nullable: true
                      description: The latest successful delivery in the window.
                    last_failure_at:
                      type: string
                      nullable: true
                      description: The latest failed delivery in the window.
                  required:
                    - success_rate
                    - failure_rate
                    - avg_duration_ms
                    - p50_duration_ms
                    - p95_duration_ms
                    - p99_duration_ms
                    - total_retries
                    - last_success_at
                    - last_failure_at
            metrics:
              type: object
              properties:
                success_rate:
                  type: number
                  nullable: true
                  description: 0..1 over the terminal rows; null when none.
                failure_rate:
                  type: number
                  nullable: true
                  description: 0..1, the mirror of success_rate.
                avg_duration_ms:
                  type: number
                  nullable: true
                  description: Mean over timed rows.
                p50_duration_ms:
                  type: number
                  nullable: true
                  description: Median latency over terminal rows.
                p95_duration_ms:
                  type: number
                  nullable: true
                  description: 95th percentile.
                p99_duration_ms:
                  type: number
                  nullable: true
                  description: 99th percentile.
                total_retries:
                  type: number
                  description: Sum of retry_count over the set.
                last_success_at:
                  type: string
                  nullable: true
                  description: The latest successful delivery in the window.
                last_failure_at:
                  type: string
                  nullable: true
                  description: The latest failed delivery in the window.
              required:
                - success_rate
                - failure_rate
                - avg_duration_ms
                - p50_duration_ms
                - p95_duration_ms
                - p99_duration_ms
                - total_retries
                - last_success_at
                - last_failure_at
        applied_filters:
          type: object
          additionalProperties: {}
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - metrics
        - meta
    GetWebhookResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - get
        item:
          type: object
          properties:
            sid:
              type: string
              description: Webhook sid (wh_hk_...).
            team_sid:
              type: string
              description: The subscribing workspace (ts_tm_...).
            name:
              type: string
              description: Free text, 1..255 chars.
            target_url:
              type: string
              description: The https endpoint events are POSTed to; one subscription per team per URL.
            events:
              type: array
              items:
                type: string
              description: The subscribed event types (WebhookEventTypeEnum values), exact membership.
            filters:
              type: object
              nullable: true
              properties:
                account_sid:
                  type: string
                  nullable: true
                  minLength: 18
                  maxLength: 18
                  description: Deliver only the events of this sending identity (18 chars, e.g. a sender profile ub_sp_...); null = no narrowing.
              description: The narrowing by sending identity; null or {} = every subscribed event.
            secret:
              type: string
              nullable: true
              description: "The 32-hex HMAC secret: in the create response only, null on every other read."
            status:
              type: string
              enum:
                - "on"
                - "off"
                - failed
              description: "on; off (switched off by hand); failed (20 failed deliveries in a row or one 410: revive with update status on)."
            consecutive_failed_attempts:
              type: integer
              description: Failed deliveries in a row, driven by the log; 20 trips the auto-disable.
            last_failure_at:
              type: string
              nullable: true
              description: ISO 8601 UTC of the most recent failed delivery.
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who subscribed.
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who deleted it; null while live.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
            deleted_at:
              type: string
              nullable: true
              description: ISO 8601 UTC; null = live.
          required:
            - sid
            - team_sid
            - name
            - target_url
            - events
            - filters
            - status
            - consecutive_failed_attempts
            - last_failure_at
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        included:
          type: object
          properties:
            latest_webhook_logs:
              type: array
              items:
                type: object
                additionalProperties: {}
              description: The most recent delivery rows (WebhookLogDomain) of the subscription.
        includes:
          type: array
          items:
            type: string
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - item
        - included
        - includes
        - meta
    ListProviderCatalogResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - action
        action:
          type: string
          description: kebab-case verb; matches the route segment.
        item: {}
        result:
          type: object
          properties:
            entries:
              type: array
              items:
                type: object
                properties:
                  operation:
                    type: string
                    enum:
                      - llm.generate
                      - llm.embed
                      - email.find
                      - email.verify
                      - http.request
                      - crm.contact_upsert
                      - crm.company_upsert
                      - crm.associate
                      - crm.properties_list
                      - serp.search
                      - audio.transcribe
                    description: The operation.
                  provider:
                    type: string
                    enum:
                      - openai
                      - anthropic
                      - google
                      - deepseek
                      - xai
                      - voyage
                      - cohere
                      - hunter
                      - findymail
                      - anymailfinder
                      - emaillistverify
                      - custom
                      - hubspot
                      - serper
                    description: The adapter.
                  model:
                    type: string
                    nullable: true
                    description: One entry per priced model on llm and audio operations; null elsewhere.
                  name:
                    type: string
                    description: "Display name (Find email: Hunter)."
                  description:
                    type: string
                    nullable: true
                    description: Display copy for the pickers.
                  platform_key:
                    type: boolean
                    description: true = a platform key is configured, callable now; a crm entry has none by design (it runs on the team's grant).
                  pricing_unit:
                    type: string
                    description: "per_call (the rate is the product's own credit price for the vendor) | per_token (the vendor's dollars per token plus the product's margin, 2026-10-30: a call is billed on its own token counts)."
                  price_min:
                    type: number
                    description: "Credits, a quote with no prompt in hand: a per_call rate; for a per_token entry a short reference call (200 tokens in, 50 out)."
                  price_expected:
                    type: number
                    description: "Credits, the quote of a typical call (1,000 in, 300 out). A row of a Use AI column is priced on its own prompt instead: estimate_playtable_field_ai_cost."
                  price_max:
                    type: number
                    description: Credits, the quote of the reference prompt with the model's whole output cap.
                  credits_per_mtok_input:
                    type: number
                    nullable: true
                    description: "per_token: the credits a million input tokens cost a team, the vendor's price with the margin at the rate; null on a per_call entry."
                  credits_per_mtok_output:
                    type: number
                    nullable: true
                    description: "per_token: the same for output tokens; 0 where the vendor bills none (an embedding)."
                  max_tokens:
                    type: integer
                    nullable: true
                    description: "per_token: the model's completion cap, the ceiling of a row's price."
                  cacheable:
                    type: boolean
                    description: "email.find and email.verify: a repeat is free."
                  web_search:
                    type: boolean
                    description: "llm.generate: the model can run the vendor's web search."
                  price_web_search:
                    type: number
                    nullable: true
                    description: Credits per search (the vendor's fee with the margin) on top of the tokens; null when it cannot search.
                  web_search_overhead_tokens:
                    type: integer
                    nullable: true
                    description: The prompt tokens the vendor bills for declaring the search tool, searched or not; null when it cannot search.
                  web_search_max_uses:
                    type: integer
                    nullable: true
                    description: The searches one call may run at most; null when it cannot search.
                  price_with_web_search_min:
                    type: number
                    nullable: true
                    description: The triple of the same call with the search tool declared (its overhead billed searched or not).
                  price_with_web_search_expected:
                    type: number
                    nullable: true
                    description: As above, expected.
                  price_with_web_search_max:
                    type: number
                    nullable: true
                    description: As above, max.
                  default:
                    type: boolean
                    description: The one default model of an llm operation (model auto resolves to it).
                  dimensions:
                    type: integer
                    nullable: true
                    description: "llm.embed: the pinned vector size (1024); null elsewhere."
                required:
                  - operation
                  - provider
                  - model
                  - name
                  - description
                  - platform_key
                  - pricing_unit
                  - price_min
                  - price_expected
                  - price_max
                  - credits_per_mtok_input
                  - credits_per_mtok_output
                  - max_tokens
                  - cacheable
                  - web_search
                  - price_web_search
                  - web_search_overhead_tokens
                  - web_search_max_uses
                  - price_with_web_search_min
                  - price_with_web_search_expected
                  - price_with_web_search_max
                  - default
                  - dimensions
              description: The catalog, one entry per priced operation.
          required:
            - entries
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - action
        - item
        - result
        - meta
    McpError:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - validation_failed
                - nothing_to_update
                - not_found
                - relation_not_found
                - invalid_transition
                - limit_exceeded
                - payment_required
                - duplicate_rejected
                - conflict
                - delete_blocked
                - unauthorized
                - forbidden
                - rate_limited
                - internal_error
                - service_unavailable
                - not_implemented
            message:
              type: string
            recoverable:
              type: boolean
            suggestion:
              type: string
            field_errors:
              type: object
              additionalProperties:
                type: array
                items:
                  type: object
                  properties:
                    rule:
                      type: string
                    message:
                      type: string
                  required:
                    - rule
                    - message
            blockers:
              type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                    description: Machine-readable blocker type (active_flow, pending_tasks, …).
                  severity:
                    type: string
                    enum:
                      - hard
                      - soft
                    description: hard = external action required; soft = acknowledge is enough.
                  description:
                    type: string
                  entity_sid:
                    type: string
                    nullable: true
                  count:
                    type: integer
                  resolution:
                    type: string
                    description: "Hard: tool name to call. Soft: code for acknowledge[]."
                  resolution_hint:
                    type: string
                required:
                  - type
                  - severity
                  - description
                  - entity_sid
                  - resolution
                  - resolution_hint
            context:
              type: object
              additionalProperties: {}
          required:
            - code
            - message
            - recoverable
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - error
    RetryWebhookLogRequest:
      type: object
      description: Request body of `retry_webhook_log`.
      properties:
        expected_status:
          type: string
          enum:
            - pending
            - in_progress
            - retrying
            - success
            - failed
            - cancelled
          description: "Optional guard: the retry only runs when the row still has this status."
    RetryWebhookLogResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - action
        action:
          type: string
          description: kebab-case verb; matches the route segment.
        item:
          type: object
          nullable: true
          properties:
            sid:
              type: string
              description: Delivery sid (wh_lg_...).
            team_sid:
              type: string
              description: The subscribing workspace (ts_tm_...).
            webhook_sid:
              type: string
              description: The parent subscription (wh_hk_...).
            account_sid:
              type: string
              nullable: true
              description: The sending identity the subscription matched on (ub_sp_...); null on a team-wide event.
            source_service:
              type: string
              nullable: true
              description: Which service produced the event (playtables, unibox, signals, integrations); observability only.
            event_type:
              type: string
              description: The event type (a WebhookEventTypeEnum value).
            event_source_sid:
              type: string
              nullable: true
              description: The row whose state change produced the event; null when none.
            status:
              type: string
              enum:
                - pending
                - in_progress
                - retrying
                - success
                - failed
                - cancelled
              description: pending or retrying = waiting for the tick; in_progress = leased by a worker; success; failed (the ladder ran out, or a 4xx); cancelled.
            retry_count:
              type: integer
              description: Executed attempts; a manual re-arm does not move it.
            cancel_reason:
              type: string
              nullable: true
              enum:
                - manual
                - webhook_deleted
                - webhook_disabled
                - webhook_failed
              description: manual, or the cascade of a deleted, disabled or failed webhook; null unless cancelled.
            request_method:
              type: string
              enum:
                - POST
              description: POST.
            request_url:
              type: string
              description: "The target URL at insert: a retry replays it."
            request_headers:
              type: object
              additionalProperties:
                type: string
              description: The X-Webhook-* and X-Trace-Id headers as sent.
            request_payload:
              type: object
              properties:
                webhook_log_sid:
                  type: string
                  description: "This row's own sid: the receiver's dedup key."
                type:
                  type: string
                  description: The event type (a WebhookEventTypeEnum value).
                emitted_at:
                  type: string
                  description: ISO 8601 UTC of the state change.
                team_sid:
                  type: string
                  description: The workspace (ts_tm_...).
                trace_id:
                  type: string
                  description: The trace of the write that produced the event.
                payload:
                  type: object
                  additionalProperties: {}
                  description: The event-specific payload.
              required:
                - webhook_log_sid
                - type
                - emitted_at
                - team_sid
                - trace_id
                - payload
              description: The stored envelope.
            response_code:
              type: integer
              nullable: true
              description: The receiver's status; null on a network error.
            error_message:
              type: string
              nullable: true
              description: The last attempt's error.
            duration_ms:
              type: integer
              nullable: true
              description: The last attempt's wall clock; null before one ran.
            scheduled_at:
              type: string
              description: ISO 8601 UTC when the next (or last) attempt is due.
            executed_at:
              type: string
              nullable: true
              description: ISO 8601 UTC of the last attempt; null before one ran.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
          required:
            - sid
            - team_sid
            - webhook_sid
            - account_sid
            - source_service
            - event_type
            - event_source_sid
            - status
            - retry_count
            - cancel_reason
            - request_method
            - request_url
            - request_headers
            - request_payload
            - response_code
            - error_message
            - duration_ms
            - scheduled_at
            - executed_at
            - created_at
            - updated_at
        result:
          type: object
          properties:
            previous_status:
              type: string
              enum:
                - pending
                - in_progress
                - retrying
                - success
                - failed
                - cancelled
              description: The status before the re-arm.
            scheduled_at:
              type: string
              description: ISO 8601 UTC when the attempt is due (now).
            retry_count:
              type: integer
              description: Attempts executed so far; unchanged by the re-arm.
          required:
            - previous_status
            - scheduled_at
            - retry_count
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - action
        - item
        - result
        - meta
    SearchCustomToolsRequest:
      type: object
      description: Request body of `search_custom_tools`.
      properties:
        filter:
          type: object
          properties:
            sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: "Tool sid(s): the point lookup."
            status:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - "on"
                    - "off"
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - "on"
                      - "off"
              additionalProperties: false
              description: on | off.
            provider_connection_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
                is_null:
                  type: boolean
              additionalProperties: false
              description: The tools on one connection; is_null true = public-API tools.
            q:
              type: string
              maxLength: 255
              description: Infix match over the name.
            created_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds.
            deleted_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                is_null:
                  type: boolean
              additionalProperties: false
              description: "Default scope is { is_null: true }."
            deleted:
              type: boolean
              description: true = include soft-deleted rows.
          description: "Field filters, ANDed: {field: {eq | ne | in | nin | gte | lte | gt | lt | is_null}}; q inside it is free text. Omit for every row."
        include:
          type: array
          items:
            type: string
            enum:
              - provider_connection
          description: Relations to attach to every item; omit for the bare rows.
        sort:
          type: object
          properties:
            field:
              type: string
              enum:
                - created_at
                - updated_at
                - name
              description: The column to order by.
            direction:
              type: string
              enum:
                - asc
                - desc
              description: asc or desc; default desc.
          required:
            - field
          description: One column and its direction; omit for the default order.
        page_size:
          type: integer
          minimum: 0
          maximum: 500
          description: 0..500, default 50; 0 = counts only, 1 = the first row.
        cursor:
          type: string
          nullable: true
          description: pagination.next_cursor of the previous page.
    SearchCustomToolsResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - search
        items:
          type: array
          items:
            type: object
            properties:
              item:
                type: object
                properties:
                  sid:
                    type: string
                    description: Custom tool sid (in_tl_...).
                  team_sid:
                    type: string
                    description: The owning workspace (ts_tm_...).
                  name:
                    type: string
                    description: Unique within the team among live rows; what the tool pickers show.
                  description:
                    type: string
                    nullable: true
                    description: Free text, up to 2000 chars.
                  provider_connection_sid:
                    type: string
                    nullable: true
                    description: The connection the tool authenticates with (in_cn_...); null = no auth.
                  request:
                    type: object
                    properties:
                      method:
                        type: string
                        enum:
                          - GET
                          - POST
                          - PUT
                          - PATCH
                          - DELETE
                        description: The HTTP method.
                      url:
                        type: string
                        maxLength: 2048
                        pattern: ^https:\/\/
                        description: https URL; scheme and host literal (no placeholders, default port, public DNS), placeholders in the path and query only.
                      headers:
                        type: object
                        additionalProperties:
                          type: string
                          maxLength: 1024
                        description: "Up to 20 headers; values may hold placeholders. Auth-shaped names (authorization, cookie, token, key...) and Content-Type are refused: auth comes from the connection."
                      body:
                        type: object
                        nullable: true
                        additionalProperties: {}
                        description: A JSON template; null on GET and DELETE. String leaves may hold placeholders; a leaf that IS {{key}} renders with the input's native type.
                    required:
                      - method
                      - url
                    description: The request template.
                  input_schema:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                          description: The placeholder name.
                        type:
                          type: string
                          description: string | number | boolean.
                        required:
                          type: boolean
                          description: Whether a call must bind it.
                      required:
                        - key
                        - type
                        - required
                    description: The declared inputs (up to 30).
                  output_mapping:
                    type: object
                    additionalProperties:
                      type: string
                    description: name to dot-path into the response body (up to 20); {} = the raw body only.
                  status:
                    type: string
                    enum:
                      - "on"
                      - "off"
                    description: off = the executor refuses it with a failed row (custom_tool_disabled).
                  created_by:
                    type: object
                    properties:
                      actor_type:
                        type: string
                        enum:
                          - user
                          - support
                          - api_key
                          - system
                          - agent
                      actor_sid:
                        type: string
                        nullable: true
                      team_sid:
                        type: string
                      actor_name:
                        type: string
                        nullable: true
                        description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                      oauth_client_sid:
                        type: string
                        nullable: true
                        description: The acting OAuth client (id_oc_*); null off the OAuth path.
                      reason:
                        type: string
                        nullable: true
                        description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                      permissions:
                        type: object
                        additionalProperties: {}
                        description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                      cluster_id:
                        type: integer
                        nullable: true
                        description: "Internal audit context: the cluster that served the write."
                      trace_id:
                        type: string
                        nullable: true
                        description: "Internal audit context: the trace id of the request that wrote the row."
                    required:
                      - actor_type
                      - actor_sid
                      - team_sid
                      - permissions
                    description: Who defined the tool.
                  deleted_by:
                    type: object
                    nullable: true
                    properties:
                      actor_type:
                        type: string
                        enum:
                          - user
                          - support
                          - api_key
                          - system
                          - agent
                      actor_sid:
                        type: string
                        nullable: true
                      team_sid:
                        type: string
                      actor_name:
                        type: string
                        nullable: true
                        description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                      oauth_client_sid:
                        type: string
                        nullable: true
                        description: The acting OAuth client (id_oc_*); null off the OAuth path.
                      reason:
                        type: string
                        nullable: true
                        description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                      permissions:
                        type: object
                        additionalProperties: {}
                        description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                      cluster_id:
                        type: integer
                        nullable: true
                        description: "Internal audit context: the cluster that served the write."
                      trace_id:
                        type: string
                        nullable: true
                        description: "Internal audit context: the trace id of the request that wrote the row."
                    required:
                      - actor_type
                      - actor_sid
                      - team_sid
                      - permissions
                    description: Who deleted it; null while live.
                  created_at:
                    type: string
                    description: ISO 8601 UTC.
                  updated_at:
                    type: string
                    description: ISO 8601 UTC.
                  deleted_at:
                    type: string
                    nullable: true
                    description: ISO 8601 UTC; null = live.
                required:
                  - sid
                  - team_sid
                  - name
                  - description
                  - provider_connection_sid
                  - request
                  - input_schema
                  - output_mapping
                  - status
                  - created_by
                  - deleted_by
                  - created_at
                  - updated_at
                  - deleted_at
              included:
                type: object
                properties:
                  provider_connection:
                    type: object
                    nullable: true
                    additionalProperties: {}
                    description: The connection the tool authenticates with (ProviderConnectionDomain); null when none.
            required:
              - item
              - included
        pagination:
          type: object
          properties:
            next_cursor:
              type: string
              nullable: true
            has_more:
              type: boolean
            total_count:
              type: integer
              nullable: true
          required:
            - next_cursor
            - has_more
            - total_count
        applied_filters:
          type: object
          additionalProperties: {}
        includes:
          type: array
          items:
            type: string
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
        counts:
          type: object
          properties:
            total_count:
              type: number
              description: Tools matching the filter.
            groups:
              type: object
              additionalProperties: {}
              description: "status: the count per status."
          required:
            - total_count
            - groups
      required:
        - success
        - operation
        - items
        - pagination
        - applied_filters
        - includes
        - meta
    SearchProviderCallsRequest:
      type: object
      description: Request body of `search_provider_calls`.
      properties:
        filter:
          type: object
          properties:
            sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: Call sid(s).
            operation:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - llm.generate
                    - llm.embed
                    - email.find
                    - email.verify
                    - http.request
                    - crm.contact_upsert
                    - crm.company_upsert
                    - crm.associate
                    - crm.properties_list
                    - serp.search
                    - audio.transcribe
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - llm.generate
                      - llm.embed
                      - email.find
                      - email.verify
                      - http.request
                      - crm.contact_upsert
                      - crm.company_upsert
                      - crm.associate
                      - crm.properties_list
                      - serp.search
                      - audio.transcribe
              additionalProperties: false
              description: llm.generate, email.find, http.request, crm.*...
            provider:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - openai
                    - anthropic
                    - google
                    - deepseek
                    - xai
                    - voyage
                    - cohere
                    - hunter
                    - findymail
                    - anymailfinder
                    - emaillistverify
                    - custom
                    - hubspot
                    - serper
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - openai
                      - anthropic
                      - google
                      - deepseek
                      - xai
                      - voyage
                      - cohere
                      - hunter
                      - findymail
                      - anymailfinder
                      - emaillistverify
                      - custom
                      - hubspot
                      - serper
              additionalProperties: false
              description: The adapter.
            model:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
                is_null:
                  type: boolean
              additionalProperties: false
              description: The model of llm and audio calls.
            provider_connection_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
                is_null:
                  type: boolean
              additionalProperties: false
              description: Calls through one connection (is this key working); is_null true = platform-key calls.
            custom_tool_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: One custom tool's calls.
            source_service:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: playtables | unibox | agents | api | app.
            tool_type:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: playtable_field, workflow_task, agent_run, custom_tool, dictation.
            tool_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: "One cell's or one run's attempts (with object_sid: one cell)."
            object_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: What was called about one person or company.
            status:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - pending
                    - in_progress
                    - success
                    - failed
                    - retrying
                    - cancelled
                ne:
                  type: string
                  enum:
                    - pending
                    - in_progress
                    - success
                    - failed
                    - retrying
                    - cancelled
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - pending
                      - in_progress
                      - success
                      - failed
                      - retrying
                      - cancelled
              additionalProperties: false
              description: success | failed | pending.
            error_code:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - auth_error
                    - rate_limited
                    - timeout
                    - network_error
                    - invalid_input
                    - provider_error
                    - not_found
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - auth_error
                      - rate_limited
                      - timeout
                      - network_error
                      - invalid_input
                      - provider_error
                      - not_found
                is_null:
                  type: boolean
              additionalProperties: false
              description: auth_error is the evidence behind a failed connection.
            cache_hit:
              type: object
              properties:
                eq:
                  type: boolean
              additionalProperties: false
              description: true = served from the cache.
            idempotency_key:
              type: object
              properties:
                eq:
                  type: string
              additionalProperties: false
              description: The call behind one exact charge.
            credits_charged:
              type: object
              properties:
                eq:
                  type: number
                gte:
                  type: number
                lte:
                  type: number
                gt:
                  type: number
                lt:
                  type: number
              additionalProperties: false
              description: gt 0 = the paid subset.
            created_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds; a lower bound makes the scan bounded.
          description: "Field filters, ANDed: {field: {eq | ne | in | nin | gte | lte | gt | lt | is_null}}; q inside it is free text. Omit for every row."
        include:
          type: array
          items:
            type: string
            enum:
              - provider_connection
          description: Relations to attach to every item; omit for the bare rows.
        sort:
          type: object
          properties:
            field:
              type: string
              enum:
                - created_at
                - duration_ms
                - credits_charged
              description: The column to order by.
            direction:
              type: string
              enum:
                - asc
                - desc
              description: asc or desc; default desc.
          required:
            - field
          description: One column and its direction; omit for the default order.
        page_size:
          type: integer
          minimum: 0
          maximum: 500
          description: 0..500, default 50; 0 = counts only, 1 = the first row.
        cursor:
          type: string
          nullable: true
          description: pagination.next_cursor of the previous page.
    SearchProviderCallsResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - search
        items:
          type: array
          items:
            type: object
            properties:
              item:
                type: object
                properties:
                  sid:
                    type: string
                    description: Call sid (in_pc_...).
                  team_sid:
                    type: string
                    description: The workspace (ts_tm_...).
                  source_service:
                    type: string
                    description: "Who asked: playtables, unibox, agents, api, app."
                  tool_type:
                    type: string
                    nullable: true
                    description: "The caller's tool kind: playtable_field (a cell), playtable_action, workflow_task, agent_run, custom_tool, dictation."
                  tool_sid:
                    type: string
                    nullable: true
                    description: The invoking row (a field pt_fd_, a run...); opaque, may dangle.
                  object_type:
                    type: string
                    nullable: true
                    description: "The row the call was about: people, company, conversation."
                  object_sid:
                    type: string
                    nullable: true
                    description: Its sid; opaque, may dangle.
                  operation:
                    type: string
                    enum:
                      - llm.generate
                      - llm.embed
                      - email.find
                      - email.verify
                      - http.request
                      - crm.contact_upsert
                      - crm.company_upsert
                      - crm.associate
                      - crm.properties_list
                      - serp.search
                      - audio.transcribe
                    description: What was called.
                  provider:
                    type: string
                    enum:
                      - openai
                      - anthropic
                      - google
                      - deepseek
                      - xai
                      - voyage
                      - cohere
                      - hunter
                      - findymail
                      - anymailfinder
                      - emaillistverify
                      - custom
                      - hubspot
                      - serper
                    description: The adapter that ran it.
                  model:
                    type: string
                    nullable: true
                    description: "The model on an llm or audio call: the price axis; null elsewhere."
                  custom_tool_sid:
                    type: string
                    nullable: true
                    description: The custom tool of an http.request (in_tl_...); null elsewhere.
                  provider_connection_sid:
                    type: string
                    nullable: true
                    description: The team grant of a crm call or the tool's connection; null = the platform key.
                  status:
                    type: string
                    enum:
                      - pending
                      - in_progress
                      - success
                      - failed
                      - retrying
                      - cancelled
                    description: success | failed for a finished call; pending = an http.request claimed and never finalized (outcome unknown).
                  http_code:
                    type: integer
                    nullable: true
                    description: The provider's answer; null on a network error or timeout.
                  duration_ms:
                    type: integer
                    nullable: true
                    description: Wall clock of the attempt.
                  error_code:
                    type: string
                    nullable: true
                    enum:
                      - auth_error
                      - rate_limited
                      - timeout
                      - network_error
                      - invalid_input
                      - provider_error
                      - not_found
                    description: The classified failure; not_found = an operation-level miss (no email exists); null on success.
                  error_message:
                    type: string
                    nullable: true
                    description: A tenant-readable rendering; the raw body is in response.
                  request:
                    type: object
                    nullable: true
                    additionalProperties: {}
                    description: The sanitized provider request (no auth material); capped at 64 KB; null on search rows.
                  response:
                    type: object
                    nullable: true
                    additionalProperties: {}
                    description: The raw provider body, truncated to 16 KB; null on search rows.
                  output:
                    type: object
                    nullable: true
                    additionalProperties: {}
                    description: The normalized result the caller received; null on search rows.
                  prompt_tokens:
                    type: integer
                    nullable: true
                    description: llm calls only.
                  completion_tokens:
                    type: integer
                    nullable: true
                    description: llm calls only.
                  total_tokens:
                    type: integer
                    nullable: true
                    description: llm calls only.
                  cache_hit:
                    type: boolean
                    description: true = answered from the cross-team result cache, no round-trip, 0 credits.
                  credits_charged:
                    anyOf:
                      - type: number
                      - type: string
                    description: Credits priced at call time (a decimal); 0 on a failure, a cache hit, a bundled call.
                  billing:
                    type: string
                    nullable: true
                    enum:
                      - standard
                      - bundled
                      - caller
                    description: standard = the catalog rate, held and settled on the team wallet by the platform (the billing bus, 2026-10-22); bundled = folded into a charge the caller already made (0); caller = the caller meters it against the wallet itself under the same key (the email finder and verifier of a waterfall); null on rows before the column.
                  idempotency_key:
                    type: string
                    description: The caller's end-to-end dedup key; a replay returns the stored outcome.
                  created_at:
                    type: string
                    description: "ISO 8601 UTC: the metrics period column."
                  updated_at:
                    type: string
                    description: ISO 8601 UTC.
                required:
                  - sid
                  - team_sid
                  - source_service
                  - tool_type
                  - tool_sid
                  - object_type
                  - object_sid
                  - operation
                  - provider
                  - model
                  - custom_tool_sid
                  - provider_connection_sid
                  - status
                  - http_code
                  - duration_ms
                  - error_code
                  - error_message
                  - request
                  - response
                  - output
                  - prompt_tokens
                  - completion_tokens
                  - total_tokens
                  - cache_hit
                  - credits_charged
                  - billing
                  - idempotency_key
                  - created_at
                  - updated_at
              included:
                type: object
                properties:
                  provider_connection:
                    type: object
                    nullable: true
                    additionalProperties: {}
                    description: The connection the call ran through (ProviderConnectionDomain); null for platform-key calls and dangling refs.
            required:
              - item
              - included
        pagination:
          type: object
          properties:
            next_cursor:
              type: string
              nullable: true
            has_more:
              type: boolean
            total_count:
              type: integer
              nullable: true
          required:
            - next_cursor
            - has_more
            - total_count
        applied_filters:
          type: object
          additionalProperties: {}
        includes:
          type: array
          items:
            type: string
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
        counts:
          type: object
          properties:
            total_count:
              type: number
              description: Calls matching the filter (the bounded scope).
            groups:
              type: object
              additionalProperties: {}
              description: "operation, provider, model, status, error_code, source_service, cache_hit, created_date: the count per value."
          required:
            - total_count
            - groups
      required:
        - success
        - operation
        - items
        - pagination
        - applied_filters
        - includes
        - meta
    SearchProviderConnectionsRequest:
      type: object
      description: Request body of `search_provider_connections`.
      properties:
        filter:
          type: object
          properties:
            sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: "Connection sid(s): the point lookup."
            provider:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - openai
                    - anthropic
                    - google
                    - deepseek
                    - xai
                    - voyage
                    - cohere
                    - hunter
                    - findymail
                    - anymailfinder
                    - emaillistverify
                    - custom
                    - hubspot
                    - serper
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - openai
                      - anthropic
                      - google
                      - deepseek
                      - xai
                      - voyage
                      - cohere
                      - hunter
                      - findymail
                      - anymailfinder
                      - emaillistverify
                      - custom
                      - hubspot
                      - serper
              additionalProperties: false
              description: custom | hubspot.
            auth_type:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - api_key
                    - bearer
                    - basic
                    - header
                    - query
                    - oauth
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - api_key
                      - bearer
                      - basic
                      - header
                      - query
                      - oauth
              additionalProperties: false
              description: The secret shape.
            status:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - "on"
                    - "off"
                    - failed
                ne:
                  type: string
                  enum:
                    - "on"
                    - "off"
                    - failed
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - "on"
                      - "off"
                      - failed
              additionalProperties: false
              description: status.eq failed = the auto-disabled ones.
            q:
              type: string
              maxLength: 255
              description: Infix match over the name.
            created_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds.
            deleted_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                is_null:
                  type: boolean
              additionalProperties: false
              description: "Default scope is { is_null: true }."
            deleted:
              type: boolean
              description: true = include soft-deleted rows.
          description: "Field filters, ANDed: {field: {eq | ne | in | nin | gte | lte | gt | lt | is_null}}; q inside it is free text. Omit for every row."
        sort:
          type: object
          properties:
            field:
              type: string
              enum:
                - created_at
                - updated_at
                - name
                - last_failure_at
              description: The column to order by.
            direction:
              type: string
              enum:
                - asc
                - desc
              description: asc or desc; default desc.
          required:
            - field
          description: One column and its direction; omit for the default order.
        page_size:
          type: integer
          minimum: 0
          maximum: 500
          description: 0..500, default 50; 0 = counts only, 1 = the first row.
        cursor:
          type: string
          nullable: true
          description: pagination.next_cursor of the previous page.
    SearchProviderConnectionsResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - search
        items:
          type: array
          items:
            type: object
            properties:
              item:
                type: object
                properties:
                  sid:
                    type: string
                    description: Connection sid (in_cn_...).
                  team_sid:
                    type: string
                    description: The owning workspace (ts_tm_...).
                  name:
                    type: string
                    description: Display name, unique within the team among live rows.
                  provider:
                    type: string
                    enum:
                      - openai
                      - anthropic
                      - google
                      - deepseek
                      - xai
                      - voyage
                      - cohere
                      - hunter
                      - findymail
                      - anymailfinder
                      - emaillistverify
                      - custom
                      - hubspot
                      - serper
                    description: custom (the team's own API) or hubspot (a CRM grant); immutable.
                  auth_type:
                    type: string
                    enum:
                      - api_key
                      - bearer
                      - basic
                      - header
                      - query
                      - oauth
                    description: The shape of the stored secret; oauth on a HubSpot grant.
                  external_account_id:
                    type: string
                    nullable: true
                    description: "The provider-side account of an OAuth grant (the HubSpot portal id): the reconnect key; null on key auth."
                  status:
                    type: string
                    enum:
                      - "on"
                      - "off"
                      - failed
                    description: on; off (paused by hand); failed (auto-disabled after five auth failures in a row, revived by update or a reconnect).
                  consecutive_failed_attempts:
                    type: integer
                    description: Auth-classified failures in a row; any non-cache success or a rotation resets it.
                  last_failure_at:
                    type: string
                    nullable: true
                    description: ISO 8601 UTC of the last auth failure.
                  created_by:
                    type: object
                    properties:
                      actor_type:
                        type: string
                        enum:
                          - user
                          - support
                          - api_key
                          - system
                          - agent
                      actor_sid:
                        type: string
                        nullable: true
                      team_sid:
                        type: string
                      actor_name:
                        type: string
                        nullable: true
                        description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                      oauth_client_sid:
                        type: string
                        nullable: true
                        description: The acting OAuth client (id_oc_*); null off the OAuth path.
                      reason:
                        type: string
                        nullable: true
                        description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                      permissions:
                        type: object
                        additionalProperties: {}
                        description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                      cluster_id:
                        type: integer
                        nullable: true
                        description: "Internal audit context: the cluster that served the write."
                      trace_id:
                        type: string
                        nullable: true
                        description: "Internal audit context: the trace id of the request that wrote the row."
                    required:
                      - actor_type
                      - actor_sid
                      - team_sid
                      - permissions
                    description: Who stored it.
                  deleted_by:
                    type: object
                    nullable: true
                    properties:
                      actor_type:
                        type: string
                        enum:
                          - user
                          - support
                          - api_key
                          - system
                          - agent
                      actor_sid:
                        type: string
                        nullable: true
                      team_sid:
                        type: string
                      actor_name:
                        type: string
                        nullable: true
                        description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                      oauth_client_sid:
                        type: string
                        nullable: true
                        description: The acting OAuth client (id_oc_*); null off the OAuth path.
                      reason:
                        type: string
                        nullable: true
                        description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                      permissions:
                        type: object
                        additionalProperties: {}
                        description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                      cluster_id:
                        type: integer
                        nullable: true
                        description: "Internal audit context: the cluster that served the write."
                      trace_id:
                        type: string
                        nullable: true
                        description: "Internal audit context: the trace id of the request that wrote the row."
                    required:
                      - actor_type
                      - actor_sid
                      - team_sid
                      - permissions
                    description: Who deleted it; null while live.
                  created_at:
                    type: string
                    description: ISO 8601 UTC.
                  updated_at:
                    type: string
                    description: ISO 8601 UTC.
                  deleted_at:
                    type: string
                    nullable: true
                    description: ISO 8601 UTC; the secret is scrubbed with it.
                required:
                  - sid
                  - team_sid
                  - name
                  - provider
                  - auth_type
                  - external_account_id
                  - status
                  - consecutive_failed_attempts
                  - last_failure_at
                  - created_by
                  - deleted_by
                  - created_at
                  - updated_at
                  - deleted_at
              included:
                type: object
                additionalProperties: {}
            required:
              - item
              - included
        pagination:
          type: object
          properties:
            next_cursor:
              type: string
              nullable: true
            has_more:
              type: boolean
            total_count:
              type: integer
              nullable: true
          required:
            - next_cursor
            - has_more
            - total_count
        applied_filters:
          type: object
          additionalProperties: {}
        includes:
          type: array
          items:
            type: string
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
        counts:
          type: object
          properties:
            total_count:
              type: number
              description: Connections matching the filter.
            groups:
              type: object
              additionalProperties: {}
              description: "provider and status: the count per value."
          required:
            - total_count
            - groups
      required:
        - success
        - operation
        - items
        - pagination
        - applied_filters
        - includes
        - meta
    SearchWebhookLogsRequest:
      type: object
      description: Request body of `search_webhook_logs`.
      properties:
        filter:
          type: object
          properties:
            sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: Delivery sid(s).
            webhook_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: One subscription's deliveries.
            account_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
                is_null:
                  type: boolean
              additionalProperties: false
              description: One sending identity; is_null true = team-wide events.
            source_service:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: playtables | unibox | signals | integrations.
            event_type:
              type: object
              properties:
                eq:
                  type: string
                ne:
                  type: string
                in:
                  type: array
                  items:
                    type: string
                nin:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: The event type.
            event_source_sid:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: The row that produced the event.
            status:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - pending
                    - in_progress
                    - retrying
                    - success
                    - failed
                    - cancelled
                ne:
                  type: string
                  enum:
                    - pending
                    - in_progress
                    - retrying
                    - success
                    - failed
                    - cancelled
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - pending
                      - in_progress
                      - retrying
                      - success
                      - failed
                      - cancelled
                nin:
                  type: array
                  items:
                    type: string
                    enum:
                      - pending
                      - in_progress
                      - retrying
                      - success
                      - failed
                      - cancelled
              additionalProperties: false
              description: in [pending, retrying] = still in flight.
            cancel_reason:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - manual
                    - webhook_deleted
                    - webhook_disabled
                    - webhook_failed
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - manual
                      - webhook_deleted
                      - webhook_disabled
                      - webhook_failed
                is_null:
                  type: boolean
              additionalProperties: false
              description: Why a row was cancelled.
            retry_count:
              type: object
              properties:
                eq:
                  type: number
                ne:
                  type: number
                gte:
                  type: number
                lte:
                  type: number
                gt:
                  type: number
                lt:
                  type: number
              additionalProperties: false
              description: Executed attempts.
            response_code:
              type: object
              properties:
                eq:
                  type: number
                ne:
                  type: number
                gte:
                  type: number
                lte:
                  type: number
                gt:
                  type: number
                lt:
                  type: number
                is_null:
                  type: boolean
              additionalProperties: false
              description: is_null true = no HTTP answer (network, timeout).
            duration_ms:
              type: object
              properties:
                eq:
                  type: number
                ne:
                  type: number
                gte:
                  type: number
                lte:
                  type: number
                gt:
                  type: number
                lt:
                  type: number
                is_null:
                  type: boolean
              additionalProperties: false
              description: The last attempt's latency.
            scheduled_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds.
            executed_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
                is_null:
                  type: boolean
              additionalProperties: false
              description: ISO 8601 bounds; is_null true = never attempted.
            created_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds.
          description: "Field filters, ANDed: {field: {eq | ne | in | nin | gte | lte | gt | lt | is_null}}; q inside it is free text. Omit for every row."
        include:
          type: array
          items:
            type: string
            enum:
              - webhook
          description: Relations to attach to every item; omit for the bare rows.
        sort:
          type: object
          properties:
            field:
              type: string
              enum:
                - created_at
                - scheduled_at
                - executed_at
                - duration_ms
              description: The column to order by.
            direction:
              type: string
              enum:
                - asc
                - desc
              description: asc or desc; default desc.
          required:
            - field
          description: One column and its direction; omit for the default order.
        page_size:
          type: integer
          minimum: 0
          maximum: 500
          description: 0..500, default 50; 0 = counts only, 1 = the first row.
        cursor:
          type: string
          nullable: true
          description: pagination.next_cursor of the previous page.
    SearchWebhookLogsResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - search
        items:
          type: array
          items:
            type: object
            properties:
              item:
                type: object
                properties:
                  sid:
                    type: string
                    description: Delivery sid (wh_lg_...).
                  team_sid:
                    type: string
                    description: The subscribing workspace (ts_tm_...).
                  webhook_sid:
                    type: string
                    description: The parent subscription (wh_hk_...).
                  account_sid:
                    type: string
                    nullable: true
                    description: The sending identity the subscription matched on (ub_sp_...); null on a team-wide event.
                  source_service:
                    type: string
                    nullable: true
                    description: Which service produced the event (playtables, unibox, signals, integrations); observability only.
                  event_type:
                    type: string
                    description: The event type (a WebhookEventTypeEnum value).
                  event_source_sid:
                    type: string
                    nullable: true
                    description: The row whose state change produced the event; null when none.
                  status:
                    type: string
                    enum:
                      - pending
                      - in_progress
                      - retrying
                      - success
                      - failed
                      - cancelled
                    description: pending or retrying = waiting for the tick; in_progress = leased by a worker; success; failed (the ladder ran out, or a 4xx); cancelled.
                  retry_count:
                    type: integer
                    description: Executed attempts; a manual re-arm does not move it.
                  cancel_reason:
                    type: string
                    nullable: true
                    enum:
                      - manual
                      - webhook_deleted
                      - webhook_disabled
                      - webhook_failed
                    description: manual, or the cascade of a deleted, disabled or failed webhook; null unless cancelled.
                  request_method:
                    type: string
                    enum:
                      - POST
                    description: POST.
                  request_url:
                    type: string
                    description: "The target URL at insert: a retry replays it."
                  request_headers:
                    type: object
                    additionalProperties:
                      type: string
                    description: The X-Webhook-* and X-Trace-Id headers as sent.
                  request_payload:
                    type: object
                    properties:
                      webhook_log_sid:
                        type: string
                        description: "This row's own sid: the receiver's dedup key."
                      type:
                        type: string
                        description: The event type (a WebhookEventTypeEnum value).
                      emitted_at:
                        type: string
                        description: ISO 8601 UTC of the state change.
                      team_sid:
                        type: string
                        description: The workspace (ts_tm_...).
                      trace_id:
                        type: string
                        description: The trace of the write that produced the event.
                      payload:
                        type: object
                        additionalProperties: {}
                        description: The event-specific payload.
                    required:
                      - webhook_log_sid
                      - type
                      - emitted_at
                      - team_sid
                      - trace_id
                      - payload
                    description: The stored envelope.
                  response_code:
                    type: integer
                    nullable: true
                    description: The receiver's status; null on a network error.
                  error_message:
                    type: string
                    nullable: true
                    description: The last attempt's error.
                  duration_ms:
                    type: integer
                    nullable: true
                    description: The last attempt's wall clock; null before one ran.
                  scheduled_at:
                    type: string
                    description: ISO 8601 UTC when the next (or last) attempt is due.
                  executed_at:
                    type: string
                    nullable: true
                    description: ISO 8601 UTC of the last attempt; null before one ran.
                  created_at:
                    type: string
                    description: ISO 8601 UTC.
                  updated_at:
                    type: string
                    description: ISO 8601 UTC.
                required:
                  - sid
                  - team_sid
                  - webhook_sid
                  - account_sid
                  - source_service
                  - event_type
                  - event_source_sid
                  - status
                  - retry_count
                  - cancel_reason
                  - request_method
                  - request_url
                  - request_headers
                  - request_payload
                  - response_code
                  - error_message
                  - duration_ms
                  - scheduled_at
                  - executed_at
                  - created_at
                  - updated_at
              included:
                type: object
                properties:
                  webhook:
                    type: object
                    additionalProperties: {}
                    description: The parent subscription (WebhookDomain, secret masked).
            required:
              - item
              - included
        pagination:
          type: object
          properties:
            next_cursor:
              type: string
              nullable: true
            has_more:
              type: boolean
            total_count:
              type: integer
              nullable: true
          required:
            - next_cursor
            - has_more
            - total_count
        applied_filters:
          type: object
          additionalProperties: {}
        includes:
          type: array
          items:
            type: string
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
        counts:
          type: object
          properties:
            total_count:
              type: number
              description: Deliveries matching the filter.
            groups:
              type: object
              additionalProperties: {}
              description: "status, event_type, response_code, webhook_sid, account_sid: the count per value."
          required:
            - total_count
            - groups
      required:
        - success
        - operation
        - items
        - pagination
        - applied_filters
        - includes
        - meta
    SearchWebhooksRequest:
      type: object
      description: Request body of `search_webhooks`.
      properties:
        filter:
          type: object
          properties:
            status:
              type: object
              properties:
                eq:
                  type: string
                  enum:
                    - "on"
                    - "off"
                    - failed
                in:
                  type: array
                  items:
                    type: string
                    enum:
                      - "on"
                      - "off"
                      - failed
              additionalProperties: false
              description: on | off | failed.
            events:
              type: object
              properties:
                eq:
                  type: string
                in:
                  type: array
                  items:
                    type: string
              additionalProperties: false
              description: "eq: the subscriptions to this event type; in: to any of these."
            name:
              type: object
              properties:
                eq:
                  type: string
              additionalProperties: false
              description: Exact name.
            q:
              type: string
              maxLength: 255
              description: Full text over name and target_url.
            consecutive_failed_attempts:
              type: object
              properties:
                eq:
                  type: number
                gte:
                  type: number
                lte:
                  type: number
                gt:
                  type: number
                lt:
                  type: number
              additionalProperties: false
              description: The close-to-failing axis (20 disables).
            last_failure_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds.
            created_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds.
            updated_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
                gt:
                  type: string
                lt:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds.
            deleted_at:
              type: object
              properties:
                gte:
                  type: string
                lte:
                  type: string
              additionalProperties: false
              description: ISO 8601 bounds (with deleted true).
            deleted:
              type: boolean
              description: true = include soft-deleted rows; default excludes them.
          description: "Field filters, ANDed: {field: {eq | ne | in | nin | gte | lte | gt | lt | is_null}}; q inside it is free text. Omit for every row."
        include:
          type: array
          items:
            type: string
            enum:
              - latest_webhook_logs
          description: Relations to attach to every item; omit for the bare rows.
        sort:
          type: object
          properties:
            field:
              type: string
              enum:
                - created_at
                - updated_at
                - name
              description: The column to order by.
            direction:
              type: string
              enum:
                - asc
                - desc
              description: asc or desc; default desc.
          required:
            - field
          description: One column and its direction; omit for the default order.
        page_size:
          type: integer
          minimum: 0
          maximum: 500
          description: 0..500, default 50; 0 = counts only, 1 = the first row.
        cursor:
          type: string
          nullable: true
          description: pagination.next_cursor of the previous page.
    SearchWebhooksResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - search
        items:
          type: array
          items:
            type: object
            properties:
              item:
                type: object
                properties:
                  sid:
                    type: string
                    description: Webhook sid (wh_hk_...).
                  team_sid:
                    type: string
                    description: The subscribing workspace (ts_tm_...).
                  name:
                    type: string
                    description: Free text, 1..255 chars.
                  target_url:
                    type: string
                    description: The https endpoint events are POSTed to; one subscription per team per URL.
                  events:
                    type: array
                    items:
                      type: string
                    description: The subscribed event types (WebhookEventTypeEnum values), exact membership.
                  filters:
                    type: object
                    nullable: true
                    properties:
                      account_sid:
                        type: string
                        nullable: true
                        minLength: 18
                        maxLength: 18
                        description: Deliver only the events of this sending identity (18 chars, e.g. a sender profile ub_sp_...); null = no narrowing.
                    description: The narrowing by sending identity; null or {} = every subscribed event.
                  secret:
                    type: string
                    nullable: true
                    description: "The 32-hex HMAC secret: in the create response only, null on every other read."
                  status:
                    type: string
                    enum:
                      - "on"
                      - "off"
                      - failed
                    description: "on; off (switched off by hand); failed (20 failed deliveries in a row or one 410: revive with update status on)."
                  consecutive_failed_attempts:
                    type: integer
                    description: Failed deliveries in a row, driven by the log; 20 trips the auto-disable.
                  last_failure_at:
                    type: string
                    nullable: true
                    description: ISO 8601 UTC of the most recent failed delivery.
                  created_by:
                    type: object
                    properties:
                      actor_type:
                        type: string
                        enum:
                          - user
                          - support
                          - api_key
                          - system
                          - agent
                      actor_sid:
                        type: string
                        nullable: true
                      team_sid:
                        type: string
                      actor_name:
                        type: string
                        nullable: true
                        description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                      oauth_client_sid:
                        type: string
                        nullable: true
                        description: The acting OAuth client (id_oc_*); null off the OAuth path.
                      reason:
                        type: string
                        nullable: true
                        description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                      permissions:
                        type: object
                        additionalProperties: {}
                        description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                      cluster_id:
                        type: integer
                        nullable: true
                        description: "Internal audit context: the cluster that served the write."
                      trace_id:
                        type: string
                        nullable: true
                        description: "Internal audit context: the trace id of the request that wrote the row."
                    required:
                      - actor_type
                      - actor_sid
                      - team_sid
                      - permissions
                    description: Who subscribed.
                  deleted_by:
                    type: object
                    nullable: true
                    properties:
                      actor_type:
                        type: string
                        enum:
                          - user
                          - support
                          - api_key
                          - system
                          - agent
                      actor_sid:
                        type: string
                        nullable: true
                      team_sid:
                        type: string
                      actor_name:
                        type: string
                        nullable: true
                        description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                      oauth_client_sid:
                        type: string
                        nullable: true
                        description: The acting OAuth client (id_oc_*); null off the OAuth path.
                      reason:
                        type: string
                        nullable: true
                        description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                      permissions:
                        type: object
                        additionalProperties: {}
                        description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                      cluster_id:
                        type: integer
                        nullable: true
                        description: "Internal audit context: the cluster that served the write."
                      trace_id:
                        type: string
                        nullable: true
                        description: "Internal audit context: the trace id of the request that wrote the row."
                    required:
                      - actor_type
                      - actor_sid
                      - team_sid
                      - permissions
                    description: Who deleted it; null while live.
                  created_at:
                    type: string
                    description: ISO 8601 UTC.
                  updated_at:
                    type: string
                    description: ISO 8601 UTC.
                  deleted_at:
                    type: string
                    nullable: true
                    description: ISO 8601 UTC; null = live.
                required:
                  - sid
                  - team_sid
                  - name
                  - target_url
                  - events
                  - filters
                  - status
                  - consecutive_failed_attempts
                  - last_failure_at
                  - created_by
                  - deleted_by
                  - created_at
                  - updated_at
                  - deleted_at
              included:
                type: object
                properties:
                  latest_webhook_logs:
                    type: array
                    items:
                      type: object
                      additionalProperties: {}
                    description: The most recent delivery rows (WebhookLogDomain) of the subscription.
            required:
              - item
              - included
        pagination:
          type: object
          properties:
            next_cursor:
              type: string
              nullable: true
            has_more:
              type: boolean
            total_count:
              type: integer
              nullable: true
          required:
            - next_cursor
            - has_more
            - total_count
        applied_filters:
          type: object
          additionalProperties: {}
        includes:
          type: array
          items:
            type: string
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
        counts:
          type: object
          properties:
            total_count:
              type: number
              description: Subscriptions matching the filter.
            groups:
              type: object
              additionalProperties: {}
              description: "status: the count per status."
          required:
            - total_count
            - groups
      required:
        - success
        - operation
        - items
        - pagination
        - applied_filters
        - includes
        - meta
    StartProviderConnectionOauthRequest:
      type: object
      description: Request body of `start_provider_connection_oauth`.
      properties:
        provider:
          type: string
          enum:
            - hubspot
          description: hubspot.
      required:
        - provider
    StartProviderConnectionOauthResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - action
        action:
          type: string
          description: kebab-case verb; matches the route segment.
        item: {}
        result:
          type: object
          properties:
            authorize_url:
              type: string
              description: The provider's consent screen, state embedded.
            state:
              type: string
              description: Hand it back verbatim at completion.
            expires_at:
              type: string
              description: ISO 8601 UTC when the leg lapses.
          required:
            - authorize_url
            - state
            - expires_at
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - action
        - item
        - result
        - meta
    TestCustomToolRequest:
      type: object
      description: Request body of `test_custom_tool`.
      properties:
        params:
          type: object
          additionalProperties:
            anyOf:
              - type: string
              - type: number
              - type: boolean
          description: The inputs by key, bound against input_schema (a missing required one fails the row).
    TestCustomToolResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - action
        action:
          type: string
          description: kebab-case verb; matches the route segment.
        item:
          type: object
          nullable: true
          properties:
            sid:
              type: string
              description: Custom tool sid (in_tl_...).
            team_sid:
              type: string
              description: The owning workspace (ts_tm_...).
            name:
              type: string
              description: Unique within the team among live rows; what the tool pickers show.
            description:
              type: string
              nullable: true
              description: Free text, up to 2000 chars.
            provider_connection_sid:
              type: string
              nullable: true
              description: The connection the tool authenticates with (in_cn_...); null = no auth.
            request:
              type: object
              properties:
                method:
                  type: string
                  enum:
                    - GET
                    - POST
                    - PUT
                    - PATCH
                    - DELETE
                  description: The HTTP method.
                url:
                  type: string
                  maxLength: 2048
                  pattern: ^https:\/\/
                  description: https URL; scheme and host literal (no placeholders, default port, public DNS), placeholders in the path and query only.
                headers:
                  type: object
                  additionalProperties:
                    type: string
                    maxLength: 1024
                  description: "Up to 20 headers; values may hold placeholders. Auth-shaped names (authorization, cookie, token, key...) and Content-Type are refused: auth comes from the connection."
                body:
                  type: object
                  nullable: true
                  additionalProperties: {}
                  description: A JSON template; null on GET and DELETE. String leaves may hold placeholders; a leaf that IS {{key}} renders with the input's native type.
              required:
                - method
                - url
              description: The request template.
            input_schema:
              type: array
              items:
                type: object
                properties:
                  key:
                    type: string
                    description: The placeholder name.
                  type:
                    type: string
                    description: string | number | boolean.
                  required:
                    type: boolean
                    description: Whether a call must bind it.
                required:
                  - key
                  - type
                  - required
              description: The declared inputs (up to 30).
            output_mapping:
              type: object
              additionalProperties:
                type: string
              description: name to dot-path into the response body (up to 20); {} = the raw body only.
            status:
              type: string
              enum:
                - "on"
                - "off"
              description: off = the executor refuses it with a failed row (custom_tool_disabled).
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who defined the tool.
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who deleted it; null while live.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
            deleted_at:
              type: string
              nullable: true
              description: ISO 8601 UTC; null = live.
          required:
            - sid
            - team_sid
            - name
            - description
            - provider_connection_sid
            - request
            - input_schema
            - output_mapping
            - status
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        result:
          type: object
          properties:
            status:
              type: string
              description: "success | failed: the execute outcome."
            output:
              type: object
              nullable: true
              additionalProperties: {}
              description: "{status, body (capped), extracted} of the real call; null on a failure before the call."
            error_code:
              type: string
              nullable: true
              enum:
                - auth_error
                - rate_limited
                - timeout
                - network_error
                - invalid_input
                - provider_error
                - not_found
              description: The executor's classified code; null on success.
            error_message:
              type: string
              nullable: true
              description: Opens with the branchable token on a tool-level failure (custom_tool_disabled, input_binding...).
            credits_charged:
              type: number
              description: Always 0 for http.request.
            cache_hit:
              type: boolean
              description: "Always false: http.request is never cached."
            provider_call_sid:
              type: string
              description: "The logged row (in_pc_...): get_provider_call reads the snapshots."
          required:
            - status
            - output
            - error_code
            - error_message
            - credits_charged
            - cache_hit
            - provider_call_sid
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - action
        - item
        - result
        - meta
    TestProviderConnectionResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - action
        action:
          type: string
          description: kebab-case verb; matches the route segment.
        item:
          type: object
          nullable: true
          properties:
            sid:
              type: string
              description: Connection sid (in_cn_...).
            team_sid:
              type: string
              description: The owning workspace (ts_tm_...).
            name:
              type: string
              description: Display name, unique within the team among live rows.
            provider:
              type: string
              enum:
                - openai
                - anthropic
                - google
                - deepseek
                - xai
                - voyage
                - cohere
                - hunter
                - findymail
                - anymailfinder
                - emaillistverify
                - custom
                - hubspot
                - serper
              description: custom (the team's own API) or hubspot (a CRM grant); immutable.
            auth_type:
              type: string
              enum:
                - api_key
                - bearer
                - basic
                - header
                - query
                - oauth
              description: The shape of the stored secret; oauth on a HubSpot grant.
            external_account_id:
              type: string
              nullable: true
              description: "The provider-side account of an OAuth grant (the HubSpot portal id): the reconnect key; null on key auth."
            status:
              type: string
              enum:
                - "on"
                - "off"
                - failed
              description: on; off (paused by hand); failed (auto-disabled after five auth failures in a row, revived by update or a reconnect).
            consecutive_failed_attempts:
              type: integer
              description: Auth-classified failures in a row; any non-cache success or a rotation resets it.
            last_failure_at:
              type: string
              nullable: true
              description: ISO 8601 UTC of the last auth failure.
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who stored it.
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who deleted it; null while live.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
            deleted_at:
              type: string
              nullable: true
              description: ISO 8601 UTC; the secret is scrubbed with it.
          required:
            - sid
            - team_sid
            - name
            - provider
            - auth_type
            - external_account_id
            - status
            - consecutive_failed_attempts
            - last_failure_at
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        result:
          type: object
          properties:
            ok:
              type: boolean
              description: true = the secret verified.
            http_code:
              type: integer
              nullable: true
              description: The provider's answer; null without a network call.
            error_kind:
              type: string
              description: none | auth | network | timeout | provider.
            duration_ms:
              type: integer
              description: Wall clock of the probe.
          required:
            - ok
            - http_code
            - error_kind
            - duration_ms
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - action
        - item
        - result
        - meta
    TestWebhookRequest:
      type: object
      description: Request body of `test_webhook`.
      properties:
        override_event_type:
          type: string
          description: Send the envelope under this event type instead of webhooks.test.
    TestWebhookResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - action
        action:
          type: string
          description: kebab-case verb; matches the route segment.
        item:
          type: object
          nullable: true
          properties:
            sid:
              type: string
              description: Webhook sid (wh_hk_...).
            team_sid:
              type: string
              description: The subscribing workspace (ts_tm_...).
            name:
              type: string
              description: Free text, 1..255 chars.
            target_url:
              type: string
              description: The https endpoint events are POSTed to; one subscription per team per URL.
            events:
              type: array
              items:
                type: string
              description: The subscribed event types (WebhookEventTypeEnum values), exact membership.
            filters:
              type: object
              nullable: true
              properties:
                account_sid:
                  type: string
                  nullable: true
                  minLength: 18
                  maxLength: 18
                  description: Deliver only the events of this sending identity (18 chars, e.g. a sender profile ub_sp_...); null = no narrowing.
              description: The narrowing by sending identity; null or {} = every subscribed event.
            secret:
              type: string
              nullable: true
              description: "The 32-hex HMAC secret: in the create response only, null on every other read."
            status:
              type: string
              enum:
                - "on"
                - "off"
                - failed
              description: "on; off (switched off by hand); failed (20 failed deliveries in a row or one 410: revive with update status on)."
            consecutive_failed_attempts:
              type: integer
              description: Failed deliveries in a row, driven by the log; 20 trips the auto-disable.
            last_failure_at:
              type: string
              nullable: true
              description: ISO 8601 UTC of the most recent failed delivery.
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who subscribed.
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who deleted it; null while live.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
            deleted_at:
              type: string
              nullable: true
              description: ISO 8601 UTC; null = live.
          required:
            - sid
            - team_sid
            - name
            - target_url
            - events
            - filters
            - status
            - consecutive_failed_attempts
            - last_failure_at
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        result:
          type: object
          properties:
            http_status:
              type: integer
              nullable: true
              description: The receiver's status; null when no answer came back.
            response_body:
              type: string
              nullable: true
              description: Not captured today (null).
            duration_ms:
              type: integer
              description: Wall clock of the attempt.
            error_kind:
              type: string
              description: "none (2xx or 3xx), http_error (400 and up), network (no answer: refused, timed out, dropped)."
            error_message:
              type: string
              nullable: true
              description: Not captured today (null).
          required:
            - http_status
            - response_body
            - duration_ms
            - error_kind
            - error_message
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - action
        - item
        - result
        - meta
    UpdateCustomToolRequest:
      type: object
      description: Request body of `update_custom_tool`.
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: New name, 1..255 chars.
        description:
          type: string
          nullable: true
          maxLength: 2000
          description: New description; null clears it.
        provider_connection_sid:
          type: string
          nullable: true
          minLength: 18
          maxLength: 18
          pattern: ^in_cn_
          description: A provider connection of provider custom this tool authenticates with (in_cn_...); null = a public API, no auth injected.
        request:
          type: object
          properties:
            method:
              type: string
              enum:
                - GET
                - POST
                - PUT
                - PATCH
                - DELETE
              description: The HTTP method.
            url:
              type: string
              maxLength: 2048
              pattern: ^https:\/\/
              description: https URL; scheme and host literal (no placeholders, default port, public DNS), placeholders in the path and query only.
            headers:
              type: object
              additionalProperties:
                type: string
                maxLength: 1024
              description: "Up to 20 headers; values may hold placeholders. Auth-shaped names (authorization, cookie, token, key...) and Content-Type are refused: auth comes from the connection."
            body:
              type: object
              nullable: true
              additionalProperties: {}
              description: A JSON template; null on GET and DELETE. String leaves may hold placeholders; a leaf that IS {{key}} renders with the input's native type.
          required:
            - method
            - url
          description: Replaces the whole template.
        input_schema:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
                maxLength: 64
                pattern: ^[a-z][a-z0-9_]*$
                description: "The placeholder name: lowercase, digits and underscores."
              type:
                type: string
                enum:
                  - string
                  - number
                  - boolean
                description: string | number | boolean.
              required:
                type: boolean
                description: "true: a call without it fails as invalid_input."
            required:
              - key
              - type
          maxItems: 30
          description: Replaces the whole input list.
        output_mapping:
          type: object
          additionalProperties:
            type: string
            maxLength: 255
          description: Replaces the whole mapping.
        status:
          type: string
          enum:
            - "on"
            - "off"
          description: on | off.
    UpdateCustomToolResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - update
        item:
          type: object
          properties:
            sid:
              type: string
              description: Custom tool sid (in_tl_...).
            team_sid:
              type: string
              description: The owning workspace (ts_tm_...).
            name:
              type: string
              description: Unique within the team among live rows; what the tool pickers show.
            description:
              type: string
              nullable: true
              description: Free text, up to 2000 chars.
            provider_connection_sid:
              type: string
              nullable: true
              description: The connection the tool authenticates with (in_cn_...); null = no auth.
            request:
              type: object
              properties:
                method:
                  type: string
                  enum:
                    - GET
                    - POST
                    - PUT
                    - PATCH
                    - DELETE
                  description: The HTTP method.
                url:
                  type: string
                  maxLength: 2048
                  pattern: ^https:\/\/
                  description: https URL; scheme and host literal (no placeholders, default port, public DNS), placeholders in the path and query only.
                headers:
                  type: object
                  additionalProperties:
                    type: string
                    maxLength: 1024
                  description: "Up to 20 headers; values may hold placeholders. Auth-shaped names (authorization, cookie, token, key...) and Content-Type are refused: auth comes from the connection."
                body:
                  type: object
                  nullable: true
                  additionalProperties: {}
                  description: A JSON template; null on GET and DELETE. String leaves may hold placeholders; a leaf that IS {{key}} renders with the input's native type.
              required:
                - method
                - url
              description: The request template.
            input_schema:
              type: array
              items:
                type: object
                properties:
                  key:
                    type: string
                    description: The placeholder name.
                  type:
                    type: string
                    description: string | number | boolean.
                  required:
                    type: boolean
                    description: Whether a call must bind it.
                required:
                  - key
                  - type
                  - required
              description: The declared inputs (up to 30).
            output_mapping:
              type: object
              additionalProperties:
                type: string
              description: name to dot-path into the response body (up to 20); {} = the raw body only.
            status:
              type: string
              enum:
                - "on"
                - "off"
              description: off = the executor refuses it with a failed row (custom_tool_disabled).
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who defined the tool.
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who deleted it; null while live.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
            deleted_at:
              type: string
              nullable: true
              description: ISO 8601 UTC; null = live.
          required:
            - sid
            - team_sid
            - name
            - description
            - provider_connection_sid
            - request
            - input_schema
            - output_mapping
            - status
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        updated_fields:
          type: array
          items:
            type: string
        previous_values:
          type: object
          additionalProperties: {}
        kept_fields:
          type: array
          items:
            type: string
          description: The fields this write did not change because the person's own value stands on them (stamped person); read the item for what landed.
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - item
        - updated_fields
        - previous_values
        - meta
    UpdateProviderConnectionRequest:
      type: object
      description: Request body of `update_provider_connection`.
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: New name, 1..255 chars.
        status:
          type: string
          enum:
            - "on"
            - "off"
          description: on | off; failed is never client-settable.
        auth_type:
          type: string
          nullable: true
          enum:
            - api_key
            - bearer
            - basic
            - header
            - query
          description: "With auth: the new secret's shape (the pair rotates together)."
        auth:
          type: object
          additionalProperties:
            type: string
            maxLength: 4096
          description: "WRITE-ONLY, never echoed: {key} for api_key or bearer, {username, password} for basic, {header_name, value} for header, {param_name, value} for query."
    UpdateProviderConnectionResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - update
        item:
          type: object
          properties:
            sid:
              type: string
              description: Connection sid (in_cn_...).
            team_sid:
              type: string
              description: The owning workspace (ts_tm_...).
            name:
              type: string
              description: Display name, unique within the team among live rows.
            provider:
              type: string
              enum:
                - openai
                - anthropic
                - google
                - deepseek
                - xai
                - voyage
                - cohere
                - hunter
                - findymail
                - anymailfinder
                - emaillistverify
                - custom
                - hubspot
                - serper
              description: custom (the team's own API) or hubspot (a CRM grant); immutable.
            auth_type:
              type: string
              enum:
                - api_key
                - bearer
                - basic
                - header
                - query
                - oauth
              description: The shape of the stored secret; oauth on a HubSpot grant.
            external_account_id:
              type: string
              nullable: true
              description: "The provider-side account of an OAuth grant (the HubSpot portal id): the reconnect key; null on key auth."
            status:
              type: string
              enum:
                - "on"
                - "off"
                - failed
              description: on; off (paused by hand); failed (auto-disabled after five auth failures in a row, revived by update or a reconnect).
            consecutive_failed_attempts:
              type: integer
              description: Auth-classified failures in a row; any non-cache success or a rotation resets it.
            last_failure_at:
              type: string
              nullable: true
              description: ISO 8601 UTC of the last auth failure.
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who stored it.
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who deleted it; null while live.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
            deleted_at:
              type: string
              nullable: true
              description: ISO 8601 UTC; the secret is scrubbed with it.
          required:
            - sid
            - team_sid
            - name
            - provider
            - auth_type
            - external_account_id
            - status
            - consecutive_failed_attempts
            - last_failure_at
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        updated_fields:
          type: array
          items:
            type: string
        previous_values:
          type: object
          additionalProperties: {}
        kept_fields:
          type: array
          items:
            type: string
          description: The fields this write did not change because the person's own value stands on them (stamped person); read the item for what landed.
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - item
        - updated_fields
        - previous_values
        - meta
    UpdateWebhookRequest:
      type: object
      description: Request body of `update_webhook`.
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: New name, 1..255 chars.
        target_url:
          type: string
          maxLength: 2048
          description: https only, a public host; unique per team.
        events:
          type: array
          items:
            type: string
            enum:
              - data-sources.completed
              - data-sources.failed
              - data-sources.paused
              - data-sources.deleted
              - playtable-runs.finished
              - playtable-runs.cancelled
              - workflows.published
              - workflow-records.entered
              - workflow-records.completed
              - workflow-records.failed
              - workflow-records.exited
              - workflow-records.paused
              - workflow-records.resumed
              - messages.sent
              - messages.received
              - messages.bounced
              - conversations.created
              - conversations.state-changed
              - conversations.scenario-changed
              - conversations.merged
              - conversations.person-linked
              - conversations.person-unlinked
              - conversations.signals-changed
              - tasks.created
              - tasks.completed
              - sender-profiles.created
              - sender-profiles.deleted
              - sender-profiles.health-changed
              - agents.mode-changed
              - signals.website-visited
              - website-sites.broken
              - website-sites.recovered
              - webhooks.failed
          minItems: 1
          description: FULL replacement of the subscribed types.
        filters:
          type: object
          properties:
            account_sid:
              type: string
              nullable: true
              minLength: 18
              maxLength: 18
              description: Deliver only the events of this sending identity (18 chars, e.g. a sender profile ub_sp_...); null = no narrowing.
          description: FULL replacement; {} or account_sid null clears the narrowing.
        status:
          type: string
          enum:
            - "on"
            - "off"
          description: on | off; failed is platform-set.
    UpdateWebhookResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        operation:
          type: string
          enum:
            - update
        item:
          type: object
          properties:
            sid:
              type: string
              description: Webhook sid (wh_hk_...).
            team_sid:
              type: string
              description: The subscribing workspace (ts_tm_...).
            name:
              type: string
              description: Free text, 1..255 chars.
            target_url:
              type: string
              description: The https endpoint events are POSTed to; one subscription per team per URL.
            events:
              type: array
              items:
                type: string
              description: The subscribed event types (WebhookEventTypeEnum values), exact membership.
            filters:
              type: object
              nullable: true
              properties:
                account_sid:
                  type: string
                  nullable: true
                  minLength: 18
                  maxLength: 18
                  description: Deliver only the events of this sending identity (18 chars, e.g. a sender profile ub_sp_...); null = no narrowing.
              description: The narrowing by sending identity; null or {} = every subscribed event.
            secret:
              type: string
              nullable: true
              description: "The 32-hex HMAC secret: in the create response only, null on every other read."
            status:
              type: string
              enum:
                - "on"
                - "off"
                - failed
              description: "on; off (switched off by hand); failed (20 failed deliveries in a row or one 410: revive with update status on)."
            consecutive_failed_attempts:
              type: integer
              description: Failed deliveries in a row, driven by the log; 20 trips the auto-disable.
            last_failure_at:
              type: string
              nullable: true
              description: ISO 8601 UTC of the most recent failed delivery.
            created_by:
              type: object
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who subscribed.
            deleted_by:
              type: object
              nullable: true
              properties:
                actor_type:
                  type: string
                  enum:
                    - user
                    - support
                    - api_key
                    - system
                    - agent
                actor_sid:
                  type: string
                  nullable: true
                team_sid:
                  type: string
                actor_name:
                  type: string
                  nullable: true
                  description: The OAuth client that acted ("Claude", "n8n"); null for a user, an API key or a system job.
                oauth_client_sid:
                  type: string
                  nullable: true
                  description: The acting OAuth client (id_oc_*); null off the OAuth path.
                reason:
                  type: string
                  nullable: true
                  description: Why a system actor wrote the row (snapshot_capture_job, ...); null otherwise.
                permissions:
                  type: object
                  additionalProperties: {}
                  description: "Internal audit context: the grant set the actor held at write time. Not a contract."
                cluster_id:
                  type: integer
                  nullable: true
                  description: "Internal audit context: the cluster that served the write."
                trace_id:
                  type: string
                  nullable: true
                  description: "Internal audit context: the trace id of the request that wrote the row."
              required:
                - actor_type
                - actor_sid
                - team_sid
                - permissions
              description: Who deleted it; null while live.
            created_at:
              type: string
              description: ISO 8601 UTC.
            updated_at:
              type: string
              description: ISO 8601 UTC.
            deleted_at:
              type: string
              nullable: true
              description: ISO 8601 UTC; null = live.
          required:
            - sid
            - team_sid
            - name
            - target_url
            - events
            - filters
            - status
            - consecutive_failed_attempts
            - last_failure_at
            - created_by
            - deleted_by
            - created_at
            - updated_at
            - deleted_at
        updated_fields:
          type: array
          items:
            type: string
        previous_values:
          type: object
          additionalProperties: {}
        kept_fields:
          type: array
          items:
            type: string
          description: The fields this write did not change because the person's own value stands on them (stamped person); read the item for what landed.
        meta:
          type: object
          properties:
            trace_id:
              type: string
              description: UUID v7; same 128-bit value as the X-Trace-Id header.
            span_id:
              type: string
              pattern: ^[0-9a-f]{16}$
              description: 16 hex chars, root span of this request.
            timestamp:
              type: string
              description: ISO 8601 UTC (Y-m-dTH:i:sZ), response time.
            duration_ms:
              type: integer
              minimum: 0
              description: Server-side wall clock.
            team_sid:
              type: string
              nullable: true
              description: The team this call ran in (the token team, or the team_sid override). Null when unauthenticated; absent from pre-2026-08-20 backends.
            actor_type:
              type: string
              nullable: true
              description: user | agent | api_key | system. Null when unauthenticated; absent from pre-2026-08-20 backends.
          required:
            - trace_id
            - span_id
            - timestamp
            - duration_ms
      required:
        - success
        - operation
        - item
        - updated_fields
        - previous_values
        - meta
