{
  "openapi": "3.1.0",
  "info": {
    "title": "Intuidy External API",
    "version": "1.0.0",
    "description": "Programmatic access to Intuidy workflows, ontology, and agents.\n\n## Authentication\nAll endpoints take a Bearer credential in the `Authorization` header:\n```\nAuthorization: Bearer vntg_your_api_key_here\n```\n\nTwo credentials are accepted, and both act as the key or grant they stand for:\n- an **AIPI key** (`vntg_…`), created from **Settings → AIPI Keys** in the Intuidy web interface;\n- an **OAuth 2.1 access token** (`vat_…`) that a client obtains when a user signs in from it\n  through `/oauth/authorize` (PKCE S256, public clients). The authorization server is described\n  at `{server_url}/.well-known/oauth-authorization-server`; the same token also opens `/mcp`.\n\nThe protected-resource metadata for this API is at\n`{server_url}/.well-known/oauth-protected-resource/api/v1` (RFC 9728, resource `{server_url}/api/v1`).\nA `401` for a refused OAuth token carries a `WWW-Authenticate: Bearer` challenge naming that\ndocument; a refused AIPI key gets a plain `401`. A database outage answers `503`, never `401`.\nA `403 INSUFFICIENT_SCOPE` on an OAuth token additionally carries a `WWW-Authenticate`\nstep-up challenge (`error=\"insufficient_scope\"`) listing the scopes the token holds plus the one\nthe route needs, so the client can re-authorize for the union. API keys get the plain `403`.\n\n## Scoping\nAPI keys have two access levels:\n- **User** (`scope_level: \"user\"`) — access the key creator's own workflows and every workflow in their company\n- **Admin** (`scope_level: \"client\"`) — access all workflows in the company\n\nA key reaches exactly what its owner reaches in the Intuidy web interface\n(sharing rules included): their own company for a member, and every\ncompany in the organization for an organization-level administrator,\nwhichever `scope_level` the key carries. A `client`-level key keeps its\ncompany-wide reach only while its owner holds an organization-level\nadministrator role. If the owner is demoted or moves company, the key\nbehaves as a `user`-level key from then on. It is not refused.\n\nCreating a `client`-level key requires an administrator role. API keys are\ncreated and managed **only from the Intuidy web interface** (Settings → API\nKeys): the `/keys` endpoints below are session-authenticated and are **not**\nreachable with a Bearer API key, so a key cannot mint or modify another key.\n\n## MCP Server\nThe same tenant is available to MCP clients (Claude, Codex, Cursor, …) as tools:\n- **Endpoint**: `{server_url}/mcp` — Streamable HTTP (JSON responses), stateless\n- **Auth**: `Authorization: Bearer <AIPI key>`; the key needs an `mcp` scope, or a\n  scope from one of these families: notebooks, dashboards, databases, knowledge,\n  integrations, users, approvals. Workflow, agent, template, ontology and policy\n  scopes alone do not connect. Tools are advertised per key: a missing tool means a\n  missing scope, and the `get_key_info` tool names what would reveal it.\n- **Discovery**: `{server_url}/.well-known/oauth-protected-resource/mcp` (RFC 9728);\n  an unauthenticated call answers `401` with a `WWW-Authenticate` challenge.\n- **OAuth**: the Bearer can also be an OAuth access token that an MCP client gets\n  when a user signs in from it (OAuth 2.1). The authorization server is described at\n  `{server_url}/.well-known/oauth-authorization-server`. The token acts as the key\n  its grant stands for.\n\nTools cover workflows (list, describe inputs, execute, runs, versions), agents,\nteams and skills, notebooks, dashboards, managed databases, the knowledge base,\nconnected services, ontology and glossary, governance, users, and HITL approvals.\n\n## Rate Limits\n- 600 requests per minute for a person's own credential (an OAuth sign-in or a user-scope key)\n- 240 requests per minute for any other key (company keys, connections bound to a key)\n- Every request counts, stream opens included; a refused request does not\n- Rate-limited responses return `429 Too Many Requests` with a `Retry-After` header (seconds)\n\n## Pagination\nList and data endpoints use 0-indexed pagination:\n- `page` — page number (default: 0)\n- `limit` — items per page (endpoint-specific defaults and maximums)\n- Response includes `total`, `page`, and `has_more` fields\n"
  },
  "servers": [
    {
      "url": "/api/v1",
      "description": "Intuidy API v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "An AIPI key (`vntg_…`) or an OAuth 2.1 access token (`vat_…`) obtained through `/oauth/authorize`; both act as the key or grant they stand for"
      }
    },
    "parameters": {
      "WriteOrigin": {
        "name": "X-Write-Origin",
        "in": "header",
        "required": false,
        "description": "Optional. An id for the page or client process that makes this board\nwrite, 8 to 64 characters of `A-Z a-z 0-9 _ -`; anything else is\nignored. It is echoed to every viewer of the board as `by.origin` on\nthe `dashboard.saved` event (GET /dashboards/{dashboardId}/events), so\na client that reads that stream can skip the reload its own write\ncaused. It is a client claim, never an authority check: it grants and\nrefuses nothing.\n",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{8,64}$"
        }
      }
    },
    "schemas": {
      "Share": {
        "type": "object",
        "description": "A resource's sharing, from the sharing hallway every door calls. For someone who cannot change it, only `resource`, `canChange: false` and `myGrant` (their own access) are meaningful and `targets` is empty. Content (dashboard, workflow, notebook, agent, skill) carries the levels `view` and `edit`; a company connection carries `use` and `manage`, with audience `company` or `restricted`.",
        "properties": {
          "resource": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "dashboard",
                  "workflow",
                  "notebook",
                  "agent",
                  "skill",
                  "connection"
                ]
              },
              "id": {
                "type": "integer"
              },
              "title": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "ownerUserId": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "ownerClientId": {
                "type": "integer"
              },
              "modified": {
                "type": "string",
                "format": "date-time",
                "description": "A notebook's last-saved time (notebooks only)"
              },
              "modifiedBefore": {
                "type": "string",
                "format": "date-time",
                "description": "PUT on a notebook that changed its audience: the saved time the write replaced, so an editor can keep its own baseline"
              }
            }
          },
          "canChange": {
            "type": "boolean"
          },
          "narrowingLevels": {
            "type": "boolean",
            "description": "false when a per-person view grant cannot narrow access — a dashboard or workflow already open to the whole company — so only edit is meaningful for same-company targets"
          },
          "audience": {
            "type": "string",
            "description": "The company audience — one of audienceOptions"
          },
          "audienceOptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "levels": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "view",
                "edit",
                "use",
                "manage"
              ]
            },
            "description": "view, edit — or, for a connection, use, manage"
          },
          "crossCompanyLevels": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "view",
                "edit",
                "use",
                "manage"
              ]
            },
            "description": "The only level a cross-company target can hold (view; use for a connection)"
          },
          "targets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "user",
                    "role",
                    "company"
                  ]
                },
                "id": {
                  "type": "integer"
                },
                "clientId": {
                  "type": "integer",
                  "description": "The target's company, read from the database"
                },
                "level": {
                  "type": "string",
                  "enum": [
                    "view",
                    "edit",
                    "use",
                    "manage"
                  ]
                },
                "label": {
                  "type": "string"
                },
                "email": {
                  "type": "string"
                },
                "companyName": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "crossCompany": {
                  "type": "boolean"
                },
                "live": {
                  "type": "boolean",
                  "description": "false when the two companies are no longer in one organization",
                  "or the person or role is gone": null
                },
                "inactiveReason": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "grantedBy": {
                  "type": "integer"
                },
                "grantedAt": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          },
          "ownerCompanyName": {
            "type": [
              "string",
              "null"
            ]
          },
          "crossCompanyEnabled": {
            "type": "boolean",
            "description": "Whether the caller's role in the owning company may share beyond it: any of share_in_other_companies, share_whole_other_companies, share_org_roles or share_organization"
          },
          "myGrant": {
            "type": "object",
            "description": "The caller's own grant, when they cannot change sharing",
            "properties": {
              "level": {
                "type": "string",
                "enum": [
                  "view",
                  "edit",
                  "use",
                  "manage"
                ]
              },
              "via": {
                "type": "string"
              }
            }
          },
          "skippedTeamMembers": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "PUT on an agent team: member agents the caller may not share"
          }
        }
      },
      "ShareCandidate": {
        "type": "object",
        "description": "A person or role that can be picked as a share target",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "user",
              "role"
            ]
          },
          "id": {
            "type": "integer"
          },
          "clientId": {
            "type": "integer"
          },
          "label": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "viaRoles": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Another company's person: the roles they hold"
          }
        }
      },
      "WorkflowSchedule": {
        "type": "object",
        "description": "A workflow's schedule as the platform holds it — derived from its Schedule Trigger node.",
        "properties": {
          "active": {
            "type": "boolean"
          },
          "scheduleType": {
            "type": "string",
            "enum": [
              "interval",
              "daily",
              "weekly",
              "monthly",
              "cron"
            ]
          },
          "cron": {
            "type": "string",
            "nullable": true,
            "description": "The expression the poller evaluates"
          },
          "timezone": {
            "type": "string"
          },
          "nextRunAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "lastRunAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "lastStatus": {
            "type": "string",
            "nullable": true
          },
          "consecutiveFailures": {
            "type": "integer"
          },
          "summary": {
            "type": "string",
            "description": "One line describing the schedule in words"
          }
        }
      },
      "WorkflowScheduleWrite": {
        "type": "object",
        "required": [
          "scheduleType"
        ],
        "properties": {
          "scheduleType": {
            "type": "string",
            "enum": [
              "interval",
              "daily",
              "weekly",
              "monthly",
              "cron"
            ]
          },
          "intervalMinutes": {
            "type": "integer",
            "minimum": 5,
            "description": "For interval. Minimum 5 minutes."
          },
          "timeOfDay": {
            "type": "string",
            "description": "For daily/weekly/monthly: HH:MM, 24-hour, in the timezone below"
          },
          "dayOfWeek": {
            "type": "string",
            "description": "For weekly: 0-6, Sunday is 0. Defaults to Monday."
          },
          "dayOfMonth": {
            "type": "string",
            "description": "For monthly: 1-31"
          },
          "cronExpression": {
            "type": "string",
            "description": "For cron: a 5-field expression"
          },
          "timezone": {
            "type": "string",
            "default": "UTC",
            "description": "IANA zone"
          },
          "active": {
            "type": "boolean",
            "default": true,
            "description": "false sets the schedule up without arming it"
          }
        }
      },
      "DashboardViewModifiers": {
        "type": "object",
        "description": "A dashboard view — how one viewer (or a default) reshapes a board's rows. Every key optional.",
        "properties": {
          "dateRange": {
            "type": "object",
            "properties": {
              "preset": {
                "type": "string",
                "description": "A date range preset (last_7_days, last_30_days, this_month, …) or custom"
              },
              "start": {
                "type": "string",
                "format": "date"
              },
              "end": {
                "type": "string",
                "format": "date"
              }
            }
          },
          "period": {
            "type": "string",
            "enum": [
              "day",
              "week",
              "month",
              "quarter"
            ]
          },
          "aggregation": {
            "type": "string",
            "enum": [
              "sum",
              "avg",
              "count",
              "min",
              "max"
            ]
          },
          "topN": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "compare": {
            "type": "string",
            "enum": [
              "none",
              "prior_period",
              "prior_year"
            ]
          },
          "filters": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "object",
              "required": [
                "column",
                "op"
              ],
              "properties": {
                "column": {
                  "type": "string"
                },
                "op": {
                  "type": "string",
                  "enum": [
                    "eq",
                    "neq",
                    "in",
                    "not_in",
                    "contains",
                    "gt",
                    "gte",
                    "lt",
                    "lte",
                    "between",
                    "any"
                  ]
                },
                "values": {
                  "type": "array",
                  "items": {}
                }
              }
            }
          }
        }
      },
      "DashboardCachePolicy": {
        "type": "object",
        "description": "How long a board or tile may reuse its rows. `live` runs the\nworkflows on every load and bills each one; `ttl` reuses them for\n`ttlMinutes`; `on-source-run` reuses them until the workflow runs\nagain — a schedule, a webhook, the API, the builder, or a board\nloading the same selection; `manual` reuses them until someone\nrefreshes. A TILE\nmay also say `board`, meaning it follows its board.\n",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "board",
              "live",
              "ttl",
              "on-source-run",
              "manual"
            ]
          },
          "ttlMinutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10080
          }
        },
        "required": [
          "mode"
        ]
      },
      "DashboardRefreshPolicy": {
        "type": "object",
        "description": "How often the board refreshes itself. 0 is off.",
        "properties": {
          "intervalMinutes": {
            "type": "integer",
            "enum": [
              0,
              1,
              5,
              15,
              60
            ]
          }
        },
        "required": [
          "intervalMinutes"
        ]
      },
      "DashboardAttributes": {
        "type": "object",
        "description": "What a board does and how it looks, as independent attributes, by part.\nA read answers every part and field, each at its value or its default.\nTwo attributes exclude each other only where they cannot work together;\na write that asks for such a pair is refused with the rule's code (409).\nGenerated from the attribute registry\n(lib/dashboard/attributes/attributesCore); a test holds this schema to it.\n",
        "additionalProperties": false,
        "properties": {
          "layout": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "tabLayouts": {
                "type": "string",
                "enum": [
                  "per-tab",
                  "grid",
                  "page"
                ],
                "default": "per-tab",
                "description": "Tab layouts. 'per-tab' lets each tab choose grid or HTML page; 'grid' or 'page' makes every tab, existing and new, use that layout. Enforced by the server, not only hidden."
              },
              "width": {
                "type": "string",
                "enum": [
                  "contained",
                  "full"
                ],
                "default": "contained",
                "description": "Grid width. 'contained' caps grid tabs at the page width; 'full' uses the whole screen (wall displays). HTML page tabs are always full-bleed."
              }
            }
          },
          "features": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "generative": {
                "type": "boolean",
                "default": false,
                "description": "Generated-content upkeep. Keeps tabs built from a description up to date: the headline band, scheduled rebuilds and the refine box. Turns on by itself after the first build; the tiles stay ordinary tiles either way. Enforced by the server, not only hidden."
              },
              "refineForViewers": {
                "type": "boolean",
                "default": true,
                "description": "Show the refine box to viewers. Whether viewers see the refine box under a generated tab. Editors always do. View mode only: an editor who is editing always sees the full board."
              }
            }
          },
          "freshness": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "viewerManualRefresh": {
                "type": "boolean",
                "default": true,
                "description": "Viewers can refresh. Shows the refresh button to viewers. When off, the server also refuses a forced refresh from someone who cannot edit the board. View mode only: an editor who is editing always sees the full board. Enforced by the server, not only hidden."
              },
              "viewerAutoRefresh": {
                "type": "boolean",
                "default": true,
                "description": "Viewers can change auto-refresh. Offers viewers their own auto-refresh interval. When off, the board's interval applies to everyone. View mode only: an editor who is editing always sees the full board. Enforced by the server, not only hidden."
              },
              "showAge": {
                "type": "boolean",
                "default": true,
                "description": "Show how old the data is. The \"2m ago\" stamp in the header. View mode only: an editor who is editing always sees the full board."
              }
            }
          },
          "viewer": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "title": {
                "type": "boolean",
                "default": true,
                "description": "Title. The board title in the header. View mode only: an editor who is editing always sees the full board."
              },
              "description": {
                "type": "boolean",
                "default": true,
                "description": "Description. The line under the title. View mode only: an editor who is editing always sees the full board."
              },
              "icon": {
                "type": "boolean",
                "default": true,
                "description": "Icon. The board icon in the header. View mode only: an editor who is editing always sees the full board."
              },
              "tags": {
                "type": "boolean",
                "default": true,
                "description": "Tags. The tag chips in the header. View mode only: an editor who is editing always sees the full board."
              },
              "menuBar": {
                "type": "boolean",
                "default": false,
                "description": "Menu bar. The File and View menus in view mode. Off by default: the ⋯ menu holds what viewers need. View mode only: an editor who is editing always sees the full board."
              },
              "tabStrip": {
                "type": "string",
                "enum": [
                  "auto",
                  "hidden"
                ],
                "default": "auto",
                "description": "Tab strip. 'auto' shows the tabs when there is more than one; 'hidden' never does (HTML pages can switch tabs through the bridge, and ?tab= links still work). View mode only: an editor who is editing always sees the full board."
              },
              "filterBar": {
                "type": "string",
                "enum": [
                  "on-request",
                  "always",
                  "hidden"
                ],
                "default": "on-request",
                "description": "Filter bar. 'on-request' shows the bar when a viewer turns it on or a filter is in use; 'always' always shows it; 'hidden' never draws it — link values, board defaults and the page's own variables still apply, and filters a viewer sets last until the next reload. View mode only: an editor who is editing always sees the full board."
              },
              "chatButton": {
                "type": "boolean",
                "default": true,
                "description": "Assistant button. The assistant button on the screen edge. Ctrl+/ still opens the assistant. View mode only: an editor who is editing always sees the full board."
              },
              "fullscreen": {
                "type": "string",
                "enum": [
                  "contained",
                  "immersive"
                ],
                "default": "contained",
                "description": "Fullscreen. 'contained' keeps the app sidebar; 'immersive' hides all app UI and asks the browser for fullscreen."
              },
              "fullscreenTheme": {
                "type": "string",
                "enum": [
                  "follow",
                  "light",
                  "dark"
                ],
                "default": "follow",
                "description": "Theme in fullscreen. The theme while the board is fullscreen; the app theme returns on exit."
              },
              "openFullscreen": {
                "type": "boolean",
                "default": false,
                "description": "Open in fullscreen. Opens the board straight into fullscreen (TV and kiosk screens). Esc still exits. View mode only: an editor who is editing always sees the full board."
              },
              "hideCursor": {
                "type": "boolean",
                "default": false,
                "description": "Hide the pointer when idle. In fullscreen, hides the pointer and the exit button after 3 s without movement. Needs \"Open in fullscreen\". View mode only: an editor who is editing always sees the full board."
              }
            }
          }
        }
      },
      "DashboardAttributesPatch": {
        "type": "object",
        "description": "A change to some of a board's attributes: only the fields named change,\nand a field sent as null returns to its default. An unknown part, field\nor value is refused naming it (400 INVALID_ATTRIBUTES); at least one\nfield must be named. The fields are those of DashboardAttributes.\nGenerated from the attribute registry\n(lib/dashboard/attributes/attributesCore); a test holds this schema to it.\n",
        "additionalProperties": false,
        "properties": {
          "layout": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "tabLayouts": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "per-tab",
                  "grid",
                  "page",
                  null
                ],
                "description": "Tab layouts. null returns it to \"per-tab\"."
              },
              "width": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "contained",
                  "full",
                  null
                ],
                "description": "Grid width. null returns it to \"contained\"."
              }
            }
          },
          "features": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "generative": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Generated-content upkeep. null returns it to false."
              },
              "refineForViewers": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Show the refine box to viewers. null returns it to true."
              }
            }
          },
          "freshness": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "viewerManualRefresh": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Viewers can refresh. null returns it to true."
              },
              "viewerAutoRefresh": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Viewers can change auto-refresh. null returns it to true."
              },
              "showAge": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Show how old the data is. null returns it to true."
              }
            }
          },
          "viewer": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "title": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Title. null returns it to true."
              },
              "description": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Description. null returns it to true."
              },
              "icon": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Icon. null returns it to true."
              },
              "tags": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Tags. null returns it to true."
              },
              "menuBar": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Menu bar. null returns it to false."
              },
              "tabStrip": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "auto",
                  "hidden",
                  null
                ],
                "description": "Tab strip. null returns it to \"auto\"."
              },
              "filterBar": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "on-request",
                  "always",
                  "hidden",
                  null
                ],
                "description": "Filter bar. null returns it to \"on-request\"."
              },
              "chatButton": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Assistant button. null returns it to true."
              },
              "fullscreen": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "contained",
                  "immersive",
                  null
                ],
                "description": "Fullscreen. null returns it to \"contained\"."
              },
              "fullscreenTheme": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "follow",
                  "light",
                  "dark",
                  null
                ],
                "description": "Theme in fullscreen. null returns it to \"follow\"."
              },
              "openFullscreen": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Open in fullscreen. null returns it to false."
              },
              "hideCursor": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Hide the pointer when idle. null returns it to false."
              }
            }
          }
        }
      },
      "DashboardAttributeWarning": {
        "type": "object",
        "description": "An allowed combination of attributes worth telling the user about —\nfor example viewers who can never see new data, or a hidden tab strip\non a board with several grid tabs. Nothing is refused.\n",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable code to branch on, such as FROZEN_DATA or TAB_STRIP_HIDDEN"
          },
          "key": {
            "type": "string",
            "description": "The attribute the note is about, as part.field"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "DashboardVariableDefinition": {
        "type": "object",
        "description": "A variable a board declares. Each viewer holds their own value of it\n(the view's `vars`); every tile's workflows read that value as\n`{{dash.<name>}}`, and an `inputs/variable` node reads it by name. A\nmulti-select binds one SQL placeholder per choice\n(`IN ({{dash.region}})`), and nothing chosen binds NULL. A `dateRange`\nnamed `period` reaches a run as `period_start` and `period_end`\n(whole days in the viewer's zone). `view_start` and `view_end` are\nreserved for the view's date window.\n",
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{0,39}$"
          },
          "type": {
            "type": "string",
            "enum": [
              "string",
              "number",
              "date",
              "dateRange",
              "multi"
            ]
          },
          "label": {
            "type": "string",
            "maxLength": 80
          },
          "description": {
            "type": "string",
            "maxLength": 300
          },
          "default": {
            "description": "Text, a number, a YYYY-MM-DD day, a list (multi), or a date range\n`{ start, end }` / `{ preset }`. Must be one of the options when\noptions are static.\n"
          },
          "options": {
            "type": "object",
            "description": "Where a selector's choices come from — only for string, number and\nmulti. `static` lists them (at most 500); `workflow` reads them\nfrom a workflow the board's company can run, which must not read\nthe variable it feeds (422 OPTIONS_WORKFLOW_READS_VARIABLE).\n",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "static",
                  "workflow"
                ]
              },
              "items": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "value": {},
                    "label": {
                      "type": "string"
                    }
                  }
                }
              },
              "workflowId": {
                "type": "integer"
              },
              "valueColumn": {
                "type": "string"
              },
              "labelColumn": {
                "type": "string"
              }
            },
            "required": [
              "kind"
            ]
          }
        },
        "required": [
          "name",
          "type"
        ]
      },
      "DashboardViewState": {
        "type": "object",
        "properties": {
          "v": {
            "type": "integer"
          },
          "dashboardId": {
            "type": "string"
          },
          "board": {
            "$ref": "#/components/schemas/DashboardViewModifiers"
          },
          "tiles": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/DashboardViewModifiers"
            }
          },
          "vars": {
            "type": "object",
            "additionalProperties": true,
            "description": "This viewer's choices for the board's variables, by name. Absent\nwhen nothing is chosen, so every variable takes its default. A NEW\nname the board does not declare is refused with 400 INVALID_VIEW.\nA declared name whose value the board no longer accepts (an option\nsince removed) is dropped from the saved view, not refused; a null\nis the board's default and is not stored.\n"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "DashboardSummary": {
        "type": "object",
        "description": "A dashboard row as the write doors return it.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "overview": {
            "type": "string",
            "nullable": true
          },
          "kind": {
            "type": "string",
            "enum": [
              "dashboard",
              "generative",
              "html"
            ],
            "description": "Kept for older readers, and derived from the board's attributes\nand tab layouts: `html` when every tab renders as an HTML page,\n`generative` when generated-content upkeep is on, otherwise\n`dashboard`. Change it by changing those\n(`PUT /dashboards/{dashboardId}/settings/attributes`, a tab's\n`layout`).\n"
          },
          "attributes": {
            "$ref": "#/components/schemas/DashboardAttributes"
          },
          "is_shared": {
            "type": "boolean"
          },
          "tile_count": {
            "type": "integer"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "modified": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DashboardTab": {
        "type": "object",
        "description": "One tab of a board. Tabs are an ordered list; a tile sits on one by\nits `config.tabId`, and a tile with no `tabId` belongs to the first.\n",
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable within the board; mint one by creating a tab, never by hand"
          },
          "name": {
            "type": "string",
            "maxLength": 60
          },
          "icon": {
            "type": "string",
            "description": "A lucide icon name, resolved when the tab is drawn (falls back to Layout)"
          },
          "layout": {
            "type": "string",
            "enum": [
              "grid",
              "page"
            ],
            "description": "The tab's own layout: `grid` (tiles on a grid) or `page` (one HTML\npage, full-bleed). Absent on a deleted tab.\n"
          },
          "effective_layout": {
            "type": "string",
            "enum": [
              "grid",
              "page"
            ],
            "description": "What the tab renders with: the board's `layout.tabLayouts` lock\nwhen it is `grid` or `page`, otherwise the tab's own `layout`.\nAbsent on a deleted tab.\n"
          },
          "index": {
            "type": "integer",
            "description": "0-based position in the strip"
          },
          "tile_count": {
            "type": "integer"
          },
          "url": {
            "type": "string",
            "description": "The tab's own link, a relative app path such as `/dashboard/12?tab=t3`. It always names the tab, also the first one, so it keeps its meaning after a reorder. Absent on a deleted tab."
          }
        }
      },
      "DashboardTabList": {
        "type": "object",
        "description": "A board's tabs in display order, and the tiles that sit on no tab.",
        "properties": {
          "dashboard_id": {
            "type": "integer"
          },
          "url": {
            "type": "string",
            "description": "The board's link, a relative app path such as `/dashboard/12`. Each tab's own link is its `url`."
          },
          "tab_layouts": {
            "type": "string",
            "enum": [
              "per-tab",
              "grid",
              "page"
            ],
            "description": "The board's `layout.tabLayouts` attribute: `per-tab` lets each tab choose; `grid` or `page` locks every tab to that layout."
          },
          "tabs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DashboardTab"
            }
          },
          "orphaned_tile_count": {
            "type": "integer",
            "description": "Tiles whose `config.tabId` names no existing tab. They render\nnowhere — the grid draws only the active tab's tiles — and are\nrecovered by moving them onto a tab.\n"
          },
          "orphaned_tile_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          }
        }
      },
      "HtmlPageBinding": {
        "type": "object",
        "description": "A workflow (or, under `refreshable`, a tile) a page names by LABEL.\nThe page's script passes the label; the id is read from here on the\nserver. A label is unique within its list, and defaults to the id.\n",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "label": {
            "type": "string",
            "maxLength": 64
          }
        }
      },
      "HtmlPageTileEntry": {
        "type": "object",
        "description": "One tile a page places: `{ id, label }` for a tile on the page's tab,\nor `{ label, create }` for a new one. The label is the name the\nmarkup's `<intuidy-tile tile=\"…\">` uses.\n",
        "properties": {
          "id": {
            "type": "integer"
          },
          "label": {
            "type": "string",
            "maxLength": 64
          },
          "create": {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "type": "string",
                "description": "A tile type, as in `get_tile_config_reference`. Not `htmlembed`."
              },
              "title": {
                "type": "string"
              },
              "config": {
                "type": "object",
                "description": "The tile's config, held to its tile contract."
              }
            }
          }
        }
      },
      "HtmlPage": {
        "type": "object",
        "description": "One page of an HTML dashboard: a tab holding exactly one HTML tile.\n`html` is present on a read of one page and on writes, and left out of\na list.\n",
        "properties": {
          "page_id": {
            "type": "string",
            "description": "The page's id (its tab's id)"
          },
          "name": {
            "type": "string",
            "description": "The name on the page's tab, and what `vantage.navigate` takes"
          },
          "icon": {
            "type": "string"
          },
          "tile_id": {
            "type": "integer",
            "nullable": true
          },
          "modified": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the page was last saved. Send it back as `expected_modified` on a change to be refused with STALE_TILE if the page was saved since."
          },
          "title": {
            "type": "string",
            "description": "The frame's accessible name. Not shown on the page."
          },
          "sources": {
            "type": "array",
            "description": "Workflows the page READS. They run when the board loads.",
            "items": {
              "$ref": "#/components/schemas/HtmlPageBinding"
            }
          },
          "actions": {
            "type": "array",
            "description": "Workflows the page may RUN (`vantage.runWorkflow(label)`).",
            "items": {
              "$ref": "#/components/schemas/HtmlPageBinding"
            }
          },
          "agents": {
            "type": "array",
            "description": "Agents the page may show a chat for. The markup places one with\n`<intuidy-agent agent=\"label\">`; the app draws the chat over that\nbox. It runs as the viewer and is read-only, and the page's script\ncan neither send it a message nor read its answers.\n",
            "items": {
              "$ref": "#/components/schemas/HtmlPageBinding"
            }
          },
          "refreshable": {
            "type": "array",
            "description": "Other tiles the page may reload.",
            "items": {
              "$ref": "#/components/schemas/HtmlPageBinding"
            }
          },
          "tiles": {
            "type": "array",
            "description": "Tiles the page PLACES. The markup leaves a box with\n`<intuidy-tile tile=\"label\">` and the app draws the real tile in\nit, with the board's data; the page's script hears the tile's\nevents and sends it commands through `vantage.tiles[label]`. Each\nis an ordinary tile on the page's own tab, edited with the tile\neditor.\n",
            "items": {
              "$ref": "#/components/schemas/HtmlPageBinding"
            }
          },
          "live_channel": {
            "type": "string",
            "description": "A name a workflow can push rows to. Empty for none."
          },
          "theme": {
            "type": "string",
            "enum": [
              "intuidy",
              "none"
            ]
          },
          "viewer": {
            "type": "boolean",
            "description": "Whether the page is told who is viewing it (`vantage.viewer`: id, email, first and last name) and its runs carry the same person as `viewer` on the trigger payload. Off by default."
          },
          "html_bytes": {
            "type": "integer"
          },
          "html": {
            "type": "string",
            "description": "The page body: markup with its style and script inline."
          },
          "url": {
            "type": "string",
            "description": "The page's own link, a relative app path such as `/dashboard/12?tab=t3`. It names the page's tab, also the first one. The answer's top-level `url` is the board's."
          }
        }
      },
      "HtmlPageChange": {
        "type": "object",
        "description": "The fields of a page a caller may set. Only the fields sent change; a\nlist that is sent REPLACES that list. An unknown field is refused.\n",
        "properties": {
          "html": {
            "type": "string",
            "description": "At most 1 MB."
          },
          "sources": {
            "type": "array",
            "maxItems": 12,
            "items": {
              "$ref": "#/components/schemas/HtmlPageBinding"
            }
          },
          "actions": {
            "type": "array",
            "maxItems": 24,
            "items": {
              "$ref": "#/components/schemas/HtmlPageBinding"
            }
          },
          "agents": {
            "type": "array",
            "maxItems": 6,
            "description": "Single agents only; a team is refused (AGENT_IS_A_TEAM).",
            "items": {
              "$ref": "#/components/schemas/HtmlPageBinding"
            }
          },
          "refreshable": {
            "type": "array",
            "maxItems": 24,
            "items": {
              "$ref": "#/components/schemas/HtmlPageBinding"
            }
          },
          "tiles": {
            "type": "array",
            "maxItems": 8,
            "description": "The tiles the page places, replacing the list. An entry names a\ntile already on the page's tab (`{ id, label }`), or asks for a new\none (`{ label, create: { type, title, config } }`), created in the\nsame write. A tile the list no longer names is deleted with the\nchange. A tile on another tab, or an HTML tile, is refused\n(TILE_NOT_ON_PAGE).\n",
            "items": {
              "$ref": "#/components/schemas/HtmlPageTileEntry"
            }
          },
          "live_channel": {
            "type": "string",
            "maxLength": 64
          },
          "theme": {
            "type": "string",
            "enum": [
              "intuidy",
              "none"
            ]
          },
          "title": {
            "type": "string"
          },
          "viewer": {
            "type": "boolean",
            "description": "true to tell the page who is viewing it and to stamp its runs with that person. The page's script can send what it holds anywhere, so a page must ask."
          }
        }
      },
      "HtmlPageList": {
        "type": "object",
        "description": "Every tab of an HTML dashboard, in order, and the pages among them.",
        "properties": {
          "dashboard_id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "description": "The board's link, a relative app path such as `/dashboard/12`."
          },
          "tabs": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "description": "The tab's own link, a relative app path such as `/dashboard/12?tab=t3`. It always names the tab."
                },
                "name": {
                  "type": "string"
                },
                "icon": {
                  "type": "string"
                },
                "index": {
                  "type": "integer"
                },
                "view": {
                  "type": "string",
                  "enum": [
                    "page",
                    "empty",
                    "grid"
                  ],
                  "description": "`page` — one HTML tile, rendered full width; `empty` — nothing on the tab yet; `grid` — other tiles, rendered as an ordinary grid."
                },
                "tile_count": {
                  "type": "integer"
                },
                "page": {
                  "$ref": "#/components/schemas/HtmlPage"
                }
              }
            }
          },
          "pages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HtmlPage"
            }
          },
          "reference": {
            "type": "string",
            "description": "With `reference=true`: the authoring reference, as markdown."
          }
        }
      },
      "Meta": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string",
            "description": "Unique request identifier"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "NotificationPreferences": {
        "type": "object",
        "description": "What one person chose not to be notified about.",
        "properties": {
          "disabledTypes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Notification types turned off, e.g. `agent_complete`. A type that cannot be turned off is never stored."
          },
          "mutedRuleIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Data rule ids whose \"blocked\" notices are muted. The first 500 ids of up to 120 characters are kept."
          }
        }
      },
      "Notification": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "user_id": {
            "type": "integer"
          },
          "organization_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "type": {
            "type": "string",
            "description": "The notification type, e.g. `approval_required`, `agent_complete`"
          },
          "title": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "severity": {
            "type": "string",
            "enum": [
              "info",
              "warning",
              "critical"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "unread",
              "read",
              "dismissed"
            ]
          },
          "metadata": {
            "type": [
              "object",
              "null"
            ],
            "description": "Writer-specific keys; `link` is the same-origin path the notification opens"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RecentView": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "dashboard",
              "workflow",
              "notebook",
              "agent"
            ]
          },
          "id": {
            "type": "integer"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "description": "When the caller last opened it, by the server's clock"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Machine-readable error code"
              },
              "message": {
                "type": "string",
                "description": "Human-readable error message"
              },
              "status": {
                "type": "integer",
                "description": "HTTP status code"
              }
            }
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        }
      },
      "BoardSavedMarker": {
        "type": "object",
        "description": "The last `dashboard.saved` event of one scope on a board.",
        "properties": {
          "rev": {
            "type": "integer",
            "description": "The event's rev on the board's stream"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "by": {
            "type": "object",
            "properties": {
              "userId": {
                "type": "integer",
                "nullable": true
              },
              "source": {
                "type": "string",
                "nullable": true
              },
              "origin": {
                "type": "string",
                "nullable": true,
                "description": "The writer's X-Write-Origin",
                "or null": null
              }
            }
          }
        }
      },
      "BoardHashChain": {
        "type": "object",
        "description": "The dashboard's `content_hash` before and after this write, both read\nunder the board's row lock in the write's own transaction. A caller\nwhose held `content_hash` equals `content_hash_before` may keep\n`content_hash` as its next `expected_hash`. When they differ, another\nwriter changed the board in between: read it again before the next\nguarded write. Present only on writes that change hashed content\n(tiles, a tab's tiles, the title or the overview).\n",
        "properties": {
          "content_hash_before": {
            "type": "string",
            "nullable": true
          },
          "content_hash": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "AgentSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "role_title": {
            "type": "string",
            "nullable": true
          },
          "bio": {
            "type": "string",
            "nullable": true
          },
          "icon": {
            "type": "string",
            "nullable": true
          },
          "color": {
            "type": "string",
            "nullable": true
          },
          "is_prebuilt": {
            "type": "boolean"
          },
          "is_shared": {
            "type": "boolean"
          },
          "is_active": {
            "type": "boolean"
          },
          "is_team": {
            "type": "boolean",
            "description": "Agent teams cannot be run over the API yet"
          },
          "is_own": {
            "type": "boolean",
            "description": "Created by the key's owner"
          },
          "skill_count": {
            "type": "integer"
          },
          "created": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "modified": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "AgentDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AgentSummary"
          },
          {
            "type": "object",
            "properties": {
              "skills": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "name": {
                      "type": "string"
                    },
                    "display_name": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    },
                    "category": {
                      "type": "string"
                    }
                  }
                }
              },
              "capabilities": {
                "type": "object",
                "properties": {
                  "internet_access": {
                    "type": "boolean"
                  },
                  "team": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "member_count": {
                        "type": "integer"
                      }
                    }
                  }
                }
              },
              "model": {
                "type": "object",
                "nullable": true,
                "description": "Per-agent model override, if set",
                "properties": {
                  "provider": {
                    "type": "string",
                    "nullable": true
                  },
                  "model": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        ]
      },
      "TeamSummary": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AgentSummary"
          },
          {
            "type": "object",
            "properties": {
              "member_count": {
                "type": "integer"
              }
            }
          }
        ]
      },
      "TeamDetail": {
        "description": "The summary plus `config.team` in a SHAPED form — members, strategy,\ntopology and the governance knobs — never the raw config: `vault`,\n`_history` and the orchestrator's unmodelled keys stay internal, same\nrationale as the solo agent door withholding raw config.\n",
        "allOf": [
          {
            "$ref": "#/components/schemas/TeamSummary"
          },
          {
            "type": "object",
            "properties": {
              "team": {
                "type": "object",
                "properties": {
                  "members": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "agent_id": {
                          "type": "integer",
                          "nullable": true
                        },
                        "role": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "strategy": {
                    "type": "string",
                    "enum": [
                      "parallel",
                      "sequential"
                    ]
                  },
                  "topology": {
                    "type": "object",
                    "properties": {
                      "nodes": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "nullable": true
                            },
                            "role": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "edges": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "from": {
                              "type": "string",
                              "nullable": true
                            },
                            "to": {
                              "type": "string",
                              "nullable": true
                            },
                            "handoff_mode": {
                              "type": "string"
                            },
                            "validation_rule": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  },
                  "auto_approve": {
                    "type": "boolean"
                  },
                  "max_revisions": {
                    "type": "integer"
                  },
                  "supervisor_agent_id": {
                    "type": "integer",
                    "nullable": true
                  },
                  "max_budget": {
                    "type": "number",
                    "nullable": true
                  },
                  "human_in_the_loop": {
                    "type": "boolean"
                  },
                  "clarity_gate": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        ]
      },
      "AgentJob": {
        "type": "object",
        "description": "A scheduled agent job (job_type 'scheduled'), or a run-history row when listed with ?type=run.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "agent_id": {
            "type": "integer"
          },
          "job_type": {
            "type": "string"
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "active": {
            "type": "boolean"
          },
          "schedule_type": {
            "type": "string",
            "nullable": true
          },
          "interval_minutes": {
            "type": "integer",
            "nullable": true
          },
          "time_of_day": {
            "type": "string",
            "nullable": true
          },
          "day_of_week": {
            "type": "integer",
            "nullable": true
          },
          "day_of_month": {
            "type": "integer",
            "nullable": true
          },
          "timezone": {
            "type": "string",
            "nullable": true
          },
          "cron_expression": {
            "type": "string",
            "nullable": true
          },
          "delivery_mode": {
            "type": "string",
            "nullable": true
          },
          "next_run_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "run_count": {
            "type": "integer"
          },
          "max_runs": {
            "type": "integer",
            "nullable": true
          },
          "consecutive_fails": {
            "type": "integer"
          },
          "last_error": {
            "type": "string",
            "nullable": true
          },
          "created": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "modified": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "AgentJobDetail": {
        "description": "The summary plus prompt, result, and a checkpoint summary — never raw accumulated_data (engine checkpoint state stays inside).",
        "allOf": [
          {
            "$ref": "#/components/schemas/AgentJob"
          },
          {
            "type": "object",
            "properties": {
              "prompt": {
                "type": "string",
                "nullable": true
              },
              "parent_id": {
                "type": "integer",
                "nullable": true
              },
              "duration_ms": {
                "type": "integer",
                "nullable": true
              },
              "final_result": {
                "nullable": true
              },
              "checkpoint": {
                "type": "object",
                "nullable": true
              }
            }
          }
        ]
      },
      "HeldAction": {
        "type": "object",
        "description": "The LIST view of a held action — args as a redacted per-key preview\nonly. The full raw args are deliberately reachable only through\nGET /approvals/actions/{actionId}, the informed-approval door.\n",
        "properties": {
          "id": {
            "type": "integer"
          },
          "tool": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "held",
              "releasing",
              "released",
              "rejected",
              "failed",
              "expired"
            ],
            "description": "`releasing` while an approved call runs"
          },
          "reason": {
            "type": "string",
            "nullable": true
          },
          "agent_id": {
            "type": "integer",
            "nullable": true
          },
          "user_id": {
            "type": "integer",
            "nullable": true
          },
          "destructive": {
            "type": "boolean"
          },
          "actor_type": {
            "type": "string",
            "nullable": true
          },
          "source_job_id": {
            "type": "integer",
            "nullable": true
          },
          "args_preview": {
            "type": "object",
            "description": "Key names with values truncated to 120 chars — a glimpse, not the call",
            "additionalProperties": {
              "type": "string"
            }
          },
          "args_sha256": {
            "type": "string",
            "nullable": true
          },
          "args_redacted": {
            "type": "boolean",
            "description": "Present and true when the hold belongs to another user and the viewer lacks `manage_ai_org_snippets`; `args_preview` is then empty"
          },
          "held_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "deadline": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "expired": {
            "type": "boolean"
          },
          "kind": {
            "type": "string",
            "enum": [
              "held",
              "chat",
              "dashboard"
            ],
            "description": "Where it was decided. `held` waited in the inbox; `chat` and `dashboard` were decided where they were raised and are listed already settled."
          },
          "has_reasoning": {
            "type": "boolean",
            "description": "Whether the agent gave a rationale with the call. The text is on the detail."
          },
          "decided_by": {
            "type": "integer",
            "nullable": true,
            "description": "The user who approved or rejected it"
          },
          "decided_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "decision_reason": {
            "type": "string",
            "nullable": true,
            "description": "The reviewer's note on the approval or rejection. Withheld (null) on another user's hold when `args_redacted` is true."
          },
          "edited": {
            "type": "boolean",
            "description": "Whether the reviewer approved it with edited arguments"
          },
          "changed_keys": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The top-level argument keys the reviewer changed"
          },
          "triage": {
            "type": "object",
            "nullable": true,
            "description": "How the settled decision was filed, or null when it has not been",
            "properties": {
              "bin": {
                "type": "string",
                "enum": [
                  "exception",
                  "reusable",
                  "system_gap"
                ]
              },
              "label": {
                "type": "string"
              },
              "note": {
                "type": "string"
              },
              "by": {
                "type": "integer",
                "nullable": true
              },
              "at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          }
        }
      },
      "DecisionLearning": {
        "type": "object",
        "description": "What a triage taught. Present on triage responses only.",
        "properties": {
          "lesson": {
            "type": "string",
            "nullable": true,
            "enum": [
              "written",
              "withdrawn",
              "skipped",
              "failed",
              null
            ],
            "description": "The lesson in the agent's memory. `skipped` when the decision cannot teach an agent (a dashboard action, no agent, expired, or an agent the person it ran for cannot use). `written` also when that agent's lessons are turned off in Knowledge; the summary then says the agent will not see it."
          },
          "fact": {
            "type": "string",
            "nullable": true,
            "enum": [
              "raised",
              "exists",
              "withdrawn",
              "kept",
              "skipped",
              "failed",
              null
            ],
            "description": "The pending fact in Learned knowledge. `skipped` when a system gap has neither a note nor a decision reason; `kept` when an earlier fact was already reviewed."
          },
          "summary": {
            "type": "string",
            "nullable": true,
            "description": "One sentence per effect, for the person who filed it"
          }
        }
      },
      "HeldActionDetail": {
        "description": "Everything in the list view PLUS the raw args and any settle result.",
        "allOf": [
          {
            "$ref": "#/components/schemas/HeldAction"
          },
          {
            "type": "object",
            "properties": {
              "args": {
                "type": "object",
                "description": "The held call's full arguments as PROPOSED — read them before you approve"
              },
              "reasoning": {
                "type": "string",
                "nullable": true,
                "description": "What the agent said when it made the call, when it said anything"
              },
              "edited_args": {
                "type": "object",
                "nullable": true,
                "description": "The arguments that ran, when the reviewer edited the proposal before approving"
              },
              "result": {
                "nullable": true,
                "description": "The settle result, present once released/rejected"
              }
            }
          }
        ]
      },
      "OrgUser": {
        "type": "object",
        "description": "A human user as the directory doors serve them. Password hashes and\nthe settings JSON are never selected in the hallway, so they cannot\nleak through this shape. Create/update responses omit `created` and\n`creditsUsed` (the web door's historical shape).\n",
        "properties": {
          "id": {
            "type": "integer"
          },
          "email": {
            "type": "string"
          },
          "first_name": {
            "type": "string",
            "nullable": true
          },
          "last_name": {
            "type": "string",
            "nullable": true
          },
          "client_id": {
            "type": "integer"
          },
          "client_name": {
            "type": "string"
          },
          "is_active": {
            "type": "boolean"
          },
          "default_dashboard": {
            "type": "integer",
            "nullable": true,
            "description": "The dashboard the user lands on",
            "or null.": null
          },
          "job_title": {
            "type": "string",
            "nullable": true
          },
          "department": {
            "type": "string",
            "nullable": true
          },
          "location": {
            "type": "string",
            "nullable": true
          },
          "bio": {
            "type": "string",
            "nullable": true
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "roles": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          },
          "creditsUsed": {
            "type": "number",
            "description": "Month-to-date credits (list door only)"
          }
        }
      },
      "OrgRole": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "context": {
            "type": "string",
            "nullable": true
          },
          "permissions": {
            "type": "object",
            "description": "{permissionId: boolean} — ids from GET /roles/permissions"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "modified": {
            "type": "string",
            "format": "date-time"
          },
          "userCount": {
            "type": "integer"
          },
          "clientId": {
            "type": "integer"
          },
          "isSystem": {
            "type": "boolean",
            "description": "System roles adopt every permission; their permission map is immutable and they cannot be deleted"
          },
          "creditBudget": {
            "type": "number",
            "nullable": true
          },
          "budgetPeriod": {
            "type": "string"
          },
          "overageAction": {
            "type": "string"
          }
        }
      },
      "AgentRunResult": {
        "type": "object",
        "properties": {
          "agent_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "null for the platform assistant"
          },
          "conversation_id": {
            "type": "integer",
            "description": "Present only when the run was a turn in a conversation. Send it back\non the next run to continue the thread.\n"
          },
          "success": {
            "type": "boolean"
          },
          "text": {
            "type": "string",
            "nullable": true,
            "description": "The agent's answer"
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "success": {
                  "type": "boolean"
                }
              }
            }
          },
          "usage": {
            "type": "object"
          },
          "duration_ms": {
            "type": "integer",
            "nullable": true
          },
          "iterations": {
            "type": "integer",
            "nullable": true
          },
          "error": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "AgentRunAccepted": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "integer"
          },
          "agent_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "null for the platform assistant"
          },
          "conversation_id": {
            "type": "integer",
            "description": "Present when the run was started into a conversation"
          },
          "status": {
            "type": "string",
            "enum": [
              "running"
            ]
          },
          "poll_url": {
            "type": "string",
            "description": "GET this path to poll the run, e.g. /api/v1/agents/runs/42"
          }
        }
      },
      "SkillSummary": {
        "type": "object",
        "description": "A skill as it appears in the catalogue — enough to decide whether to read it.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string",
            "description": "Slug identifier, e.g. \"invoice-triage\""
          },
          "display_name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "description": "What the skill does and when to use it — what a model matches a request against."
          },
          "category": {
            "type": "string"
          },
          "icon": {
            "type": "string"
          },
          "is_prebuilt": {
            "type": "boolean",
            "description": "Global skills shipped with Intuidy. Visible to every tenant, editable by none."
          },
          "owner_id": {
            "type": "integer",
            "nullable": true,
            "description": "The user who created it. Null for prebuilt skills."
          },
          "folder_id": {
            "type": "string",
            "nullable": true,
            "description": "The library folder it is filed in; null at the root. See `GET /skills/folders`."
          },
          "folder": {
            "type": "string",
            "description": "The folder's full path, e.g. \"Finance/Accounts payable\". Empty at the root."
          }
        }
      },
      "SkillFolder": {
        "type": "object",
        "description": "A folder in the skill library. Folders nest up to 8 levels.",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "parentId": {
            "type": "string",
            "nullable": true,
            "description": "The enclosing folder, or null at the root."
          },
          "path": {
            "type": "string",
            "description": "Full path from the root, e.g. \"Finance/Accounts payable\"."
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "AssetFolder": {
        "type": "object",
        "description": "A dashboard or workflow folder. Each type has two trees: `company`,\nshared with the whole company, and `personal`, the key owner's own.\nFolders nest up to 8 levels and never change tree. A folder never\nwidens access: a list only returns items the key's user could\nalready see.\n",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "parentId": {
            "type": "string",
            "nullable": true,
            "description": "The enclosing folder, or null at the root of its tree."
          },
          "tree": {
            "type": "string",
            "enum": [
              "company",
              "personal"
            ]
          },
          "path": {
            "type": "string",
            "description": "Full path from the root of its tree, e.g. \"Dev/QuickBooks\"."
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "SkillLink": {
        "type": "object",
        "description": "A relationship from one skill to another. `requires` makes the target\nload whenever this skill activates; `related` names the target inside\nthis skill's prompt block so an agent can pull it in mid-turn.\nA skill holds at most 25 links; a PATCH with more is refused with 422.\n",
        "properties": {
          "to": {
            "type": "integer",
            "description": "The target skill id"
          },
          "kind": {
            "type": "string",
            "enum": [
              "requires",
              "related"
            ]
          },
          "note": {
            "type": "string",
            "description": "Optional, up to 200 characters; shown to the agent beside the target's name."
          }
        }
      },
      "SkillSharing": {
        "type": "object",
        "description": "Who can see and edit a skill. The default (`company` / `edit`, no\nmembers) is what every skill had before sharing existed. `members` is\nnot stored: it is the skill's direct user grants from the sharing\nhallway (`/shares/skill/{id}`), read back as a map, and a PATCH that\nsends it is translated into user grants — the map replaces the owner\ncompany's per-person grants and leaves role, company and cross-company\ngrants alone. A direct grant overrides the company default for that\nperson. `members` is only returned to a caller who may change it (the\nowner, or a role with `manage_skills`), and names at most 200 users; a\nPATCH with more is refused with 422.\n",
        "properties": {
          "scope": {
            "type": "string",
            "enum": [
              "company",
              "private"
            ],
            "description": "`company` — everyone in the tenant can see it; `private` — only the owner and `members`."
          },
          "permission": {
            "type": "string",
            "enum": [
              "edit",
              "view"
            ],
            "description": "What the company audience may do (ignored for `private`)."
          },
          "members": {
            "type": "object",
            "maxProperties": 200,
            "additionalProperties": {
              "type": "string",
              "enum": [
                "editor",
                "viewer"
              ]
            },
            "description": "Per-user overrides keyed by user id, translated into direct user grants (`editor` → edit, `viewer` → view). At most 200 users."
          }
        }
      },
      "SkillDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SkillSummary"
          },
          {
            "type": "object",
            "properties": {
              "color": {
                "type": "string"
              },
              "instructions": {
                "type": "string",
                "description": "The guidance an agent follows once the skill is active. The body of SKILL.md."
              },
              "references": {
                "type": "array",
                "description": "Bundled level-3 material, read on demand rather than loaded up\nfront. An item with a `path` is a FILE the skill carries (a\nrules file, a script, a schema): it exports at exactly that\npath with its content untouched. An item without one is a\ndocument Intuidy files as `references/NN-title.md`.\n",
                "items": {
                  "type": "object",
                  "properties": {
                    "title": {
                      "type": "string"
                    },
                    "path": {
                      "type": "string",
                      "description": "Bundle-relative path, e.g. \"rules.md\" or \"scripts/lint.py\". Empty for a document."
                    },
                    "description": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string",
                      "description": "The document body. Empty for a reference that is only a link."
                    },
                    "url": {
                      "type": "string"
                    }
                  }
                }
              },
              "triggers": {
                "type": "array",
                "description": "Keywords that auto-activate the skill inside Intuidy. No meaning outside it.",
                "items": {
                  "type": "string"
                }
              },
              "tool_categories": {
                "type": "array",
                "description": "Intuidy tool families the instructions assume, e.g. workflow, integration.",
                "items": {
                  "type": "string"
                }
              },
              "created": {
                "type": "string",
                "format": "date-time"
              },
              "modified": {
                "type": "string",
                "format": "date-time"
              },
              "links": {
                "type": "array",
                "description": "Outgoing relationships, from the Skills library. Only targets the key's user may read are listed — the same rule the graph applies to its edges.",
                "items": {
                  "$ref": "#/components/schemas/SkillLink"
                }
              },
              "sharing": {
                "nullable": true,
                "description": "Null for prebuilt skills. `members` is present only for a caller who may change the sharing.",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/SkillSharing"
                  }
                ]
              },
              "access": {
                "type": "object",
                "description": "What the calling key's user may do with this skill.",
                "properties": {
                  "level": {
                    "type": "string",
                    "enum": [
                      "prebuilt",
                      "manager",
                      "owner",
                      "member",
                      "company"
                    ]
                  },
                  "canWrite": {
                    "type": "boolean"
                  },
                  "canShare": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        ]
      },
      "SkillWrite": {
        "type": "object",
        "description": "Create/update body. On PATCH every field is optional and omitting one\nleaves it unchanged; on POST `display_name` is required.\n",
        "properties": {
          "display_name": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "description": "Slug. Derived from display_name when omitted."
          },
          "description": {
            "type": "string"
          },
          "instructions": {
            "type": "string"
          },
          "references": {
            "type": "array",
            "description": "Documents and files. Give an item a `path` to carry it as a file at\nthat path (up to 256 KB each, 60 per skill, 1.5 MB in all; `..`,\nabsolute paths and duplicate paths are refused).\n",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "content": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                }
              }
            }
          },
          "triggers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tool_categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "icon": {
            "type": "string"
          },
          "color": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "folder_id": {
            "type": "string",
            "nullable": true,
            "description": "File the skill in this library folder; null or `root` moves it to the root. May be the only field sent on PATCH."
          },
          "links": {
            "type": "array",
            "description": "PATCH only. Replaces the skill's outgoing relationships as a set; send `[]` to clear them (null is refused with 422). Every target must be a skill the key's user can see. At most 25 entries; more is refused with 422.",
            "maxItems": 25,
            "items": {
              "$ref": "#/components/schemas/SkillLink"
            }
          },
          "sharing": {
            "description": "PATCH only. Owner or `manage_skills` only, and the key's user needs `share_skills`. A patch over the stored sharing — a field not sent keeps its value, so `{ members }` alone never widens a private skill. Every member id must be a user of this company (422 otherwise).",
            "allOf": [
              {
                "$ref": "#/components/schemas/SkillSharing"
              }
            ]
          }
        }
      },
      "ConversationSummary": {
        "type": "object",
        "properties": {
          "conversation_id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "message_count": {
            "type": "integer",
            "description": "Stored messages, counting both sides of every exchange"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "modified": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Conversation": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ConversationSummary"
          },
          {
            "type": "object",
            "properties": {
              "messages": {
                "type": "array",
                "description": "Oldest first, ready to render as a transcript",
                "items": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": "string",
                      "enum": [
                        "user",
                        "assistant"
                      ]
                    },
                    "content": {
                      "type": "string"
                    },
                    "tool_calls": {
                      "type": "array",
                      "description": "Present on assistant turns that used tools",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              },
              "project": {
                "type": "object",
                "nullable": true,
                "description": "The chat project the user filed this thread in, or null. A run\nthat continues a filed thread carries the project's\ninstructions and files in its prompt. Projects are the user's\nown sidebar shelves and are managed in the Intuidy web app only.\n",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        ]
      },
      "AgentRunStatus": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "integer"
          },
          "agent_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "null for the platform assistant"
          },
          "conversation_id": {
            "type": "integer",
            "nullable": true,
            "description": "Present when the run was a turn in a conversation"
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "completed",
              "failed",
              "hibernating"
            ],
            "description": "hibernating: a team mission paused for a person's input (resume it through /approvals/runs/{jobId})"
          },
          "text": {
            "type": "string",
            "nullable": true
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "success": {
                  "type": "boolean"
                }
              }
            }
          },
          "usage": {
            "type": "object"
          },
          "iterations": {
            "type": "integer",
            "nullable": true
          },
          "duration_ms": {
            "type": "integer",
            "nullable": true
          },
          "error": {
            "type": "string",
            "nullable": true
          },
          "created": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "modified": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "WorkflowSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "is_active": {
            "type": "boolean"
          },
          "node_count": {
            "type": "integer"
          },
          "folder_id": {
            "type": "string",
            "nullable": true,
            "description": "Folder in the company's shared tree (list only)"
          },
          "my_folder_id": {
            "type": "string",
            "nullable": true,
            "description": "Folder in the key owner's own tree (list only)"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "modified": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WorkflowDetail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "is_active": {
            "type": "boolean"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "modified": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "$ref": "#/components/schemas/WorkflowInputs"
          },
          "webhook": {
            "type": "object",
            "nullable": true,
            "description": "Where a sender posts, when the workflow has a webhook trigger; null when it has none. Secrets are never repeated here.\n",
            "properties": {
              "path": {
                "type": "string",
                "nullable": true,
                "description": "The inbound path. Null unless the key's company owns the workflow and the key may execute it."
              },
              "url": {
                "type": "string",
                "nullable": true
              },
              "method": {
                "type": "string",
                "enum": [
                  "POST"
                ],
                "description": "The method that runs the workflow"
              },
              "methods": {
                "type": "array",
                "description": "Every method the URL answers. Only POST runs the workflow; GET and HEAD are listed when a node selected a provider with a handshake, and answer that handshake and nothing else.\n",
                "items": {
                  "type": "string",
                  "enum": [
                    "POST",
                    "GET",
                    "HEAD"
                  ]
                }
              },
              "active": {
                "type": "boolean",
                "description": "False when the workflow is inactive or a webhook node is misconfigured"
              },
              "responseMode": {
                "type": "string",
                "enum": [
                  "async",
                  "sync"
                ]
              },
              "security": {
                "type": "object",
                "properties": {
                  "level": {
                    "type": "string",
                    "enum": [
                      "url-token",
                      "verified",
                      "misconfigured"
                    ]
                  },
                  "checks": {
                    "type": "array",
                    "description": "The checks a delivery must pass: `signature`, `token`, `ip`, `clientState`",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "handshake": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "microsoftGraph",
                  null
                ],
                "description": "The subscription validation this URL answers by itself, or null"
              },
              "provider": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "microsoftGraph",
                  "github",
                  "telegram",
                  null
                ],
                "description": "The sender preset a webhook node selects (`provider`), or null"
              },
              "dedupe": {
                "type": "boolean",
                "description": "True when a repeated delivery id is answered as a duplicate and not run: a node selects a provider that names a delivery id, or sets `dedupe.header` or `dedupe.path`\n"
              },
              "allowedOrigins": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "nodeCount": {
                "type": "integer"
              }
            }
          },
          "nodes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowNode"
            }
          },
          "edges": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowEdge"
            }
          }
        }
      },
      "WebhookDeliveryOutcome": {
        "type": "string",
        "description": "What became of a delivery",
        "enum": [
          "accepted",
          "handshake",
          "duplicate",
          "filtered",
          "lifecycle",
          "rejected",
          "refused",
          "rate_limited",
          "not_started",
          "error"
        ]
      },
      "WebhookDelivery": {
        "type": "object",
        "description": "One inbound webhook delivery to a workflow. Outcome facts only: never a body, a query string, an error message, or a signature, token or other secret header; the content type and the sender's delivery id are kept.\n",
        "properties": {
          "id": {
            "type": "string"
          },
          "receivedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "receiver": {
            "type": "string",
            "description": "Which door received it (`workflow` for the workflow URL, `microsoftGraph` for a managed trigger, `plaid`)"
          },
          "provider": {
            "type": "string",
            "nullable": true,
            "description": "The sender preset, when one applies"
          },
          "method": {
            "type": "string"
          },
          "outcome": {
            "$ref": "#/components/schemas/WebhookDeliveryOutcome"
          },
          "reason": {
            "type": "string",
            "nullable": true,
            "description": "Why, for an outcome that has reasons",
            "enum": [
              "trigger_filter",
              "no_changes",
              "baseline",
              "coalesced",
              "reauthorized",
              "marked_removed",
              "missed",
              "ip",
              "token",
              "signature",
              "client_state",
              "inactive",
              "misconfigured",
              "method",
              "too_large",
              "read_failed",
              "bad_body",
              "staging",
              "run_ceiling",
              "no_owner",
              "paused",
              "connection_restricted",
              "billing",
              null
            ]
          },
          "httpStatus": {
            "type": "integer"
          },
          "deliveryId": {
            "type": "string",
            "nullable": true,
            "description": "The sender's delivery id, only for a preset whose id is safe to show (GitHub, Telegram)"
          },
          "bodyBytes": {
            "type": "integer"
          },
          "contentType": {
            "type": "string",
            "nullable": true
          },
          "sourceIp": {
            "type": "string",
            "nullable": true,
            "description": "The sending address. In full for a key of the workflow's own company; for any other reader cut to its network (IPv4 /24 as a.b.c.0, IPv6 /48 as x:y:z::)."
          },
          "runId": {
            "type": "string",
            "nullable": true,
            "description": "The run this delivery started"
          },
          "durationMs": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "TriggerSubscriptionStatus": {
        "type": "object",
        "description": "The health of one managed Microsoft 365 trigger's subscription. Never the subscription secret, never a provider error message.\n",
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "microsoftGraph"
            ]
          },
          "resource": {
            "type": "string",
            "description": "The watched resource: `outlookMessage`, `outlookEvent`, `driveItem` or `teamsMessage`"
          },
          "target": {
            "type": "string",
            "description": "What the trigger watches, by name (mailbox and folder, calendar, drive, chat or channel)"
          },
          "state": {
            "type": "string",
            "enum": [
              "active",
              "expiring",
              "expired",
              "renewal_failing",
              "not_created"
            ]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "lastRenewedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "renewal": {
            "type": "object",
            "nullable": true,
            "properties": {
              "failures": {
                "type": "integer"
              },
              "lastFailedAt": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "nextAttemptAt": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "kind": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "auth",
                  "not_found",
                  "throttled",
                  "other",
                  null
                ]
              }
            }
          },
          "notCreated": {
            "type": "object",
            "nullable": true,
            "description": "Set when the last save could not create this subscription",
            "properties": {
              "at": {
                "type": "string",
                "format": "date-time"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "no_public_url",
                  "auth",
                  "not_found",
                  "throttled",
                  "unsupported",
                  "other"
                ]
              }
            }
          }
        }
      },
      "WorkflowInputs": {
        "type": "object",
        "description": "The execute contract, derived from the workflow's trigger nodes — the\nsame derivation the MCP `describe_workflow_inputs` tool serves, so both\ndoors state the same contract. Before this field, the only way a caller\ncould learn a workflow's parameters was to parse the full node graph,\nso agent clients routinely concluded a runnable endpoint \"takes no\ninput\" or invented field names.\n",
        "properties": {
          "accepts_form_data": {
            "type": "boolean",
            "description": "True when a form/webhook trigger reads `form_data` on the execute door"
          },
          "accepts_file_upload": {
            "type": "boolean",
            "description": "Present (and true) only when the workflow has a file/media upload\ninput node — feed it via POST /workflows/{workflowId}/upload, not\n`form_data`.\n"
          },
          "triggers": {
            "type": "array",
            "description": "One entry per input node",
            "items": {
              "type": "object",
              "properties": {
                "node_id": {
                  "type": "integer"
                },
                "node_type": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "method": {
                  "type": "string",
                  "description": "`upload` for file/media upload nodes; absent for form/webhook triggers"
                },
                "upload_path": {
                  "type": "string",
                  "description": "The v1 door that stages this node's files (upload nodes only)"
                },
                "routes_validation_errors": {
                  "type": "boolean",
                  "description": "Present (and true) only for a `triggers/formInput` node configured with `abortOnError: false`, which sends its own validation failures down a second output instead of failing the run. Its `required` fields are advisory: omitting one produces an error row the workflow handles, not a refusal, and the execute door does not check them.\n"
                },
                "fields": {
                  "type": "array",
                  "description": "Form-input fields (`triggers/formInput` only)",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "label": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string"
                      },
                      "required": {
                        "type": "boolean"
                      },
                      "minLength": {
                        "type": "integer"
                      },
                      "maxLength": {
                        "type": "integer"
                      },
                      "pattern": {
                        "type": "string"
                      },
                      "options": {
                        "type": "array",
                        "items": {}
                      }
                    }
                  }
                },
                "rootPath": {
                  "type": "string",
                  "description": "Webhook payload root (`triggers/webhook` only)"
                },
                "extractedFields": {
                  "type": "array",
                  "description": "Fields a webhook trigger extracts from its payload",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "WorkflowNode": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "node_type": {
            "type": "string"
          },
          "node_role": {
            "type": "string",
            "enum": [
              "getter",
              "setter",
              "terminator"
            ]
          },
          "label": {
            "type": "string",
            "nullable": true
          },
          "config": {
            "type": "object"
          }
        }
      },
      "WorkflowEdge": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "source_node_id": {
            "type": "integer"
          },
          "target_node_id": {
            "type": "integer"
          },
          "source_key": {
            "type": "string"
          },
          "target_key": {
            "type": "string"
          }
        }
      },
      "ExecutionResult": {
        "type": "object",
        "description": "One PAGE of a workflow result. `rows` holds this page only — compare `total_rows` against `page`/`limit`, or just follow `has_more`, before concluding you have the whole result.\n",
        "properties": {
          "result_id": {
            "type": "string",
            "description": "Opaque handle for fetching further pages via `GET /workflows/:workflowId/data/:result_id`. Absent for small results returned inline, which are always complete in one page.\n"
          },
          "rows": {
            "type": "array",
            "description": "The rows on this page",
            "items": {
              "type": "object"
            }
          },
          "total_rows": {
            "type": "integer",
            "description": "Rows in the FULL result, not on this page"
          },
          "schema": {
            "type": "object",
            "description": "Column name to type mapping",
            "additionalProperties": {
              "type": "string"
            }
          },
          "page": {
            "type": "integer",
            "description": "Zero-based index of this page"
          },
          "limit": {
            "type": "integer",
            "description": "Rows per page actually applied, after clamping to 1000"
          },
          "has_more": {
            "type": "boolean",
            "description": "Whether further pages exist. The one field a caller must check — an over-large `limit` is clamped silently, so a full-looking page is not proof the result ended.\n"
          },
          "cached": {
            "type": "boolean",
            "description": "Whether these rows came from a stored result rather than a run this call made. A caller that needs fresh data sets `skip_cache: true`; without this field there was no way to tell that it had been served an earlier run's answer.\n"
          },
          "next_page_url": {
            "type": "string",
            "description": "Present only when `has_more` is true"
          }
        }
      },
      "Page": {
        "type": "object",
        "properties": {
          "page": {
            "type": "integer",
            "description": "1-based page number, clamped into range"
          },
          "page_size": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "page_count": {
            "type": "integer"
          }
        }
      },
      "OntologyObjectRow": {
        "type": "object",
        "description": "Summary row for one object in the semantic layer.",
        "properties": {
          "key": {
            "type": "string",
            "description": "`<sourceType>:<sourceId>:<entity>`, e.g. `app::deals`, `managed-db:3:orders`",
            "example": "managed-db:3:orders"
          },
          "kind": {
            "type": "string",
            "example": "managed-db"
          },
          "label": {
            "type": "string"
          },
          "described": {
            "type": "boolean",
            "description": "Whether a business description has been written for it"
          },
          "description": {
            "type": "string"
          },
          "descriptionSource": {
            "type": "string",
            "enum": [
              "inferred",
              "integration",
              "chat",
              "user"
            ],
            "description": "Provenance rank. Higher ranks are never overwritten by lower ones."
          },
          "grain": {
            "type": "string",
            "description": "What ONE ROW represents"
          },
          "sensitivity": {
            "type": "string",
            "enum": [
              "public",
              "internal",
              "financial",
              "pii"
            ]
          },
          "classifications": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Governance tags; data rules match on these"
          },
          "hidden": {
            "type": "boolean"
          },
          "verified": {
            "type": "boolean"
          },
          "verificationStale": {
            "type": "boolean"
          },
          "orphaned": {
            "type": "boolean",
            "description": "Curated but its underlying source no longer exists"
          },
          "source": {
            "type": "string"
          },
          "linkCount": {
            "type": "integer"
          }
        }
      },
      "OntologyObject": {
        "type": "object",
        "description": "Full detail for one object — curated meaning merged over the live schema.",
        "properties": {
          "found": {
            "type": "boolean"
          },
          "key": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "grain": {
            "type": "string"
          },
          "primaryKey": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "alsoCalled": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sensitivity": {
            "type": "string",
            "enum": [
              "public",
              "internal",
              "financial",
              "pii"
            ]
          },
          "classifications": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "approxRows": {
            "type": "integer"
          },
          "joins": {
            "type": "array",
            "description": "Relationships to other objects",
            "items": {
              "type": "object",
              "properties": {
                "from": {
                  "type": "string"
                },
                "to": {
                  "type": "string"
                },
                "cardinality": {
                  "type": "string"
                },
                "confirmed": {
                  "type": "boolean",
                  "description": "True for foreign keys and human-drawn joins"
                }
              }
            }
          },
          "possibleJoins": {
            "type": "array",
            "description": "Guessed from column naming — verify before relying on them",
            "items": {
              "type": "object"
            }
          },
          "schemaFields": {
            "type": "object",
            "description": "Per-column type, meaning, sensitivity and value dictionary",
            "additionalProperties": {
              "type": "object"
            }
          },
          "glossaryTerms": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "GlossaryTerm": {
        "type": "object",
        "properties": {
          "term": {
            "type": "string"
          },
          "definition": {
            "type": "string",
            "nullable": true
          },
          "definitionSource": {
            "type": "string",
            "enum": [
              "inferred",
              "integration",
              "chat",
              "user"
            ]
          },
          "category": {
            "type": "string",
            "enum": [
              "metric",
              "entity",
              "process",
              "acronym"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "approved",
              "deprecated"
            ]
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "calculation": {
            "type": "string"
          },
          "relatedObjects": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "supersededBy": {
            "type": "string"
          },
          "hidden": {
            "type": "boolean"
          }
        }
      },
      "BusinessProfileDoc": {
        "type": "object",
        "description": "The stored profile document, with per-field provenance.",
        "properties": {
          "version": {
            "type": "integer"
          },
          "confirmedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When a person marked the profile reviewed, in the UI"
          },
          "confirmedBy": {
            "type": "integer",
            "nullable": true
          },
          "fields": {
            "type": "object",
            "description": "fieldKey → stored entry with provenance",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "value": {
                  "type": "string"
                },
                "source": {
                  "type": "string",
                  "enum": [
                    "inferred",
                    "signup",
                    "integration",
                    "chat",
                    "user"
                  ]
                },
                "updatedAt": {
                  "type": "string",
                  "format": "date-time",
                  "nullable": true
                },
                "updatedBy": {
                  "type": "integer",
                  "nullable": true
                }
              }
            }
          }
        }
      },
      "BusinessProfile": {
        "type": "object",
        "description": "The GET payload — the profile document plus the field registry and the fields still unknown.\n",
        "properties": {
          "profile": {
            "$ref": "#/components/schemas/BusinessProfileDoc"
          },
          "fieldRegistry": {
            "type": "array",
            "description": "Every field the profile can hold, with labels and hints",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "hint": {
                  "type": "string"
                },
                "multiline": {
                  "type": "boolean"
                }
              }
            }
          },
          "missingFields": {
            "type": "array",
            "description": "Fields with no value yet",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "hint": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "RegistryOpResult": {
        "type": "object",
        "properties": {
          "applied": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "skipped": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "op": {
                  "type": "string"
                },
                "target": {
                  "type": "string"
                },
                "reason": {
                  "type": "string"
                },
                "detail": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "PolicyRule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$",
            "example": "no_pii_to_ai"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "action": {
            "type": "string",
            "enum": [
              "redact",
              "require_approval",
              "block"
            ],
            "description": "When several rules match, the STRICTEST wins."
          },
          "channels": {
            "type": "array",
            "minItems": 1,
            "description": "A rule with no channels is invalid, not \"everywhere\".",
            "items": {
              "type": "string",
              "enum": [
                "ai",
                "external",
                "export",
                "internal"
              ]
            }
          },
          "match": {
            "type": "object",
            "properties": {
              "classifications": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "detectors": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "sensitivity": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "objectKeys": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "PolicyClassification": {
        "type": "object",
        "description": "A governance tag. Applied to objects/columns in the ontology; rules match on it.",
        "properties": {
          "label": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        }
      },
      "PolicyDetector": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "builtin",
              "keyword",
              "regex"
            ]
          },
          "pattern": {
            "type": "string",
            "writeOnly": true,
            "description": "Only returned with `include=patterns` AND the editor permission. A pattern states exactly which strings trip a block rule, so it is withheld from every other reader.\n"
          },
          "patternRedacted": {
            "type": "boolean",
            "readOnly": true,
            "description": "Present instead of `pattern` when the caller may not see it."
          },
          "keywords": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "PolicyVerdict": {
        "type": "object",
        "description": "The outcome of a dry run. Carries rule identifiers and counts, never matched values.",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "allow",
              "redact",
              "require_approval",
              "block"
            ]
          },
          "reason": {
            "type": "string"
          },
          "findings": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "ruleId": {
                  "type": "string"
                },
                "ruleName": {
                  "type": "string"
                },
                "action": {
                  "type": "string"
                },
                "via": {
                  "type": "string"
                },
                "detectorId": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                },
                "fields": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "redacted": {
            "type": "string",
            "nullable": true,
            "description": "The payload as a model would receive it, when the verdict is `redact`"
          },
          "scanned": {
            "type": "object",
            "properties": {
              "chars": {
                "type": "integer"
              },
              "truncated": {
                "type": "boolean"
              },
              "ms": {
                "type": "number"
              }
            }
          },
          "degraded": {
            "type": "boolean",
            "description": "The engine failed and fell back to the strict answer"
          },
          "evaluatedRules": {
            "type": "integer"
          },
          "brokenDetectors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "PolicyDecisionEvent": {
        "type": "object",
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "channel": {
            "type": "string",
            "enum": [
              "ai",
              "external",
              "export",
              "internal"
            ]
          },
          "action": {
            "type": "string",
            "enum": [
              "redact",
              "require_approval",
              "block"
            ]
          },
          "surface": {
            "type": "string"
          },
          "ruleIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "degraded": {
            "type": "boolean"
          }
        }
      }
    }
  },
  "paths": {
    "/workflows": {
      "get": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "summary": "List workflows",
        "description": "Returns a paginated list of workflows accessible to the API key.",
        "operationId": "listWorkflows",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            },
            "description": "Page number (0-indexed)"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 100
            },
            "description": "Items per page"
          },
          {
            "name": "folder_id",
            "in": "query",
            "description": "Only items filed directly in this folder (either tree; see the\nfolders endpoint). `root` returns the items not filed in the\ncompany's shared tree. An unknown folder is a 404.\n",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Workflow list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "workflows": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/WorkflowSummary"
                          }
                        },
                        "total": {
                          "type": "integer"
                        },
                        "page": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "summary": "Create a workflow",
        "description": "Creates a new empty workflow (no nodes or edges).",
        "operationId": "createWorkflow",
        "tags": [
          "Workflows"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title"
                ],
                "properties": {
                  "title": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "description": {
                    "type": "string",
                    "default": ""
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Workflow created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "title": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        },
                        "created": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/workflows/{workflowId}": {
      "parameters": [
        {
          "name": "workflowId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "summary": "Get workflow details",
        "description": "Returns workflow metadata and full node/edge graph.",
        "operationId": "getWorkflow",
        "tags": [
          "Workflows"
        ],
        "responses": {
          "200": {
            "description": "Workflow details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/WorkflowDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Workflow not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "summary": "Modify a workflow",
        "description": "Update the workflow's title, description or active status, or replace\nits whole graph. With `nodes`, the ENTIRE node and edge graph is\nreplaced and validated, the schedule is re-synced and the cached\nresult is invalidated; metadata in the same body is written in the\nsame transaction. Omit `nodes` for a metadata-only update.\n\nConflicts: send `expected_hash`, the `content_hash` from the last read\n(GET, or the previous write's answer). When the workflow changed since,\non any door, the write is refused with 409 `HASH_MISMATCH` and nothing\nis written. Both arms check it under the workflow's row lock, so the\ncheck and the write are one unit. The answer's `content_hash` is the\nbaseline for the next write. Omit `expected_hash` for\nlast-writer-wins; the replaced graph stays in version history.\n",
        "operationId": "updateWorkflow",
        "tags": [
          "Workflows"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "description": {
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "nodes": {
                    "type": "array",
                    "description": "Replaces the whole graph. Each node is `{ node_type, node_role, label?, config?, position? }`.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "node_type": {
                          "type": "string"
                        },
                        "node_role": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string"
                        },
                        "config": {
                          "type": "object",
                          "additionalProperties": true
                        },
                        "position": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  },
                  "edges": {
                    "type": "array",
                    "description": "With `nodes`: edges by node index, `{ source_node_index, target_node_index, source_key?, target_key? }`.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "source_node_index": {
                          "type": "integer"
                        },
                        "target_node_index": {
                          "type": "integer"
                        },
                        "source_key": {
                          "type": "string"
                        },
                        "target_key": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "expected_hash": {
                    "type": "string",
                    "description": "The `content_hash` from the last read. A workflow changed since is refused with 409 HASH_MISMATCH."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Workflow updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "title": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        },
                        "is_active": {
                          "type": "boolean"
                        },
                        "modified": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "content_hash": {
                          "type": "string",
                          "description": "Fingerprint of the workflow this write left, read inside the write's transaction. Pass it back as `expected_hash` on the next write.\n"
                        },
                        "node_count": {
                          "type": "integer",
                          "description": "With `nodes` only."
                        },
                        "edge_count": {
                          "type": "integer",
                          "description": "With `nodes` only."
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT (a malformed field, or an `expected_hash` that is not a string), or INVALID_GRAPH (the graph failed validation)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "FORBIDDEN — `nodes` or `is_active` was given for a workflow another company in the organization owns (only the owning company can replace its graph, pause it or re-activate it), or the workflow is narrowed to people this key's user is not among; SENSITIVE_ACCESS_DENIED — the graph reads data this key's user may not read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Workflow not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "HASH_MISMATCH — the workflow changed after the `expected_hash` read. Nothing was written; read it again and re-apply the change, or omit `expected_hash` to overwrite.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "summary": "Delete a workflow",
        "description": "Permanently deletes a workflow including all nodes, edges, and schedules.",
        "operationId": "deleteWorkflow",
        "tags": [
          "Workflows"
        ],
        "responses": {
          "204": {
            "description": "Workflow deleted"
          },
          "404": {
            "description": "Workflow not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/workflows/{workflowId}/execute": {
      "parameters": [
        {
          "name": "workflowId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "workflows:execute",
        "x-auth": "key",
        "summary": "Execute a workflow",
        "description": "Run a workflow and return results inline with schema and sample data.\nLarge datasets are handled in the same request: results above the size\nthreshold are stored server-side and returned as a `dataRefId` plus\npreview rows — fetch full rows via\n`GET /workflows/:workflowId/data/:dataRefId`.\n\n`mode: \"async\"` is no longer available (the background worker fleet was\ndecommissioned in August 2026) and is refused with an explicit\n`ASYNC_UNAVAILABLE` 400 rather than silently running sync.\n\nResults may contain multiple outputs if the workflow has multiple terminator nodes.\nUse the `outputs` map in the response to identify each output.\n\nPAGINATION. The response carries `total_rows` (the size of the full\nresult), `rows_returned`, `has_more` and `result_id`. `limit` defaults\nto 100 and is CLAMPED DOWN to 1000 rather than refused — a request for\n5000 returns 1000 rows with `has_more: true`, so a caller that sets a\nlarge limit and does not check `has_more` silently loses rows. Page\nthrough with `page: 0, 1, 2 …` until `has_more` is false, or fetch\npages directly from `result_id` via\n`GET /workflows/:workflowId/data/:result_id`; when there is a next page\nthe response also carries a ready-made `next_page_url`.\n",
        "operationId": "executeWorkflow",
        "tags": [
          "Workflows"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "sync",
                      "async"
                    ],
                    "default": "sync",
                    "description": "`async` is retained in the contract for older callers but always answers 400 `ASYNC_UNAVAILABLE`.\n"
                  },
                  "output_node_id": {
                    "type": "integer",
                    "description": "Select a specific terminator output node"
                  },
                  "skip_cache": {
                    "type": "boolean",
                    "default": false,
                    "description": "Bypass result cache and re-execute"
                  },
                  "form_data": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Input payload for a form or webhook trigger. A workflow that reads it caches its result per payload, so a second call with other values runs again and a later page of the same call does not.\n"
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Values for the workflow's variables, by name: every `{{dash.name}}` token in its nodes and every inputs/variable node reads them. Flat — text, a number, true/false, null, or a list of those (a list binds one SQL placeholder per item). A date range is two values, e.g. `period_start` and `period_end`. Results are cached per the values a workflow actually reads.\n"
                  },
                  "page": {
                    "type": "integer",
                    "default": 0,
                    "minimum": 0,
                    "description": "Zero-based page index. Advance while `has_more` is true."
                  },
                  "limit": {
                    "type": "integer",
                    "default": 100,
                    "maximum": 1000,
                    "description": "Rows per page. Values above 1000 are CLAMPED DOWN, not rejected — check `has_more` rather than assuming a large limit returned everything. Non-numeric values are refused.\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Execution result (sync mode)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ExecutionResult"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`ASYNC_UNAVAILABLE` (async mode requested), or the request is\nmalformed, or `INVALID_INPUT`.\n\n`INVALID_INPUT` also covers a `form_data` that omits a field the\nworkflow's form trigger declares REQUIRED. That used to reach you\nas a failed node part way through the run (422), which reads as the\nworkflow being broken; the door answers before the run now, and the\nerror object carries two extra fields so the call can be fixed\nwithout guessing: `missing_fields` (the field names) and\n`example_form_data` (a complete payload that satisfies the\ncontract — adapt the values). `GET /workflows/{workflowId}` returns\nthe same contract under `inputs` before you call at all.\n\nA form node configured with `abortOnError: false` routes its own\nvalidation failures to a second output instead of failing the run;\nits fields are never checked here, and the trigger entry in\n`inputs` marks it `routes_validation_errors: true`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Workflow not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/workflows/{workflowId}/upload": {
      "parameters": [
        {
          "name": "workflowId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "workflows:execute",
        "x-auth": "key",
        "summary": "Push files into an upload-triggered workflow",
        "description": "Stages files for a workflow whose input is a file/media upload node —\nthe workflows GET /workflows/{workflowId} advertises with\n`accepts_file_upload: true`. Until this door, the execute endpoint\ntook `form_data` but nothing could stage FILES, so those workflows\nonly ran from the web editor or a dashboard tile.\n\nSend either multipart/form-data (file parts named `files`, plus\noptional plain fields `execute` and `mode`) or JSON with base64 file\nbodies. Staged files live for one hour; both upload node types find\nthem.\n\nStaging alone is unmetered — the caller can hit the execute door\nthemselves. When `execute` is requested (or `mode` is set), the shared\nexecute hallway runs the workflow in the same request and enforces\nbilling, ownership, pagination and the export governance scan exactly\nas POST /workflows/{workflowId}/execute does; `skip_cache` defaults ON\nhere (still overridable) so fresh files are never answered by a cached\nrun. If the execute step fails, the error still carries the upload\nsummary — the files ARE staged, so fix the problem and hit the execute\ndoor without re-sending the bytes.\n",
        "operationId": "uploadWorkflowFiles",
        "tags": [
          "Workflows"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "files": {
                    "type": "array",
                    "description": "One or more file parts (part name `files` or `file`)",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    }
                  },
                  "execute": {
                    "type": "string",
                    "description": "`true`/`1`/`yes` to run the workflow after staging"
                  },
                  "mode": {
                    "type": "string",
                    "description": "`sync` — implies execute"
                  }
                }
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "description": "Send `files`, or the `upload_id` of an upload staged earlier (staged files last one hour).",
                "properties": {
                  "upload_id": {
                    "type": "string",
                    "description": "Run an upload staged earlier instead of sending files again. 404 when it expired or belongs to another workflow."
                  },
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "name",
                        "base64"
                      ],
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "mimeType": {
                          "type": "string"
                        },
                        "base64": {
                          "type": "string"
                        },
                        "size": {
                          "type": "integer"
                        }
                      }
                    }
                  },
                  "execute": {
                    "type": "boolean"
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "sync"
                    ]
                  },
                  "output_node_id": {
                    "type": "integer"
                  },
                  "skip_cache": {
                    "type": "boolean",
                    "description": "Defaults to true on this door — fresh files must not hit the result cache"
                  },
                  "form_data": {
                    "type": "object",
                    "description": "Passed through to the execute hallway untouched"
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Values for the workflow's variables, as the execute door takes them"
                  },
                  "connections": {
                    "type": "object"
                  },
                  "page": {
                    "type": "integer"
                  },
                  "limit": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Files staged (and the execution result when `execute` was requested)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "workflow_id": {
                          "type": "integer"
                        },
                        "upload": {
                          "type": "object",
                          "properties": {
                            "upload_id": {
                              "type": "string"
                            },
                            "upload_key": {
                              "type": "string"
                            },
                            "file_count": {
                              "type": "integer"
                            },
                            "files": {
                              "type": "array",
                              "items": {
                                "type": "object"
                              }
                            },
                            "expires_in_seconds": {
                              "type": "integer",
                              "nullable": true,
                              "description": "Seconds left before the staged files expire (the full hour for new files, the remainder for an upload_id); null when unknown."
                            }
                          }
                        },
                        "executed": {
                          "type": "boolean"
                        },
                        "execution": {
                          "$ref": "#/components/schemas/ExecutionResult"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, no files, or the execute step refused the request"
          },
          "402": {
            "description": "Insufficient credits (execute step)"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `workflows:execute`"
          },
          "404": {
            "description": "Workflow not found"
          },
          "413": {
            "description": "Files over the upload cap. The answer carries `Connection: close`; open a new connection for the next request."
          }
        }
      }
    },
    "/workflows/{workflowId}/data/{dataRefId}": {
      "parameters": [
        {
          "name": "workflowId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "dataRefId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "Data reference ID from execution result (with or without `dataRef:` prefix)"
        }
      ],
      "get": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "summary": "Get paginated execution results",
        "description": "Retrieve rows from a workflow execution result. Results are stored temporarily\nin Redis with a TTL (typically 1 hour). If the data has expired, re-execute\nthe workflow.\n",
        "operationId": "getExecutionData",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            },
            "description": "Page number (0-indexed)"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 100,
              "maximum": 1000
            },
            "description": "Rows per page"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "total": {
                          "type": "integer"
                        },
                        "page": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Data expired or not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/workflows/{workflowId}/validate": {
      "parameters": [
        {
          "name": "workflowId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "summary": "Validate workflow graph",
        "description": "Checks that the workflow graph is structurally valid without executing it.\nReturns errors and warnings for issues like missing terminators, orphan nodes,\ninvalid edges, self-loops, and unreachable terminators. `NO_GETTER` means the\ngraph has no data source: an `inputs/*` or `triggers/*` node, or a getter\nwith no input port. A getter that only filters the rows it is given (such\nas `messaging/messageSearch`) is not a source.\n",
        "operationId": "validateWorkflow",
        "tags": [
          "Workflows"
        ],
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "node_count": {
                          "type": "integer"
                        },
                        "edge_count": {
                          "type": "integer"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "code": {
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "code": {
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "node_id": {
                                "type": "integer"
                              }
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Workflow not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/node-types": {
      "get": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "summary": "List available node types",
        "description": "Returns the workflow node types the key's company can see (platform node\ntypes plus the company's own) and their categories. Use this to discover\nwhat nodes can be added to workflows and how to configure them.\n\nEach node type carries two roles. `node_role` is the role the workflow\nbuilder's palette gives the node. `config_reference.role` is the role to\nsend as `node_role` when a workflow is saved through the API. A workflow\nneeds at least one data source and one `terminator`. A data source is an\n`inputs/*` or `triggers/*` node, or a `getter` with no input port.\n\n`config_reference` is the config description to build from. It is the same\nreference the MCP `list_node_types` tool returns. `config_schema` is the\nbuilder's form schema and can list fewer keys.\n\nTool names in `credential_note`, `required`, `optional` and `note` are MCP\ntool names. REST equivalents: `list_managed_databases` is `GET /databases`;\n`list_integrations` and the \"Your Connected Services\" list are\n`GET /integrations/query`; `evaluate_expression` is\n`POST /expressions/evaluate`.\n\nThe response also includes MCP server connection info for interactive workflow building.\n",
        "operationId": "listNodeTypes",
        "tags": [
          "Node Types"
        ],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by category name (case-insensitive)"
          },
          {
            "name": "role",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "getter",
                "setter",
                "terminator"
              ]
            },
            "description": "Filter on the top-level node_role, the role the builder palette gives the node"
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "Text search, ignoring case. Matches the node type, the description, config key names and the note. An exact node type is listed first, then node types that contain the text, then other matches. Text past 200 characters is ignored."
          }
        ],
        "responses": {
          "200": {
            "description": "Node type catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "categories": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "integer"
                              },
                              "name": {
                                "type": "string"
                              },
                              "node_count": {
                                "type": "integer"
                              }
                            }
                          }
                        },
                        "node_types": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "node_type": {
                                "type": "string",
                                "description": "Identifier used in workflow graph (e.g. \"queryoperators/filter\")"
                              },
                              "category": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "node_role": {
                                "type": "string",
                                "enum": [
                                  "getter",
                                  "setter",
                                  "terminator"
                                ]
                              },
                              "description": {
                                "type": "string"
                              },
                              "inputs": {
                                "type": "integer"
                              },
                              "outputs": {
                                "type": "integer"
                              },
                              "requires_credential": {
                                "type": "boolean"
                              },
                              "config_schema": {
                                "type": "object",
                                "nullable": true,
                                "description": "The workflow builder's form schema for this node type. It can list fewer keys than the node reads; config_reference is the complete description."
                              },
                              "config_reference": {
                                "type": "object",
                                "description": "How to configure this node type. The same reference MCP list_node_types returns. Tool names in its text are MCP tool names (see the operation description for REST equivalents).",
                                "properties": {
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "registry",
                                      "catalog"
                                    ],
                                    "description": "registry: a curated reference. catalog: derived from the builder form schema; keys can be missing."
                                  },
                                  "description": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "role": {
                                    "type": "string",
                                    "enum": [
                                      "getter",
                                      "setter",
                                      "terminator"
                                    ],
                                    "description": "The role to send as node_role when a workflow is saved through the API. A workflow needs at least one getter and one terminator."
                                  },
                                  "writes": {
                                    "type": "boolean",
                                    "description": "Whether the node writes to an outside system. Curated references only."
                                  },
                                  "service_key": {
                                    "type": "string",
                                    "description": "The connected service the node needs, when it needs one"
                                  },
                                  "service_keys": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    },
                                    "description": "Several services, any one of which satisfies the node. Present only when there are two or more."
                                  },
                                  "credential_note": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "How to choose the credentialId for this node"
                                  },
                                  "required": {
                                    "type": "object",
                                    "additionalProperties": {
                                      "type": "string"
                                    },
                                    "description": "Required config keys and what each holds"
                                  },
                                  "optional": {
                                    "type": "object",
                                    "additionalProperties": {
                                      "type": "string"
                                    },
                                    "description": "Optional config keys and what each holds"
                                  },
                                  "note": {
                                    "type": "string"
                                  },
                                  "example": {
                                    "type": "object",
                                    "description": "An example config. Connection ids (credentialId, databaseId) are left out; take them from GET /databases or GET /integrations/query."
                                  }
                                }
                              }
                            }
                          }
                        },
                        "total": {
                          "type": "integer"
                        },
                        "mcp": {
                          "type": "object",
                          "description": "How to reach the AIPI MCP server (same tenant, as tools)",
                          "properties": {
                            "description": {
                              "type": "string"
                            },
                            "url": {
                              "type": "string",
                              "description": "Streamable HTTP endpoint, e.g. https://host/mcp"
                            },
                            "transport": {
                              "type": "string",
                              "enum": [
                                "streamable-http"
                              ]
                            },
                            "auth": {
                              "type": "string"
                            },
                            "docs": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/agents": {
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "List agents",
        "description": "Returns the agents this key can see: prebuilt agents, agents shared\nacross the company, and the key owner's own private agents. Another\nuser's private agents are never listed.\n\nThe system prompt, raw config, and builder graph are internal and are\nnot returned here.\n",
        "operationId": "listAgents",
        "tags": [
          "Agents"
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            },
            "description": "0-indexed page number"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 100
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Match against name or role title"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "agents": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/AgentSummary"
                          }
                        },
                        "total": {
                          "type": "integer"
                        },
                        "page": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Key lacks the agents:read scope"
          }
        }
      },
      "post": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Create an agent",
        "description": "Creates an agent through the same hallway the in-app builder writes,\nso every guard rides along. Skill ids are verified against the\ntenant's visible shelf — unlike the session door, whose picker makes\nbad ids unrepresentable, this door must check.\n\n`config` takes allowlisted keys only (internetAccess, aiProvider,\naiModel, budget, readOnly, allowUnattendedOutbound,\nallowUnattendedDbWrites, personality, dataResources); unknown keys are\na 400 and `team` is refused here — teams have their own door,\n`POST /agents/teams`.\n\nNew agents are private to the key's user; client_id/user_id come from\nthe authenticated identity and are never read from the body.\n",
        "operationId": "createAgent",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "role_title": {
                    "type": "string"
                  },
                  "bio": {
                    "type": "string"
                  },
                  "icon": {
                    "type": "string"
                  },
                  "color": {
                    "type": "string"
                  },
                  "system_prompt": {
                    "type": "string"
                  },
                  "skills": {
                    "type": "array",
                    "description": "Ids from GET /skills — each verified visible to the tenant",
                    "items": {
                      "type": "integer"
                    }
                  },
                  "config": {
                    "type": "object",
                    "description": "Allowlisted keys only; unknown keys 400, `team` refused"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created — the same detail shape GET /agents/{agentId} serves",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "agent": {
                          "$ref": "#/components/schemas/AgentDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, unknown config key, or an invisible skill id"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `agents:write`"
          }
        }
      }
    },
    "/agents/{agentId}": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "Get an agent",
        "description": "One agent's public shape: identity, resolved skills, derived\ncapabilities, and any model override. An agent this key cannot see\nreturns 404 rather than 403.\n\nRaw config and the builder graph stay internal. `?include=prompt` adds\n`system_prompt` via the same shaper flag MCP's get_agent_config uses —\nnot a widening: the session door already shows the prompt to any\nviewer who can see the agent.\n",
        "operationId": "getAgent",
        "tags": [
          "Agents"
        ],
        "parameters": [
          {
            "name": "include",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated extras. `prompt` adds system_prompt to the detail."
          }
        ],
        "responses": {
          "200": {
            "description": "Agent detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "agent": {
                          "$ref": "#/components/schemas/AgentDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found or not visible to this key"
          }
        }
      },
      "patch": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Edit an agent",
        "description": "Partial update — absent fields are left alone; `config` merges onto\nthe stored config after the allowlist (unknown keys 400;\n`team`/`vault`/`_history` refused by name); skill ids are verified\nagainst the tenant's visible shelf. PATCH, not PUT: the v1 CORS\ncontract has no PUT in Allow-Methods, so a browser-based caller's\npreflight would fail on it.\n\nWritability is creator-only: a visible agent the key's user does not\nOWN (shared, or prebuilt) refuses writes with 403. An agent the key\ncannot see at all is 404 — a 403 would confirm it exists, which is\nwhat an id-enumerating caller wants to learn.\n\nConflicts: send `expected_modified`, the agent's `modified` from the\nlast read. When the agent was saved since (on any door), the write is\nrefused with 409 `STALE_AGENT` and nothing is written; the check and\nthe write are one statement. The answer's `agent.modified` is the\nwhole-second stamp to send on the next PATCH. Omit it for\nlast-writer-wins; an edit without it that loses three races in a row\nto other saves is refused with 409 `STALE_AGENT`, so retry it. A share\nchange does not move the stamp.\n",
        "operationId": "updateAgent",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expected_modified": {
                    "type": "string",
                    "format": "date-time",
                    "description": "The agent's `modified` from the last read. Compared at whole-second precision; a newer stored stamp is refused with 409 STALE_AGENT."
                  },
                  "name": {
                    "type": "string"
                  },
                  "role_title": {
                    "type": "string"
                  },
                  "bio": {
                    "type": "string"
                  },
                  "icon": {
                    "type": "string"
                  },
                  "color": {
                    "type": "string"
                  },
                  "system_prompt": {
                    "type": "string"
                  },
                  "skills": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  },
                  "config": {
                    "type": "object",
                    "description": "Merged onto the stored config after the allowlist"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated agent — the same detail shape GET serves. `agent.modified` is the stamp this write stored; send it as the next `expected_modified`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "agent": {
                          "$ref": "#/components/schemas/AgentDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, unknown config key, an invisible skill id, or an `expected_modified` that is not a timestamp"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — the agent is visible but not the key user's own (prebuilt agents are never writable)"
          },
          "404": {
            "description": "Agent not found or not visible to this key"
          },
          "409": {
            "description": "STALE_AGENT — the agent was saved after the `expected_modified` stamp. Nothing was written; read it again and re-apply the change.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Retire an agent",
        "description": "Soft retire (`is_active: false`) — finished runs stay pollable and\nhistory stays readable. Creator-only, same rule as PATCH.\n",
        "operationId": "deleteAgent",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Retired"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — not the key user's own agent"
          },
          "404": {
            "description": "Agent not found or not visible to this key"
          }
        }
      }
    },
    "/agents/{agentId}/run": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "agents:execute",
        "x-auth": "key",
        "summary": "Run an agent",
        "description": "Runs the agent headlessly with the tenant's context, the agent's own\nskills, and the unattended policy gate — which still blocks outbound\nwrites and raw SQL writes unless the agent's own configuration opted\nin. An API key cannot give an agent powers it does not already have.\n\n`mode: \"sync\"` (default) waits up to 5 minutes and returns the answer.\n`mode: \"async\"` returns a `job_id` and `poll_url` immediately.\n\n**Conversations.** By default a run is a one-shot: the agent remembers\nnothing from the last call. Pass `start_conversation: true` to open a\nthread, then send its `conversation_id` on every later turn — the agent\nis replayed the prior turns and the exchange is stored. Threads live in\nthe same place the in-app agent chat keeps its history, so a\nconversation an external chatbot opens is readable in the Agents page\nand can be continued from either side. Read them back under\n`/agents/conversations`.\n\nThe replay is windowed (most recent turns, bounded by size) — a long\nthread stays affordable, and the oldest turns fall out of the agent's\nview while remaining in the stored transcript.\n\nAgent teams are refused here with 400 — run them via\n`POST /agents/teams/{teamId}/run` instead (async-only).\n\nTokens are billed to the key's tenant; an over-budget account is\nrefused before the model runs. Limited to 10 runs per minute per\ntenant, shared with the MCP `run_agent` tool.\n",
        "operationId": "runAgent",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt"
                ],
                "properties": {
                  "prompt": {
                    "type": "string",
                    "description": "What the agent should do"
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "sync",
                      "async"
                    ],
                    "default": "sync"
                  },
                  "title": {
                    "type": "string",
                    "description": "Label for the run record (async only)"
                  },
                  "max_iterations": {
                    "type": "integer",
                    "description": "Cap on agent turns; clamped to the platform ceiling"
                  },
                  "conversation_id": {
                    "type": "integer",
                    "description": "Make this run a turn in an existing conversation. The agent\nis replayed the thread's prior turns before your prompt, and\nthe exchange is appended when it answers. 404 if the thread\nis not this key's.\n"
                  },
                  "start_conversation": {
                    "type": "boolean",
                    "description": "Open a new conversation for this run. The response carries\nits `conversation_id` — pass that back on the next turn.\n"
                  },
                  "conversation_title": {
                    "type": "string",
                    "description": "Names a conversation being opened. Defaults to the first\nprompt, truncated.\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Run result (sync) or accepted job (async)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/AgentRunResult"
                        },
                        {
                          "$ref": "#/components/schemas/AgentRunAccepted"
                        }
                      ]
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Agent is a team, or the request is malformed"
          },
          "402": {
            "description": "Insufficient credits"
          },
          "422": {
            "description": "Invalid mode or missing prompt"
          },
          "429": {
            "description": "Too many agent runs"
          }
        }
      }
    },
    "/agents/assistant/run": {
      "post": {
        "x-required-scope": "agents:execute",
        "x-auth": "key",
        "summary": "Run the platform assistant",
        "description": "Runs the platform assistant (the in-app chat with no agent selected)\nheadlessly. Same body and answers as `POST /agents/{agentId}/run`;\nanswers carry `agent_id: null`.\n\nThe assistant has the tenant's context (business profile, pinned\nnotes and notes matching the prompt, connected services) and every\ndefault tool, found through tool search. It has no skills, budget or\nmemory of its own. The unattended policy gate applies, as on the agent\ndoor: outbound writes and raw SQL writes are refused, and a step a\ntenant rule holds for approval is denied. The assistant is told to ask\nfor confirmation in its answer instead, so continue the conversation\nto give it.\n\n**Conversations** work as on the agent door. Threads belong to the\nperson, not to an agent, so one conversation can mix assistant turns\nand agent turns.\n\nAn async run is readable through `GET /agents/runs/{jobId}` and its\nstream by the person who started it only. Billing and the per-tenant\nrun limit are shared with the agent door.\n",
        "operationId": "runAssistant",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt"
                ],
                "properties": {
                  "prompt": {
                    "type": "string",
                    "description": "What the assistant should do"
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "sync",
                      "async"
                    ],
                    "default": "sync"
                  },
                  "title": {
                    "type": "string",
                    "description": "Label for the run record (async only)"
                  },
                  "max_iterations": {
                    "type": "integer",
                    "description": "Cap on turns; clamped to the platform ceiling"
                  },
                  "conversation_id": {
                    "type": "integer",
                    "description": "Make this run a turn in an existing conversation"
                  },
                  "start_conversation": {
                    "type": "boolean",
                    "description": "Open a new conversation for this run"
                  },
                  "conversation_title": {
                    "type": "string",
                    "description": "Names a conversation being opened"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Run result (sync) or accepted job (async)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/AgentRunResult"
                        },
                        {
                          "$ref": "#/components/schemas/AgentRunAccepted"
                        }
                      ]
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed"
          },
          "402": {
            "description": "Insufficient credits"
          },
          "403": {
            "description": "AI features are disabled for this person"
          },
          "404": {
            "description": "The conversation is not this credential's"
          },
          "422": {
            "description": "Invalid mode or missing prompt"
          },
          "429": {
            "description": "Too many agent runs"
          }
        }
      }
    },
    "/agents/teams": {
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "List agent teams",
        "description": "The team-shaped view of the agents whose `config.team` exists — the\nsame rows GET /agents lists with `is_team: true`, here with\n`member_count`. Same visibility fence: prebuilt, company-shared, and\nthe key owner's own private teams.\n",
        "operationId": "listAgentTeams",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Team list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "teams": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/TeamSummary"
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `agents:read`"
          }
        }
      },
      "post": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Create an agent team",
        "description": "The only v1 place teams are created — `POST /agents` refuses\n`config.team` and points here. Same contract as the session builder:\nevery member agentId must be an agent the key can see, and\n`strategy: \"sequential\"` chains members into handoff edges. Governance\nknobs (autoApprove, humanInTheLoop, …) start at their conservative\ndefaults and are edited via PATCH /agents/teams/{teamId}. New teams\nare private to the key's user.\n",
        "operationId": "createAgentTeam",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "supervisorPrompt": {
                    "type": "string",
                    "description": "Defaulted when blank"
                  },
                  "members": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "agentId": {
                          "type": "integer"
                        },
                        "role": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "strategy": {
                    "type": "string",
                    "enum": [
                      "parallel",
                      "sequential"
                    ]
                  },
                  "icon": {
                    "type": "string"
                  },
                  "color": {
                    "type": "string"
                  },
                  "supervisorAgentId": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created — the same detail shape GET /agents/teams/{teamId} serves",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "team": {
                          "$ref": "#/components/schemas/TeamDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, or a member agentId the key cannot see"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `agents:write`"
          }
        }
      }
    },
    "/agents/teams/{teamId}": {
      "parameters": [
        {
          "name": "teamId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "Get an agent team",
        "description": "One team's shaped detail — members, strategy, topology, governance\nknobs. A team the key cannot see is 404 (never 403 — that confirms\nthe id exists); a visible row that is not a team is 400.\n",
        "operationId": "getAgentTeam",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Team detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "team": {
                          "$ref": "#/components/schemas/TeamDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The row exists and is visible, but is not a team"
          },
          "404": {
            "description": "Team not found or not visible to this key"
          }
        }
      },
      "patch": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Edit an agent team",
        "description": "The session editor's full-state save contract: name, description,\nsupervisorPrompt, icon, color, and EITHER `topology.{nodes,edges}`\n(the graph schema) OR flat `members[]` + `strategy` + `handoffRules`\n(back-compat), plus the governance knobs (autoApprove, maxRevisions,\nsupervisorAgentId, maxBudget, humanInTheLoop, clarityGate — the last\nonly written when stated). Every member agentId must be an agent the\nkey can see. Stored config.team keys this contract does not model\nsurvive the save, and the previous state is snapshotted into the\nteam's rolling history.\n\nWrites are creator-only (403 otherwise); prebuilt teams are never\nwritable. PATCH, not PUT — the v1 CORS contract has no PUT.\n",
        "operationId": "updateAgentTeam",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "supervisorPrompt": {
                    "type": "string"
                  },
                  "icon": {
                    "type": "string"
                  },
                  "color": {
                    "type": "string"
                  },
                  "topology": {
                    "type": "object",
                    "properties": {
                      "nodes": {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      },
                      "edges": {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      }
                    }
                  },
                  "members": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "agentId": {
                          "type": "integer"
                        },
                        "role": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "strategy": {
                    "type": "string",
                    "enum": [
                      "parallel",
                      "sequential"
                    ]
                  },
                  "handoffRules": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "autoApprove": {
                    "type": "boolean"
                  },
                  "maxRevisions": {
                    "type": "integer"
                  },
                  "supervisorAgentId": {
                    "type": "integer"
                  },
                  "maxBudget": {
                    "type": "number"
                  },
                  "humanInTheLoop": {
                    "type": "boolean"
                  },
                  "clarityGate": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated team — re-read through the one shaper so it cannot drift from GET",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "team": {
                          "$ref": "#/components/schemas/TeamDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, a non-team row, or a member the key cannot see"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — not the key user's own team"
          },
          "404": {
            "description": "Team not found or not visible to this key"
          }
        }
      },
      "delete": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Retire an agent team",
        "description": "Soft retire (`is_active: false`) — finished runs stay pollable. Creator-only, same rule as PATCH.",
        "operationId": "deleteAgentTeam",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Retired"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — not the key user's own team"
          },
          "404": {
            "description": "Team not found or not visible to this key"
          }
        }
      }
    },
    "/agents/teams/{teamId}/run": {
      "parameters": [
        {
          "name": "teamId",
          "in": "path",
          "required": true,
          "description": "ID of an agent team — rows in `GET /agents` with `is_team: true`.\n",
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "agents:execute",
        "x-auth": "key",
        "summary": "Run an agent team",
        "description": "Starts a team run in the background: the supervisor decomposes the\ntask, member agents work it, and results are reviewed before the team\nanswers. Returns a `job_id` immediately — poll it at\n`/agents/runs/{jobId}`, which serves team runs exactly as it serves\nsolo async runs.\n\nASYNC-ONLY. A team run is a multi-agent fan-out with no iteration\nceiling, so there is no synchronous mode; `mode: \"sync\"` is refused\nwith 422 rather than silently running in the background. Omit `mode`\nor pass `\"async\"`.\n\nWorkers run with the tenant's context and the unattended policy gate,\nand human-in-the-loop pauses never trigger on this path — there is no\nhuman here to resume one. Running a solo agent through this endpoint\nreturns 400 pointing at `/agents/{agentId}/run`.\n\nTokens are billed to the key's tenant; an over-budget account settles\nthe job as failed with the billing reason. Run starts share the\n10-per-minute tenant throttle with solo runs and the MCP\n`run_agent_team` tool.\n",
        "operationId": "runAgentTeam",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt"
                ],
                "properties": {
                  "prompt": {
                    "type": "string",
                    "description": "The task for the team"
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "async"
                    ],
                    "default": "async",
                    "description": "Accepted for symmetry with the solo door; async is the only mode"
                  },
                  "title": {
                    "type": "string",
                    "description": "Label for the run record"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AgentRunAccepted"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Not a team (solo agents run via /agents/{agentId}/run), or the request is malformed"
          },
          "404": {
            "description": "Team not found or not visible to this key"
          },
          "422": {
            "description": "Missing prompt, or a non-async mode"
          },
          "429": {
            "description": "Too many agent runs"
          }
        }
      }
    },
    "/agents/runs": {
      "get": {
        "x-required-scope": [
          "agents:read",
          "agents:execute"
        ],
        "x-auth": "person",
        "summary": "List the caller's own runs",
        "description": "The runs the credential's own person started, newest first: solo,\nteam and assistant runs, from any door. Open one through\n`GET /agents/runs/{jobId}` or its stream.\n\n`agent_name` is the agent's name while the person can still see the\nagent, the assistant's name for an assistant run, and null otherwise.\n`finished` is null while a run is running.\n\nRequires `agents:read` or `agents:execute`, and the credential must\nbe the person: an OAuth sign-in or a user-scope key. A company key,\nor a connection bound to another person's key, gets\n`403 PERSON_CREDENTIAL_REQUIRED`.\n",
        "operationId": "listOwnAgentRuns",
        "tags": [
          "Agents"
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "running",
                "recent"
              ],
              "default": "recent"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The runs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "runs": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "job_id": {
                                "type": "integer"
                              },
                              "agent_id": {
                                "type": [
                                  "integer",
                                  "null"
                                ],
                                "description": "null for an assistant run"
                              },
                              "agent_name": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "agent",
                                  "team",
                                  "assistant"
                                ]
                              },
                              "title": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "completed",
                                  "failed",
                                  "hibernating"
                                ],
                                "description": "hibernating: paused, waiting for a person's input; finished is null"
                              },
                              "started": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "finished": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "format": "date-time"
                              },
                              "duration_ms": {
                                "type": [
                                  "integer",
                                  "null"
                                ]
                              },
                              "error": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            }
                          }
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "running",
                            "recent"
                          ]
                        },
                        "limit": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unknown status"
          },
          "403": {
            "description": "The credential does not stand for one person"
          }
        }
      }
    },
    "/agents/runs/{jobId}": {
      "parameters": [
        {
          "name": "jobId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "agents:execute",
        "x-auth": "key",
        "summary": "Poll an async agent run",
        "description": "Status walks `running` → `completed` | `failed`. Serves solo runs and\nteam runs alike — both doors return a `poll_url` pointing here.\n\nRequires `agents:execute` (not `agents:read`), so the key that started\nthe run can always poll it.\n",
        "operationId": "getAgentRun",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Run status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AgentRunStatus"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Run not found"
          }
        }
      }
    },
    "/agents/runs/{jobId}/stream": {
      "parameters": [
        {
          "name": "jobId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": [
          "agents:read",
          "agents:execute"
        ],
        "x-auth": "key",
        "summary": "Follow an async agent run as server-sent events",
        "description": "The streaming twin of `GET /agents/runs/{jobId}`: instead of polling,\nhold this open and receive frames until the run settles.\n\nFrames (`event:` names): `status` — the poll door's body, sent first and\nagain whenever the run row changes; `event` — what a team run narrates\nas it works (`{ type, data, at }`, the orchestrator's own event names\ninside; solo runs narrate nothing between start and finish); `done` —\n`{ status }`, after which the stream ends; `ping` every 15 seconds;\n`reconnect` after four minutes (reconnect and the first frame is the\ncurrent `status`); `error` with a code if the run can no longer be read.\n\nServes solo and team runs alike. Requires `agents:read` or\n`agents:execute`, so the credential that started a run can always\nwatch it.\n",
        "operationId": "streamAgentRun",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Server-sent events until the run settles",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "SSE frames — `status`, `event`, `done`, `ping`, `reconnect`, `error`"
                }
              }
            }
          },
          "400": {
            "description": "jobId is not a positive integer"
          },
          "404": {
            "description": "Run not found or not visible to this credential"
          }
        }
      }
    },
    "/agents/{agentId}/jobs": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "List an agent's scheduled jobs",
        "description": "`?type=scheduled` (default) for the schedules themselves, `?type=run`\nfor background/history rows. Rows go out through the shared job shaper\n— never the raw row: accumulated_data is engine checkpoint state and\nstays inside.\n",
        "operationId": "listAgentJobs",
        "tags": [
          "Agents"
        ],
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "scheduled",
                "run"
              ],
              "default": "scheduled"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Job list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "jobs": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/AgentJob"
                          }
                        },
                        "total": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `agents:read`"
          },
          "404": {
            "description": "Agent not found or not visible to this key"
          }
        }
      },
      "post": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Schedule an agent job",
        "description": "Creates a schedule — draft by default, `status: \"live\"` or\n`go_live: true` to activate immediately, exactly like the web door.\n\nThis door is STRICT where the web door is permissive: delivery_mode\nmust be one of the user-settable modes, timezone must be a real IANA\nzone (the web door lets computeNextRun silently fall back to UTC),\nschedule_type must be a known type. An external caller getting a 400\ntoday beats a schedule that silently fires at the wrong hour forever.\n",
        "operationId": "createAgentJob",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title",
                  "prompt"
                ],
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "schedule_type": {
                    "type": "string"
                  },
                  "interval_minutes": {
                    "type": "integer"
                  },
                  "time_of_day": {
                    "type": "string"
                  },
                  "day_of_week": {
                    "type": "integer"
                  },
                  "day_of_month": {
                    "type": "integer"
                  },
                  "timezone": {
                    "type": "string",
                    "description": "A real IANA zone — validated here, unlike the web door"
                  },
                  "cron_expression": {
                    "type": "string"
                  },
                  "delivery_mode": {
                    "type": "string"
                  },
                  "max_runs": {
                    "type": "integer"
                  },
                  "status": {
                    "type": "string",
                    "description": "`\"live\"` to activate immediately; draft otherwise"
                  },
                  "go_live": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The created job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "job": {
                          "$ref": "#/components/schemas/AgentJobDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Strict validation failed — unknown schedule_type, delivery_mode, or timezone"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `agents:write`"
          },
          "404": {
            "description": "Agent not found or not visible to this key"
          }
        }
      }
    },
    "/agents/{agentId}/jobs/{jobId}": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "jobId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "Get a scheduled job",
        "operationId": "getAgentJob",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Job detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "job": {
                          "$ref": "#/components/schemas/AgentJobDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Job not found"
          }
        }
      },
      "patch": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Edit, pause, resume, or publish a job",
        "description": "The whole lifecycle the web door drives through the same verb: edit\nfields, pause/resume via `active`, publish via `status: \"live\"`, and\n`recompute_schedule: true` to re-arm next_run_at without changing the\nschedule. Strict validation, as on create.\n\nOwner-fenced (client + the key's user): a job created by a different\nuser in the tenant reads as 404, not 403 — a 403 would confirm it\nexists to an id-enumerating caller.\n",
        "operationId": "updateAgentJob",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "schedule_type": {
                    "type": "string"
                  },
                  "interval_minutes": {
                    "type": "integer"
                  },
                  "time_of_day": {
                    "type": "string"
                  },
                  "day_of_week": {
                    "type": "integer"
                  },
                  "day_of_month": {
                    "type": "integer"
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "cron_expression": {
                    "type": "string"
                  },
                  "delivery_mode": {
                    "type": "string"
                  },
                  "max_runs": {
                    "type": "integer"
                  },
                  "active": {
                    "type": "boolean",
                    "description": "Pause (false) or resume (true) the schedule"
                  },
                  "status": {
                    "type": "string"
                  },
                  "recompute_schedule": {
                    "type": "boolean",
                    "description": "Re-arm next_run_at without changing the schedule"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated job, with the list of fields actually changed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "job": {
                          "$ref": "#/components/schemas/AgentJobDetail"
                        },
                        "updated_fields": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Strict validation failed"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `agents:write`"
          },
          "404": {
            "description": "Job not found, or owned by a different user"
          }
        }
      },
      "delete": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Delete a scheduled job",
        "description": "Owner-fenced like PATCH — another user's job reads as 404.",
        "operationId": "deleteAgentJob",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "deleted": {
                          "type": "boolean"
                        },
                        "job_id": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `agents:write`"
          },
          "404": {
            "description": "Job not found, or owned by a different user"
          }
        }
      }
    },
    "/agents/{agentId}/jobs/{jobId}/run-now": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "jobId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "agents:execute",
        "x-auth": "key",
        "summary": "Force-execute a scheduled job now",
        "description": "Returns right away with the CHILD run's id: the hallway pre-creates\nthe run-history row before firing the executor, so `run_id` is\npollable via GET /agents/runs/{jobId} (status walks running →\ncompleted | failed). A 409 means the job is already running — the\natomic lock in the hallway, not a pre-read race.\n\nScope `agents:execute` — this spends model tokens, same as\nPOST /agents/{agentId}/run. Not user-fenced, matching the web Run Now\nbutton: any tenant member who can see the job can trigger it; the\nschedule itself is untouched except for its normal post-run advance.\n",
        "operationId": "runAgentJobNow",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "The run is executing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "job_id": {
                          "type": "integer"
                        },
                        "run_id": {
                          "type": "integer"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "running"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `agents:execute`"
          },
          "404": {
            "description": "Job not found"
          },
          "409": {
            "description": "The job is already running"
          }
        }
      }
    },
    "/agents/{agentId}/jobs/{jobId}/runs": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "jobId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "Run history for a scheduled job",
        "description": "Newest first. Each row is a child job_type 'run' record; a row still\nin status 'running' can be polled live via GET /agents/runs/{id}.\nScope `agents:read` — history is a read, unlike run-now which spends\ntokens.\n",
        "operationId": "listAgentJobRuns",
        "tags": [
          "Agents"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated run history",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "runs": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "integer"
                              },
                              "parent_id": {
                                "type": "integer",
                                "nullable": true
                              },
                              "title": {
                                "type": "string",
                                "nullable": true
                              },
                              "status": {
                                "type": "string",
                                "nullable": true
                              },
                              "final_result": {
                                "nullable": true
                              },
                              "last_error": {
                                "type": "string",
                                "nullable": true
                              },
                              "duration_ms": {
                                "type": "integer",
                                "nullable": true
                              },
                              "created": {
                                "type": "string",
                                "format": "date-time",
                                "nullable": true
                              }
                            }
                          }
                        },
                        "total": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "offset": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Job not found"
          }
        }
      }
    },
    "/agents/{agentId}/brain": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "List an agent's Library documents",
        "description": "Documents plus a usage summary against the Library's 50K-character\ncapacity — the same hallway the in-app Library editor reads, so budget\nmath cannot drift between doors. `?original=<id>` returns one uploaded\ndocument's stored full source text instead (uploads keep the source\nalongside their summary).\n\nEvery v1 brain route first verifies the key's user can SEE the agent\nand answers 404 when not — a 403 would confirm the agent exists,\nwhich is what an id-enumerating caller wants to learn.\n",
        "operationId": "listBrainDocuments",
        "tags": [
          "Agents"
        ],
        "parameters": [
          {
            "name": "original",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Return this document's stored full source text"
          }
        ],
        "responses": {
          "200": {
            "description": "Documents and usage (or one document's source when `original` is set)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "documents": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "integer"
                              },
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string",
                                "nullable": true
                              },
                              "content": {
                                "type": "string"
                              },
                              "created": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "modified": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "hasOriginal": {
                                "type": "boolean"
                              },
                              "originalChars": {
                                "type": "integer"
                              }
                            }
                          }
                        },
                        "usage": {
                          "type": "object"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `agents:read`"
          },
          "404": {
            "description": "Agent (or the requested document) not found"
          }
        }
      },
      "post": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Add a Library document",
        "description": "Over-budget content is auto-summarized to fit the Library's capacity —\nthat summarization is a billed model call, so an out-of-credit tenant\ngets 402. A tenant data-policy block surfaces as 403 POLICY_BLOCKED.\n",
        "operationId": "addBrainDocument",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title",
                  "content"
                ],
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "doc_type": {
                    "type": "string"
                  },
                  "keywords": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The stored document (possibly summarized)"
          },
          "400": {
            "description": "Missing title/content"
          },
          "402": {
            "description": "Out of credit for the summarization call"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or POLICY_BLOCKED — a tenant data rule refused the content"
          },
          "404": {
            "description": "Agent not found or not visible to this key"
          }
        }
      }
    },
    "/agents/{agentId}/brain/{documentId}": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "documentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "patch": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Update a Library document",
        "description": "Title and/or content; content changes are delta-budgeted against the\nLibrary's 50K-character capacity.\n",
        "operationId": "updateBrainDocument",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated"
          },
          "400": {
            "description": "Nothing to update, or `content` is not a string"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `agents:write`"
          },
          "404": {
            "description": "Agent or document not found"
          }
        }
      },
      "delete": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Remove a Library document",
        "description": "Soft-delete — the row is disabled, matching the in-app door; there is no hard delete.",
        "operationId": "deleteBrainDocument",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Removed"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `agents:write`"
          },
          "404": {
            "description": "Agent or document not found"
          }
        }
      }
    },
    "/agents/{agentId}/brain/upload": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Upload a document into an agent's Library",
        "description": "PDF, DOCX, or text; 10 MB cap. Extraction, billing, capacity and\nusage tracking run in the same shared service the in-app upload uses.\nBig documents are extracted and AI-summarized, so allow up to a\nminute.\n",
        "operationId": "uploadBrainDocument",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The stored document"
          },
          "400": {
            "description": "Not a multipart body, or an unsupported file type"
          },
          "402": {
            "description": "Out of credit for the summarization call"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or POLICY_BLOCKED"
          },
          "404": {
            "description": "Agent not found or not visible to this key"
          },
          "413": {
            "description": "File over the 10 MB cap"
          }
        }
      }
    },
    "/agents/conversations": {
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "List agent conversations",
        "description": "The stored threads this key owns, newest first — the same conversations\nthe in-app agent chat lists, so an external chatbot and the UI share one\nhistory.\n\nSummaries only; a transcript can be long. Read one thread's messages\nfrom `/agents/conversations/{conversationId}`.\n\nConversations are keyed to the user, not to an agent: one thread can be\ncontinued by whichever agent the caller names on each run.\n",
        "operationId": "listAgentConversations",
        "tags": [
          "Agents"
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 100
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Only threads whose title or message text contains this\n(case-insensitive). A query under 2 characters is ignored and the\nplain list comes back; only the first 200 characters are read.\nA search reads the 2,000 most recent threads and keeps at most 200\nmatches, which `page` and `limit` then page through. When either\nlimit is reached the reply says `truncated: true`, and `total`\ncounts only the kept matches.\n",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Conversation list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "conversations": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/ConversationSummary"
                          }
                        },
                        "total": {
                          "type": "integer"
                        },
                        "page": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        },
                        "truncated": {
                          "type": "boolean",
                          "description": "Present on a search (`q`). True when the search may have missed matches (see `q`)."
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "x-required-scope": "agents:execute",
        "x-auth": "key",
        "summary": "Open a conversation",
        "description": "Creates an empty thread and returns its id. Optional — passing\n`start_conversation: true` on a run opens one too, named from the first\nprompt. Use this when the chatbot needs the id before it has anything to\nsay, such as on session start.\n\nRequires `agents:execute`: opening a thread is the first half of running\nan agent in one.\n",
        "operationId": "createAgentConversation",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "description": "Defaults to a generated name; max 100 characters"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new conversation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "conversation": {
                          "$ref": "#/components/schemas/ConversationSummary"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/agents/conversations/{conversationId}": {
      "parameters": [
        {
          "name": "conversationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "Read a conversation",
        "description": "The thread and its full message history — what an external chatbot\nrenders when a user reopens a session — and the chat project it is\nfiled in, if any (`project`).\n\nA thread that is not this key's returns 404 rather than 403: the door\nnever confirms that an id it will not serve exists.\n",
        "operationId": "getAgentConversation",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "The conversation and its messages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "conversation": {
                          "$ref": "#/components/schemas/Conversation"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Conversation not found"
          }
        }
      },
      "patch": {
        "x-required-scope": "agents:execute",
        "x-auth": "key",
        "summary": "Rename a conversation",
        "description": "Title only. Messages are written by runs — a caller cannot PUT a\ntranscript, because the in-app chat renders this store as real history.\n",
        "operationId": "renameAgentConversation",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title"
                ],
                "properties": {
                  "title": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The renamed conversation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "conversation": {
                          "$ref": "#/components/schemas/ConversationSummary"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Conversation not found"
          }
        }
      },
      "delete": {
        "x-required-scope": "agents:execute",
        "x-auth": "key",
        "summary": "Delete a conversation",
        "description": "Removes the thread and its stored transcript. Not recoverable.",
        "operationId": "deleteAgentConversation",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "conversation_id": {
                          "type": "integer"
                        },
                        "deleted": {
                          "type": "boolean"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Conversation not found"
          }
        }
      }
    },
    "/skills": {
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "List agent skills",
        "description": "The agent skills available to this tenant — prebuilt skills plus the\ntenant's own. A skill carries the instructions and tool grants an agent\npicks up when the skill matches what it is doing.\n\nSummaries only. This is the discovery shelf: it tells you what exists\nand what each skill is for, without spending your context on every\ninstruction body. Read one in full with `GET /skills/{skillId}`.\n",
        "operationId": "listSkills",
        "tags": [
          "Agents"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Rows to skip. Page while `has_more` is true — a library can hold hundreds of skills.",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Case-insensitive match on name, display name or description.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "folder_id",
            "in": "query",
            "description": "Only skills filed in this library folder (see `GET /skills/folders`); `root` for the unfiled. Unknown folder: 404.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Skill list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "skills": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/SkillSummary"
                          }
                        },
                        "total": {
                          "type": "integer",
                          "description": "Skills the key's user may see that match the filters."
                        },
                        "offset": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Key lacks the agents:read scope"
          }
        }
      },
      "post": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Create an agent skill",
        "description": "Creates a skill owned by the calling key's tenant.\n\nTwo body formats. Send `application/json` with the fields below, or\nsend `text/markdown` containing a complete `SKILL.md` — YAML\nfrontmatter (`name`, `description`) followed by the instructions as the\nmarkdown body. The markdown form is what makes skills portable: a\nSKILL.md written for Claude Code, or downloaded from another Intuidy\ntenant, can be posted verbatim.\n\nPrebuilt skills cannot be created — `is_prebuilt` is not settable, and\n`client_id`/`user_id` always come from the API key, never the body.\n",
        "operationId": "createSkill",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SkillWrite"
              }
            },
            "text/markdown": {
              "schema": {
                "type": "string",
                "description": "A complete SKILL.md document"
              },
              "example": "---\nname: invoice-triage\ndescription: Sort inbound invoices by urgency. Use when the user mentions invoices, AP, or payment runs.\n---\n\n# Invoice Triage\n\n1. Read the invoice total and due date.\n2. Flag anything over 30 days past due.\n"
            }
          }
        },
        "responses": {
          "201": {
            "description": "Skill created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "skill": {
                          "$ref": "#/components/schemas/SkillDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — display_name missing or over 255 characters, or a SKILL.md with no name and no heading"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — the user's role lacks `edit_skills`"
          }
        }
      }
    },
    "/skills/download": {
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "Download skills as an Agent Skills bundle",
        "description": "Returns a zip archive in the Anthropic Agent Skills layout — one\ndirectory per skill, each containing `SKILL.md`, any bundled\n`references/*.md`, and a `vantage.json` sidecar carrying the\nIntuidy-only fields (triggers, tool categories, icon, colour).\n\nUnzip it into `~/.claude/skills/` or a project's `.claude/skills/`, or\nupload a single skill's directory to claude.ai, and your own runtime\nruns the skill you authored here. The sidecar is ignored by runtimes\nthat do not know it, and is what lets the bundle be posted back to\n`POST /skills` intact.\n\nSubject to your organization's data rules: skill instructions can quote\ninternal identifiers, so a rule that blocks that content on the export\nchannel refuses the download rather than redacting it silently.\n",
        "operationId": "downloadSkills",
        "tags": [
          "Agents"
        ],
        "parameters": [
          {
            "name": "ids",
            "in": "query",
            "description": "Comma-separated skill ids. Omit for every skill the key can see.",
            "schema": {
              "type": "string"
            },
            "example": "12,15,18"
          }
        ],
        "responses": {
          "200": {
            "description": "Zip archive",
            "headers": {
              "X-Vantage-Skill-Count": {
                "description": "How many skills the archive actually contains.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-Vantage-Truncated": {
                "description": "Present and `true` when more skills matched than one bundle carries (250). The archive is a subset — narrow it with `ids`.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                }
              }
            },
            "content": {
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE, or POLICY_BLOCKED when a data rule refuses the content"
          },
          "404": {
            "description": "No skills matched"
          }
        }
      }
    },
    "/skills/graph": {
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "The skill library as a graph",
        "description": "The nodes and edges the Skills library's Graph view draws: skill nodes\n(with their folder, colour and a private flag), folders as parent\nnodes, `requires` / `related` edges between skills, and optionally the\nagents that carry them. Node ids are `skill:<id>`, `folder:<id>` and\n`agent:<id>`; a node inside a folder names it in `parent`. Only skills\nthe key's user may see appear, and an edge to one they cannot is\ndropped with it.\n",
        "operationId": "getSkillGraph",
        "tags": [
          "Agents"
        ],
        "parameters": [
          {
            "name": "group_by_folder",
            "in": "query",
            "description": "Wrap skills in their folder (default true).",
            "schema": {
              "type": "boolean",
              "default": true
            }
          },
          {
            "name": "show_agents",
            "in": "query",
            "description": "Add agent nodes and `carries` edges (default false).",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "show_prebuilt",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": true
            }
          },
          {
            "name": "kinds",
            "in": "query",
            "description": "Comma-separated skill-to-skill edge kinds to include: requires, related. Default both.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Graph",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "nodes": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "description": "skill:<id>, folder:<id> or agent:<id>"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "skill",
                                  "folder",
                                  "agent"
                                ]
                              },
                              "label": {
                                "type": "string"
                              },
                              "objId": {
                                "description": "The skill",
                                "folder or agent id": null
                              },
                              "parent": {
                                "type": "string",
                                "description": "The enclosing folder node",
                                "when grouped": null
                              },
                              "color": {
                                "type": "string",
                                "description": "The skill's colour as drawn on the graph's dark canvas, not the stored colour (GET /skills/{skillId} returns that)"
                              },
                              "system": {
                                "type": "integer",
                                "description": "1 for the synthetic Prebuilt folder node. It is not a library folder: PATCH or DELETE on its id returns 404."
                              },
                              "prebuilt": {
                                "type": "integer",
                                "description": "1 for a prebuilt skill"
                              },
                              "priv": {
                                "type": "integer",
                                "description": "1 for a privately shared skill"
                              },
                              "degree": {
                                "type": "integer",
                                "description": "Edges touching the node"
                              }
                            }
                          }
                        },
                        "edges": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "source": {
                                "type": "string"
                              },
                              "target": {
                                "type": "string"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "requires",
                                  "related",
                                  "carries"
                                ]
                              },
                              "note": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "counts": {
                          "type": "object",
                          "properties": {
                            "skills": {
                              "type": "integer"
                            },
                            "folders": {
                              "type": "integer"
                            },
                            "agents": {
                              "type": "integer"
                            },
                            "requires": {
                              "type": "integer"
                            },
                            "related": {
                              "type": "integer"
                            },
                            "carries": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`kinds` names a kind other than requires or related"
          },
          "403": {
            "description": "Key lacks the agents:read scope"
          }
        }
      }
    },
    "/skills/import": {
      "post": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Import Agent Skills bundles",
        "description": "The inverse of `GET /skills/download`: whatever that door hands out,\nthis one takes back, so a library round-trips between tenants or out\nof a git checkout. Each skill is a directory holding `SKILL.md`, any\nfiles it carries and an optional `vantage.json` sidecar; a bare\n`SKILL.md` imports too. A sidecar `folder` path is rebuilt beneath\n`folder_id` (or the root). Imported skills are always the tenant's\nown — `is_prebuilt` in a sidecar is ignored.\n\nTwo body formats. `multipart/form-data` with one or more `files` parts\n(a `.zip`, or loose text files with their bundle-relative paths in\nmatching `paths` fields) plus an optional `folderId` field; or JSON\nwith `files` (path + content), `zip_base64`, or both. 5 MB, up to 50\nskills, 60 files and 1.5 MB per skill.\n\nNeeds `agents:write`, and the key owner's role must hold both\n`edit_skills` and `import_data` (Import Data), as in the Skills tab.\n",
        "operationId": "importSkills",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    }
                  },
                  "paths": {
                    "type": "array",
                    "description": "One per file part, in order — its bundle-relative path (e.g. `invoice-triage/SKILL.md`).",
                    "items": {
                      "type": "string"
                    }
                  },
                  "folderId": {
                    "type": "string",
                    "description": "Library folder to import into; omit for the root."
                  }
                }
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "path",
                        "content"
                      ],
                      "properties": {
                        "path": {
                          "type": "string",
                          "description": "Bundle-relative, e.g. invoice-triage/scripts/lint.py"
                        },
                        "content": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "zip_base64": {
                    "type": "string",
                    "description": "A skill bundle archive, base64-encoded."
                  },
                  "folder_id": {
                    "type": "string",
                    "nullable": true,
                    "description": "Library folder to import into; omit or null for the root."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Skills created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "skills": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/SkillDetail"
                          }
                        },
                        "count": {
                          "type": "integer"
                        },
                        "truncated": {
                          "type": "boolean",
                          "description": "True when the archive held more than the caps allowed and some entries were dropped."
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — nothing importable, a bundle with no name or a name over 255 characters, more than 50 skills, or a file outside the reference caps. The whole upload is validated before any skill is written."
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — the key owner's role lacks `edit_skills` or `import_data`"
          },
          "404": {
            "description": "NOT_FOUND — no such target folder"
          },
          "413": {
            "description": "PAYLOAD_TOO_LARGE — more than 5 MB, or a file over 256 KB"
          },
          "429": {
            "description": "RATE_LIMITED — too many imports for this tenant; wait a few minutes"
          }
        }
      }
    },
    "/skills/{skillId}": {
      "parameters": [
        {
          "name": "skillId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "Get one agent skill in full",
        "description": "The complete skill: its `instructions`, bundled `references`, trigger\nkeywords and tool categories.\n\nUnlike `GET /agents/{agentId}`, which withholds the agent's\n`system_prompt`, this returns the instruction text. The two are not the\nsame kind of secret — an agent's prompt is internal state assembled from\nconfiguration, whereas a skill's instructions are the artifact your\ntenant authored and is entitled to take elsewhere.\n",
        "operationId": "getSkill",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Skill detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "skill": {
                          "$ref": "#/components/schemas/SkillDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Key lacks the agents:read scope"
          },
          "404": {
            "description": "NOT_FOUND — no such skill, or it belongs to another tenant (a private skill the key's user is not a member of is the same 404)"
          }
        }
      },
      "patch": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Update an agent skill",
        "description": "Partial update — omitted fields are left as they are. That matters for\n`references`, `triggers` and `tool_categories` in particular: sending\nthe object without them preserves what is stored rather than clearing\nit, so a client that only knows about some fields cannot silently\ndestroy the rest.\n\nPATCH rather than PUT because the API's CORS allow-list does not include\nPUT, so a browser-based caller's preflight would fail on it.\n",
        "operationId": "updateSkill",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SkillWrite"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Skill updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "skill": {
                          "$ref": "#/components/schemas/SkillDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — no editable fields (unknown keys are ignored, so `links` or `sharing` beside them still count), or a field of the wrong type"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — the skill is prebuilt; the skill was shared view-only; or (for `sharing`) the key's user is neither the owner nor a skill manager. Every gate is checked before anything is written, so a 403 means nothing changed."
          },
          "404": {
            "description": "NOT_FOUND — no such skill, or it belongs to another tenant (a private skill the key's user is not a member of is the same 404)"
          },
          "422": {
            "description": "INVALID_INPUT — `sharing` or `links` carried a value outside its enum, `links` was null (send `[]` to clear), or a `sharing.members` id is not a user of this company — refused rather than defaulted"
          }
        }
      },
      "delete": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Delete an agent skill",
        "description": "Removes the skill. Agents that referenced it keep the id in their\n`skills` array, where it resolves to nothing — detach it in the agent\nbuilder if the agent should stop advertising the capability.\n",
        "operationId": "deleteSkill",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "deleted": {
                          "type": "boolean"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — the skill is prebuilt and therefore read-only"
          },
          "404": {
            "description": "NOT_FOUND — no such skill, or it belongs to another tenant (a private skill the key's user is not a member of is the same 404)"
          }
        }
      }
    },
    "/skills/{skillId}/download": {
      "parameters": [
        {
          "name": "skillId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "Download one skill as an Agent Skills bundle",
        "description": "The same archive layout as `GET /skills/download`, containing a single\nskill's directory. See that endpoint for what the bundle holds and how\nto install it.\n",
        "operationId": "downloadSkill",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Zip archive",
            "content": {
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE, or POLICY_BLOCKED when a data rule refuses the content"
          },
          "404": {
            "description": "NOT_FOUND — no such skill, or it belongs to another tenant (a private skill the key's user is not a member of is the same 404)"
          }
        }
      }
    },
    "/skills/folders": {
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "List the skill library's folders",
        "description": "Every folder in the tenant's skill library, each with its full `path`.\nSkills name their folder through `folder_id` / `folder`; this is the\ntree those ids belong to. Also returns the key's user's role grants\nfor the library (`edit_skills`, `share_skills`, `manage_skills`).\n",
        "operationId": "listSkillFolders",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Folder list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "folders": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/SkillFolder"
                          }
                        },
                        "permissions": {
                          "type": "object",
                          "properties": {
                            "edit_skills": {
                              "type": "boolean"
                            },
                            "share_skills": {
                              "type": "boolean"
                            },
                            "manage_skills": {
                              "type": "boolean"
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Key lacks the agents:read scope"
          }
        }
      },
      "post": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Create a skill library folder",
        "description": "Needs `agents:write` and a user whose role may author skills\n(`edit_skills`). Names may not contain `/`, which the export sidecar\nuses as the path separator — a name with one is refused (400), not\nrewritten.\n",
        "operationId": "createSkillFolder",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "parentId": {
                    "type": "string",
                    "nullable": true,
                    "description": "The enclosing folder; omit or null for the root."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Folder created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "folder": {
                          "$ref": "#/components/schemas/SkillFolder"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — empty name, a name containing `/`, or the tree would exceed 8 levels"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — the user's role lacks `edit_skills`"
          },
          "404": {
            "description": "NOT_FOUND — no such parent folder"
          }
        }
      }
    },
    "/skills/folders/{folderId}": {
      "parameters": [
        {
          "name": "folderId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "patch": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Rename or move a skill library folder",
        "description": "`name` renames; `parentId` moves (null = the root). A folder cannot be\nmoved inside itself or one of its descendants.\n",
        "operationId": "updateSkillFolder",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "parentId": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Folder updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "folder": {
                          "$ref": "#/components/schemas/SkillFolder"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — empty name, a name containing `/`, a cycle, or too deep"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — the user's role lacks `edit_skills`"
          },
          "404": {
            "description": "NOT_FOUND — no such folder"
          }
        }
      },
      "delete": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "Delete a skill library folder",
        "description": "Removes the folder only. Its sub-folders and the skills filed in it\nmove up to its parent — nothing else is deleted.\n",
        "operationId": "deleteSkillFolder",
        "tags": [
          "Agents"
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "deleted": {
                          "type": "boolean"
                        },
                        "movedTo": {
                          "type": "string",
                          "nullable": true,
                          "description": "Where the contents went (the parent folder, or null for the root)."
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — the user's role lacks `edit_skills`"
          },
          "404": {
            "description": "NOT_FOUND — no such folder"
          }
        }
      }
    },
    "/skills/move": {
      "post": {
        "x-required-scope": "agents:write",
        "x-auth": "key",
        "summary": "File skills and folders under a folder",
        "description": "Moves several items at once — the API twin of the library's drag-and-\ndrop and multi-select move. Any skill the key's user can see may be\nfiled, prebuilt ones included (placement is tenant metadata, not an\nedit of the skill). `targetFolderId` null (or `root`) files them at the\nroot. Every id is checked before anything moves.\n",
        "operationId": "moveSkillItems",
        "tags": [
          "Agents"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "skillIds": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  },
                  "folderIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "targetFolderId": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Moved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "moved": {
                          "type": "integer",
                          "description": "Skills filed"
                        },
                        "folders": {
                          "type": "integer",
                          "description": "Folders moved"
                        },
                        "folderId": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — an id the user cannot see, or a folder moved into itself. The batch is checked whole before anything moves; a refusal moves nothing."
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:write` missing), or FORBIDDEN — the user's role lacks `edit_skills`"
          },
          "404": {
            "description": "NOT_FOUND — no such target folder"
          }
        }
      }
    },
    "/dashboards/folders": {
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "List the dashboard folders",
        "description": "Both dashboard folder trees: the company's shared folders and the key\nowner's own, each folder with its `tree` and full `path`. Items name\ntheir folder through `folder_id` / `my_folder_id` on\nGET /dashboards; `?folder_id=` lists one folder's contents. Also says\nwhether the key's user may manage the shared tree.\n",
        "operationId": "listDashboardFolders",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "Folder list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "folders": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/AssetFolder"
                          }
                        },
                        "permissions": {
                          "type": "object",
                          "properties": {
                            "manageShared": {
                              "type": "boolean",
                              "description": "The user's role may edit dashboards, so may change the shared tree"
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Key lacks the dashboards:read scope, or the user's role cannot view dashboards"
          }
        }
      },
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Create a dashboard folder",
        "description": "`tree` is `company` (default; needs `dashboards:write` and a role with\n`edit_dashboard`) or `personal` (the key owner's own). A child always joins\nits parent's tree. Names may not contain `/` (refused, not rewritten)\nand must be unique among their siblings.\n",
        "operationId": "createDashboardFolder",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "parentId": {
                    "type": "string",
                    "nullable": true,
                    "description": "The enclosing folder; omit or null for the root."
                  },
                  "tree": {
                    "type": "string",
                    "enum": [
                      "company",
                      "personal"
                    ],
                    "default": "company"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Folder created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "folder": {
                          "$ref": "#/components/schemas/AssetFolder"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — empty name, a name containing `/`, or the tree would exceed 8 levels"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`dashboards:write` missing), or FORBIDDEN — the role cannot change the shared tree"
          },
          "404": {
            "description": "NOT_FOUND — no such parent folder"
          },
          "409": {
            "description": "CONFLICT — a sibling already has that name"
          }
        }
      }
    },
    "/dashboards/folders/{folderId}": {
      "parameters": [
        {
          "name": "folderId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "patch": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Rename or move a dashboard folder",
        "description": "`name` renames; `parentId` moves it within its own tree (null = the\nroot). A folder cannot move inside itself or into the other tree.\n",
        "operationId": "updateDashboardFolder",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "parentId": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Folder updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "folder": {
                          "$ref": "#/components/schemas/AssetFolder"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — empty name, a `/`, a cycle, too deep, or a move between trees"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`dashboards:write` missing), or FORBIDDEN — the role cannot change the shared tree"
          },
          "404": {
            "description": "NOT_FOUND — no such folder"
          },
          "409": {
            "description": "CONFLICT — a sibling already has that name"
          }
        }
      },
      "delete": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Delete a dashboard folder",
        "description": "Removes the folder only. Its sub-folders and the dashboards filed in it\nmove up to its parent — no dashboard is deleted.\n",
        "operationId": "deleteDashboardFolder",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "deleted": {
                          "type": "string",
                          "description": "The deleted folder's id"
                        },
                        "movedItems": {
                          "type": "integer"
                        },
                        "movedFolders": {
                          "type": "integer"
                        },
                        "parentId": {
                          "type": "string",
                          "nullable": true,
                          "description": "Where the contents went (null = the root)."
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`dashboards:write` missing), or FORBIDDEN — the role cannot change the shared tree"
          },
          "404": {
            "description": "NOT_FOUND — no such folder"
          }
        }
      }
    },
    "/dashboards/folders/move": {
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "File dashboards in a folder",
        "description": "`folder_id` files every id there (the folder's tree decides which);\nnull takes them out of `tree`. A shared folder needs `edit_dashboard` and\nedit access to every dashboard; the key owner's own folders need only\nthat the user can see them. Every id is checked before anything\nmoves: one refused id refuses the batch. Up to 500 ids.\n",
        "operationId": "moveDashboards",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ids"
                ],
                "properties": {
                  "ids": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  },
                  "folder_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "tree": {
                    "type": "string",
                    "enum": [
                      "company",
                      "personal"
                    ],
                    "default": "company"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Moved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "moved": {
                          "type": "integer"
                        },
                        "folderId": {
                          "type": "string",
                          "nullable": true
                        },
                        "tree": {
                          "type": "string",
                          "enum": [
                            "company",
                            "personal"
                          ]
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — no ids, or more than 500"
          },
          "403": {
            "description": "FORBIDDEN — a shared folder and an id the user cannot edit (or a role without `edit_dashboard`). Nothing moved."
          },
          "404": {
            "description": "NOT_FOUND — no such folder, or (your own folders) an id the user cannot see. Nothing moved."
          }
        }
      }
    },
    "/workflows/folders": {
      "get": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "summary": "List the workflow folders",
        "description": "Both workflow folder trees: the company's shared folders and the key\nowner's own, each folder with its `tree` and full `path`. Items name\ntheir folder through `folder_id` / `my_folder_id` on\nGET /workflows; `?folder_id=` lists one folder's contents. Also says\nwhether the key's user may manage the shared tree.\n",
        "operationId": "listWorkflowFolders",
        "tags": [
          "Workflows"
        ],
        "responses": {
          "200": {
            "description": "Folder list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "folders": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/AssetFolder"
                          }
                        },
                        "permissions": {
                          "type": "object",
                          "properties": {
                            "manageShared": {
                              "type": "boolean",
                              "description": "The user's role may edit workflows, so may change the shared tree"
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Key lacks the workflows:read scope, or the user's role cannot view workflows"
          }
        }
      },
      "post": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "summary": "Create a workflow folder",
        "description": "`tree` is `company` (default; needs `workflows:write` and a role with\n`edit_workflows`) or `personal` (the key owner's own). A child always joins\nits parent's tree. Names may not contain `/` (refused, not rewritten)\nand must be unique among their siblings.\n",
        "operationId": "createWorkflowFolder",
        "tags": [
          "Workflows"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "parentId": {
                    "type": "string",
                    "nullable": true,
                    "description": "The enclosing folder; omit or null for the root."
                  },
                  "tree": {
                    "type": "string",
                    "enum": [
                      "company",
                      "personal"
                    ],
                    "default": "company"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Folder created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "folder": {
                          "$ref": "#/components/schemas/AssetFolder"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — empty name, a name containing `/`, or the tree would exceed 8 levels"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`workflows:write` missing), or FORBIDDEN — the role cannot change the shared tree"
          },
          "404": {
            "description": "NOT_FOUND — no such parent folder"
          },
          "409": {
            "description": "CONFLICT — a sibling already has that name"
          }
        }
      }
    },
    "/workflows/folders/{folderId}": {
      "parameters": [
        {
          "name": "folderId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "patch": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "summary": "Rename or move a workflow folder",
        "description": "`name` renames; `parentId` moves it within its own tree (null = the\nroot). A folder cannot move inside itself or into the other tree.\n",
        "operationId": "updateWorkflowFolder",
        "tags": [
          "Workflows"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "parentId": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Folder updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "folder": {
                          "$ref": "#/components/schemas/AssetFolder"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — empty name, a `/`, a cycle, too deep, or a move between trees"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`workflows:write` missing), or FORBIDDEN — the role cannot change the shared tree"
          },
          "404": {
            "description": "NOT_FOUND — no such folder"
          },
          "409": {
            "description": "CONFLICT — a sibling already has that name"
          }
        }
      },
      "delete": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "summary": "Delete a workflow folder",
        "description": "Removes the folder only. Its sub-folders and the workflows filed in it\nmove up to its parent — no workflow is deleted.\n",
        "operationId": "deleteWorkflowFolder",
        "tags": [
          "Workflows"
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "deleted": {
                          "type": "string",
                          "description": "The deleted folder's id"
                        },
                        "movedItems": {
                          "type": "integer"
                        },
                        "movedFolders": {
                          "type": "integer"
                        },
                        "parentId": {
                          "type": "string",
                          "nullable": true,
                          "description": "Where the contents went (null = the root)."
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`workflows:write` missing), or FORBIDDEN — the role cannot change the shared tree"
          },
          "404": {
            "description": "NOT_FOUND — no such folder"
          }
        }
      }
    },
    "/workflows/folders/move": {
      "post": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "summary": "File workflows in a folder",
        "description": "`folder_id` files every id there (the folder's tree decides which);\nnull takes them out of `tree`. A shared folder needs `edit_workflows` and\nedit access to every workflow; the key owner's own folders need only\nthat the user can see them. Every id is checked before anything\nmoves: one refused id refuses the batch. Up to 500 ids.\n",
        "operationId": "moveWorkflows",
        "tags": [
          "Workflows"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ids"
                ],
                "properties": {
                  "ids": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  },
                  "folder_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "tree": {
                    "type": "string",
                    "enum": [
                      "company",
                      "personal"
                    ],
                    "default": "company"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Moved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "moved": {
                          "type": "integer"
                        },
                        "folderId": {
                          "type": "string",
                          "nullable": true
                        },
                        "tree": {
                          "type": "string",
                          "enum": [
                            "company",
                            "personal"
                          ]
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — no ids, or more than 500"
          },
          "403": {
            "description": "FORBIDDEN — a shared folder and an id the user cannot edit (or a role without `edit_workflows`). Nothing moved."
          },
          "404": {
            "description": "NOT_FOUND — no such folder, or (your own folders) an id the user cannot see. Nothing moved."
          }
        }
      }
    },
    "/keys": {
      "get": {
        "x-required-scope": null,
        "x-auth": "session",
        "x-scope-note": "Available only from the Intuidy web app while signed in. API keys and OAuth access tokens cannot call it.",
        "summary": "List API keys",
        "description": "Returns all API keys for the authenticated user.\n\nManaged via the Intuidy web interface (session-authenticated).\n**Not reachable with a Bearer API key.**\n",
        "operationId": "listApiKeys",
        "tags": [
          "API Keys"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "API key list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "keys": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "name": {
                            "type": "string"
                          },
                          "prefix": {
                            "type": "string",
                            "description": "First 8 characters of the key for identification"
                          },
                          "scopes": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "scope_level": {
                            "type": "string",
                            "enum": [
                              "user",
                              "client"
                            ]
                          },
                          "created": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "last_used": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "key",
                              "oauth"
                            ],
                            "description": "\"key\" is a pasted key; \"oauth\" is a grant an MCP client got through OAuth sign-in"
                          },
                          "sensitive_read": {
                            "type": "boolean",
                            "nullable": true
                          },
                          "sensitive_write": {
                            "type": "boolean",
                            "nullable": true
                          },
                          "expires_at": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "x-required-scope": null,
        "x-auth": "session",
        "x-scope-note": "Available only from the Intuidy web app while signed in. API keys and OAuth access tokens cannot call it.",
        "summary": "Create an API key",
        "description": "Create a new API key with specified scopes.\nThe full key value is only returned once in the response — store it securely.\n\nManaged via the Intuidy web interface (session-authenticated).\n**Not reachable with a Bearer API key.** Creating a `client`-level\n(organization-wide) key requires an administrator role.\n",
        "operationId": "createApiKey",
        "tags": [
          "API Keys"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Human-readable key name"
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "workflows:read",
                        "workflows:write",
                        "workflows:execute",
                        "templates:read",
                        "templates:write",
                        "ontology:read",
                        "ontology:write",
                        "policies:read",
                        "policies:write",
                        "agents:read",
                        "agents:write",
                        "agents:execute",
                        "users:read",
                        "users:write",
                        "approvals:read",
                        "approvals:write",
                        "notebooks:read",
                        "notebooks:write",
                        "dashboards:read",
                        "dashboards:write",
                        "databases:read",
                        "databases:write",
                        "knowledge:read",
                        "integrations:read",
                        "integrations:write",
                        "mcp",
                        "mcp:read",
                        "mcp:write"
                      ]
                    },
                    "description": "Permission scopes (default: [workflows:read])"
                  },
                  "scope_level": {
                    "type": "string",
                    "enum": [
                      "user",
                      "client"
                    ],
                    "default": "user",
                    "description": "\"user\" for personal access, \"client\" for admin/org-wide access"
                  },
                  "sensitive_read": {
                    "type": "boolean",
                    "nullable": true,
                    "description": "Whether this key may read items marked sensitive (Settings → Data Sensitivity). false blocks it for this key even where the owner's role allows it; true or null never widen past the role. null = not set."
                  },
                  "sensitive_write": {
                    "type": "boolean",
                    "nullable": true,
                    "description": "The same switch for writing to items marked sensitive."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "API key created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string",
                      "description": "Full API key (only shown once). Starts with vntg_"
                    },
                    "id": {
                      "type": "integer"
                    },
                    "name": {
                      "type": "string"
                    },
                    "prefix": {
                      "type": "string"
                    },
                    "scopes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/keys/{keyId}": {
      "parameters": [
        {
          "name": "keyId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "patch": {
        "x-required-scope": null,
        "x-auth": "session",
        "x-scope-note": "Available only from the Intuidy web app while signed in. API keys and OAuth access tokens cannot call it.",
        "summary": "Update an API key",
        "description": "Update the name or scopes of an existing API key.\n\nManaged via the Intuidy web interface (session-authenticated).\n**Not reachable with a Bearer API key.**\n",
        "operationId": "updateApiKey",
        "tags": [
          "API Keys"
        ],
        "security": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true,
                    "description": "ISO 8601 expiry in the future; null clears it. Same rule as key creation."
                  },
                  "sensitive_read": {
                    "type": "boolean",
                    "nullable": true,
                    "description": "Whether this key may read items marked sensitive (Settings → Data Sensitivity). false blocks it for this key even where the owner's role allows it; true or null never widen past the role. null = not set."
                  },
                  "sensitive_write": {
                    "type": "boolean",
                    "nullable": true,
                    "description": "The same switch for writing to items marked sensitive."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "API key updated"
          },
          "400": {
            "description": "Body is not an object, a scope is unknown, or expires_at is malformed or not in the future"
          },
          "403": {
            "description": "Company-wide (client-scoped) keys can only be modified by an administrator; user-scoped keys only by their owner"
          },
          "404": {
            "description": "Key not found, revoked, or not in the caller's company"
          }
        }
      },
      "delete": {
        "x-required-scope": null,
        "x-auth": "session",
        "x-scope-note": "Available only from the Intuidy web app while signed in. API keys and OAuth access tokens cannot call it.",
        "summary": "Revoke an API key",
        "description": "Permanently revokes an API key. This action cannot be undone.\n\nManaged via the Intuidy web interface (session-authenticated).\n**Not reachable with a Bearer API key.**\n",
        "operationId": "deleteApiKey",
        "tags": [
          "API Keys"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "API key revoked"
          },
          "403": {
            "description": "Company-wide (client-scoped) keys can only be revoked by an administrator"
          },
          "404": {
            "description": "Key not found"
          }
        }
      }
    },
    "/ontology/objects": {
      "get": {
        "x-required-scope": "ontology:read",
        "x-auth": "key",
        "summary": "List ontology objects",
        "description": "The tenant's semantic layer: apps, managed-database tables, tenant workflow tables, integration entities and workflow output datasets, with whatever business meaning has been curated for them.\n",
        "operationId": "listOntologyObjects",
        "tags": [
          "Ontology"
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Free-text filter over keys, labels, descriptions and field names",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "needs",
                "review",
                "verified"
              ],
              "default": "all"
            }
          },
          {
            "name": "source",
            "in": "query",
            "description": "Filter by description provenance",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "inferred",
                "integration",
                "chat",
                "user"
              ],
              "default": "all"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "description": "Rejected with 400 if not one of these — an unrecognised kind would otherwise return an empty page that reads as \"you have none\".",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "app",
                "managed-db",
                "integration",
                "workflow-output",
                "tenant-db"
              ],
              "default": "all"
            }
          },
          {
            "name": "include_hidden",
            "in": "query",
            "description": "Include entries a curator has hidden",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 25,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Object list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "objects": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/OntologyObjectRow"
                          }
                        },
                        "page": {
                          "$ref": "#/components/schemas/Page"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unrecognised status or source"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `ontology:read`"
          }
        }
      }
    },
    "/ontology/objects/{key}": {
      "parameters": [
        {
          "name": "key",
          "in": "path",
          "required": true,
          "description": "Registry key, e.g. `app::deals` or `managed-db:3:orders`. Keys contain no slashes or reserved characters, and `:` is legal in a path segment, so it may be sent raw or percent-encoded.\n",
          "schema": {
            "type": "string"
          },
          "example": "managed-db:3:orders"
        }
      ],
      "get": {
        "x-required-scope": "ontology:read",
        "x-auth": "key",
        "summary": "Describe one object",
        "description": "Curated meaning merged over the live schema, with joins and per-field detail.",
        "operationId": "getOntologyObject",
        "tags": [
          "Ontology"
        ],
        "responses": {
          "200": {
            "description": "Object detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/OntologyObject"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_OBJECT_KEY"
          },
          "404": {
            "description": "OBJECT_NOT_FOUND. The error object carries `didYouMean` (closest matching keys) and `knownKeys`, so a near miss self-corrects.\n"
          }
        }
      },
      "patch": {
        "x-required-scope": "ontology:write",
        "x-auth": "key",
        "summary": "Describe an object and/or set its curation flags",
        "description": "Descriptive fields and `flags` are applied as ONE atomic batch: an unrecognised classification tag or sensitivity level rejects the whole request rather than half-applying it.\nPROVENANCE: an API key writes at `user` rank, the highest, so its text outranks inference and chat capture. Requests arriving from an in-product agent write at `chat` rank instead, and cannot overwrite what a person typed.\nGOVERNANCE MARKINGS ARE RANK-GUARDED SEPARATELY. `flags.sensitivity` and `flags.classifications` (and their per-field twins) may be changed or cleared only by a writer at or above the rank that last set them. A lower-ranked writer may ADD a classification tag but never remove one, and may fill an empty sensitivity slot but never downgrade a marking — a tag that silently disappears leaves every rule gating on it looking armed while matching nothing.\n",
        "operationId": "updateOntologyObject",
        "tags": [
          "Ontology"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string",
                    "description": "Empty string clears it (only `user` rank may clear)"
                  },
                  "grain": {
                    "type": "string"
                  },
                  "refreshCadence": {
                    "type": "string"
                  },
                  "primaryKey": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "aliases": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "links": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "fieldDescriptions": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "fieldValues": {
                    "type": "object",
                    "description": "REPLACES a field's whole value list — resend siblings or they are dropped"
                  },
                  "fieldSensitivity": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "fieldClassifications": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "flags": {
                    "type": "object",
                    "properties": {
                      "hidden": {
                        "type": "boolean"
                      },
                      "includeInPrompt": {
                        "type": "boolean"
                      },
                      "sensitivity": {
                        "type": "string",
                        "enum": [
                          "public",
                          "internal",
                          "financial",
                          "pii"
                        ]
                      },
                      "classifications": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "noSample": {
                        "type": "boolean",
                        "description": "Exclude this object from deep-scan row profiling"
                      },
                      "verified": {
                        "type": "boolean"
                      },
                      "ownerUserId": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/RegistryOpResult"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid key, or nothing to update"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE, or FORBIDDEN when the key's owner lacks `manage_ai_org_snippets`"
          },
          "409": {
            "description": "CONFLICT — the registry changed under you; re-read and retry"
          },
          "422": {
            "description": "UNPROCESSABLE — an unrecognised classification tag or flag value"
          }
        }
      },
      "delete": {
        "x-required-scope": "ontology:write",
        "x-auth": "key",
        "summary": "Remove an object's curated entry",
        "description": "Removes CURATION only. A still-connected source surfaces the object again on the next discovery scan, undescribed.\n",
        "operationId": "deleteOntologyObject",
        "tags": [
          "Ontology"
        ],
        "responses": {
          "200": {
            "description": "Removed"
          },
          "403": {
            "description": "Missing scope or permission"
          }
        }
      }
    },
    "/ontology/glossary": {
      "get": {
        "x-required-scope": "ontology:read",
        "x-auth": "key",
        "summary": "Search the business glossary",
        "description": "Terms are addressed by the `term` query parameter rather than a path segment: they are user-authored free text and routinely contain `/` and `%`.\n",
        "operationId": "listGlossaryTerms",
        "tags": [
          "Ontology"
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Free-text search across terms, aliases, definitions and calculations",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "term",
            "in": "query",
            "description": "Exact term (case-insensitive) — the single-item door",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "metric",
                "entity",
                "process",
                "acronym"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "approved",
                "deprecated"
              ]
            }
          },
          {
            "name": "include_hidden",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 25,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Glossary terms",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "terms": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/GlossaryTerm"
                          }
                        },
                        "page": {
                          "$ref": "#/components/schemas/Page"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unrecognised category or status"
          }
        }
      },
      "put": {
        "x-required-scope": "ontology:write",
        "x-auth": "key",
        "summary": "Define or update a business term",
        "operationId": "defineGlossaryTerm",
        "tags": [
          "Ontology"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "term"
                ],
                "properties": {
                  "term": {
                    "type": "string"
                  },
                  "definition": {
                    "type": "string",
                    "description": "Empty string clears it (only `user` rank may clear)"
                  },
                  "calculation": {
                    "type": "string"
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "metric",
                      "entity",
                      "process",
                      "acronym"
                    ]
                  },
                  "aliases": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "relatedObjects": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "examples": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "notToBeConfusedWith": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "flags": {
                    "type": "object",
                    "properties": {
                      "hidden": {
                        "type": "boolean"
                      },
                      "status": {
                        "type": "string",
                        "enum": [
                          "draft",
                          "approved",
                          "deprecated"
                        ]
                      },
                      "supersededBy": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied"
          },
          "400": {
            "description": "`term` is required"
          },
          "403": {
            "description": "Missing scope or permission"
          },
          "422": {
            "description": "Unrecognised category or status"
          }
        }
      },
      "delete": {
        "x-required-scope": "ontology:write",
        "x-auth": "key",
        "summary": "Remove a business term",
        "operationId": "deleteGlossaryTerm",
        "tags": [
          "Ontology"
        ],
        "parameters": [
          {
            "name": "term",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Removed"
          },
          "400": {
            "description": "`term` query parameter is required"
          },
          "403": {
            "description": "Missing scope or permission"
          }
        }
      }
    },
    "/ontology/ops": {
      "post": {
        "x-required-scope": "ontology:write",
        "x-auth": "key",
        "summary": "Batch ontology operations",
        "description": "The bulk door, for loading or migrating a semantic layer. Accepts either an op list or any single-action shape. ATOMIC: an unrecognised gating value rejects the whole batch. Maximum 200 operations per request.\n",
        "operationId": "applyOntologyOps",
        "tags": [
          "Ontology"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "ops"
                    ],
                    "properties": {
                      "ops": {
                        "type": "array",
                        "maxItems": 200,
                        "items": {
                          "type": "object",
                          "properties": {
                            "op": {
                              "type": "string",
                              "enum": [
                                "updateObject",
                                "defineTerm",
                                "removeObject",
                                "removeTerm",
                                "setObjectFlags",
                                "setTermFlags"
                              ]
                            },
                            "key": {
                              "type": "string"
                            },
                            "term": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "updateObject",
                          "defineTerm",
                          "bulk",
                          "removeObject",
                          "removeTerm",
                          "setObjectFlags",
                          "setTermFlags"
                        ]
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/RegistryOpResult"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Empty, unknown, or oversized op list"
          },
          "403": {
            "description": "Missing scope or permission"
          },
          "409": {
            "description": "Concurrent modification"
          },
          "422": {
            "description": "An unrecognised gating value — nothing was applied"
          }
        }
      }
    },
    "/ontology/discovery": {
      "get": {
        "x-required-scope": "ontology:read",
        "x-auth": "key",
        "summary": "Read the discovered-objects catalog",
        "description": "Serves the CACHED catalog (6h TTL) and never forces a rebuild — a scan opens live connections to the tenant's databases, so it lives behind POST /ontology/discovery/refresh.\n",
        "operationId": "getDiscoveryCatalog",
        "tags": [
          "Ontology"
        ],
        "responses": {
          "200": {
            "description": "Catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "objects": {
                          "type": "object"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "generated_at": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/ontology/discovery/refresh": {
      "post": {
        "x-required-scope": "ontology:write",
        "x-auth": "key",
        "summary": "Re-introspect the tenant's live data sources",
        "description": "Side-effecting and billed. `deep: true` additionally profiles column VALUES, reading real rows — it is throttled harder, counts against both windows, and honours the `noSample` / `pii` exclusions the registry flags declare. Throttle buckets are shared with the Ontology UI, so a tenant gets the advertised ceiling once, not once per door.\n",
        "operationId": "refreshDiscovery",
        "tags": [
          "Ontology"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deep": {
                    "type": "boolean",
                    "default": false
                  },
                  "include_catalog": {
                    "type": "boolean",
                    "default": false,
                    "description": "Return the full catalog as well as the counts"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scan complete",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "deep": {
                          "type": "boolean"
                        },
                        "objects": {
                          "type": "integer"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "generated_at": {
                          "type": "string"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Missing scope or permission"
          },
          "429": {
            "description": "RATE_LIMITED — 4 refreshes / 15 min, 2 deep scans / 30 min, per tenant across all doors"
          }
        }
      }
    },
    "/ontology/infer": {
      "post": {
        "x-required-scope": "ontology:write",
        "x-auth": "key",
        "summary": "Draft object descriptions and glossary terms with AI",
        "description": "COSTS CREDITS. Two-phase: send `dryRun: true` to get proposed operations without persisting, then POST the approved subset back as `ops` to apply them. Everything lands at `inferred` rank with no user attribution, so a draft can never outrank text a person wrote. Only the DRAFTING phase counts against the enrichment throttle — an accept round-trip must not burn budget the caller already spent producing the drafts.\n",
        "operationId": "inferOntology",
        "tags": [
          "Ontology"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scope": {
                    "type": "string",
                    "enum": [
                      "objects",
                      "glossary",
                      "all"
                    ],
                    "default": "all"
                  },
                  "keys": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "type": "string"
                    },
                    "description": "Limit enrichment to these objects"
                  },
                  "includeSamples": {
                    "type": "boolean",
                    "default": false,
                    "description": "Opt-in. Reads a few real rows to feed the model, honouring the registry's noSample/pii exclusions.\n"
                  },
                  "dryRun": {
                    "type": "boolean",
                    "default": false
                  },
                  "ops": {
                    "type": "array",
                    "description": "Approved drafts from a previous dry run. Only `updateObject` and `defineTerm` are accepted here.\n",
                    "items": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Drafted or applied",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dryRun": {
                          "type": "boolean"
                        },
                        "ops": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "applied": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "skipped": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "draftedObjects": {
                          "type": "integer"
                        },
                        "draftedTerms": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Missing scope or permission"
          },
          "422": {
            "description": "An op a dry run could not have produced"
          },
          "429": {
            "description": "RATE_LIMITED — 5 enrichment runs / 15 min per tenant across all doors"
          }
        }
      }
    },
    "/ontology/business-profile": {
      "get": {
        "x-required-scope": "ontology:read",
        "x-auth": "key",
        "summary": "Read the business profile",
        "description": "The third half of the tenant semantic layer alongside objects and the glossary: who the company is, what it sells, its customers, KPIs and terminology. Returns the profile document with per-field provenance, the field registry (render or validate field keys without hardcoding them), and the fields still unknown.\n",
        "operationId": "getBusinessProfile",
        "tags": [
          "Ontology"
        ],
        "responses": {
          "200": {
            "description": "Profile document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/BusinessProfile"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `ontology:read`"
          }
        }
      },
      "put": {
        "x-required-scope": "ontology:write",
        "x-auth": "key",
        "summary": "Update business profile fields",
        "description": "Merges `fields` into the stored profile under source-rank rules. PROVENANCE: an API key writes at `user` rank, like an edit in the profile UI; requests arriving from an in-product agent write at `chat` rank and can never overwrite what a person typed. An empty-string value clears a field (user-rank writers only); unknown field keys are reported in `skipped`, never guessed at. The onboarding `confirm` stamp is deliberately not settable here — it is a human consent bit.\n",
        "operationId": "updateBusinessProfile",
        "tags": [
          "Ontology"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "fields"
                ],
                "properties": {
                  "fields": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    },
                    "description": "fieldKey → value, e.g. {\"industry\": \"Commercial HVAC\"}. Valid keys come from the GET response's fieldRegistry.\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Merge result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "profile": {
                          "$ref": "#/components/schemas/BusinessProfileDoc"
                        },
                        "applied": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "skipped": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "field": {
                                "type": "string"
                              },
                              "reason": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or malformed `fields`"
          },
          "403": {
            "description": "Missing scope or permission"
          }
        }
      }
    },
    "/policies": {
      "get": {
        "x-required-scope": "policies:read",
        "x-auth": "key",
        "summary": "Read the data-governance document",
        "operationId": "getDataPolicies",
        "tags": [
          "Data Governance"
        ],
        "parameters": [
          {
            "name": "include",
            "in": "query",
            "description": "Comma-separated. `usage` adds per-tag and per-detector reference counts (what makes a delete safe). `patterns` returns raw detector regexes and requires the editor permission — asking without it is a 403 rather than a silent downgrade, because a caller that believes it received patterns and did not would draw the wrong conclusion from an absence of matches.\n",
            "schema": {
              "type": "string",
              "example": "usage"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The policy document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "policy": {
                          "type": "object",
                          "properties": {
                            "rules": {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/PolicyRule"
                              }
                            },
                            "classifications": {
                              "type": "object",
                              "additionalProperties": {
                                "$ref": "#/components/schemas/PolicyClassification"
                              }
                            },
                            "detectors": {
                              "type": "object",
                              "additionalProperties": {
                                "$ref": "#/components/schemas/PolicyDetector"
                              }
                            }
                          }
                        },
                        "failingDetectors": {
                          "type": "array",
                          "description": "Detectors the engine gave up on — surfaced loudly rather than as rules that quietly stop matching",
                          "items": {
                            "type": "string"
                          }
                        },
                        "usage": {
                          "type": "object"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, or `include=patterns` without the editor permission"
          }
        }
      }
    },
    "/policies/rules": {
      "get": {
        "x-required-scope": "policies:read",
        "x-auth": "key",
        "summary": "List governance rules",
        "operationId": "listPolicyRules",
        "tags": [
          "Data Governance"
        ],
        "parameters": [
          {
            "name": "enabled",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "ai",
                "external",
                "export",
                "internal"
              ]
            }
          },
          {
            "name": "action",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "redact",
                "require_approval",
                "block"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "rules": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/PolicyRule"
                          }
                        },
                        "total": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unrecognised channel or action"
          }
        }
      }
    },
    "/policies/rules/{ruleId}": {
      "parameters": [
        {
          "name": "ruleId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$"
          }
        }
      ],
      "get": {
        "x-required-scope": "policies:read",
        "x-auth": "key",
        "summary": "Get one rule",
        "operationId": "getPolicyRule",
        "tags": [
          "Data Governance"
        ],
        "responses": {
          "200": {
            "description": "The rule",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "rule": {
                          "$ref": "#/components/schemas/PolicyRule"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such rule"
          }
        }
      },
      "put": {
        "x-required-scope": "policies:write",
        "x-auth": "key",
        "summary": "Create or replace a rule",
        "description": "The id comes from the PATH. A body `id` that disagrees is a 400 rather than a silent pick — a governance rule written to the wrong id is a rule that silently is not enforcing what someone believes it is.\n",
        "operationId": "upsertPolicyRule",
        "tags": [
          "Data Governance"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PolicyRule"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied"
          },
          "400": {
            "description": "Invalid id, or a body id that disagrees with the path"
          },
          "403": {
            "description": "Missing scope or permission"
          },
          "422": {
            "description": "Unrecognised action, channel, or a reference to a tag/detector that does not exist"
          },
          "429": {
            "description": "RATE_LIMITED — 60 governance writes / 15 min per tenant across all doors"
          }
        }
      },
      "patch": {
        "x-required-scope": "policies:write",
        "x-auth": "key",
        "summary": "Arm or disarm a rule",
        "operationId": "setPolicyRuleEnabled",
        "tags": [
          "Data Governance"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "enabled"
                ],
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied"
          },
          "400": {
            "description": "Body must be `{ \"enabled\": true|false }`"
          },
          "403": {
            "description": "Missing scope or permission"
          }
        }
      },
      "delete": {
        "x-required-scope": "policies:write",
        "x-auth": "key",
        "summary": "Remove a rule",
        "operationId": "deletePolicyRule",
        "tags": [
          "Data Governance"
        ],
        "responses": {
          "200": {
            "description": "Removed"
          },
          "403": {
            "description": "Missing scope or permission"
          },
          "422": {
            "description": "Still referenced"
          }
        }
      }
    },
    "/policies/classifications": {
      "get": {
        "x-required-scope": "policies:read",
        "x-auth": "key",
        "summary": "List classification tags",
        "description": "The join between the ontology and governance: a tag applied to a column in Objects & Glossary is what a rule here matches on.\n",
        "operationId": "listPolicyClassifications",
        "tags": [
          "Data Governance"
        ],
        "parameters": [
          {
            "name": "include",
            "in": "query",
            "description": "`usage` adds the rules, objects and fields using each tag",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tag catalog"
          }
        }
      }
    },
    "/policies/classifications/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$"
          }
        }
      ],
      "put": {
        "x-required-scope": "policies:write",
        "x-auth": "key",
        "summary": "Create or replace a classification tag",
        "operationId": "upsertPolicyClassification",
        "tags": [
          "Data Governance"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PolicyClassification"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied"
          },
          "403": {
            "description": "Missing scope or permission"
          }
        }
      },
      "delete": {
        "x-required-scope": "policies:write",
        "x-auth": "key",
        "summary": "Remove a classification tag",
        "operationId": "deletePolicyClassification",
        "tags": [
          "Data Governance"
        ],
        "responses": {
          "200": {
            "description": "Removed"
          },
          "422": {
            "description": "Still referenced by a rule. Refused because a tag that vanishes from under a block rule is a silent unlock — the rule keeps looking armed while matching nothing.\n"
          }
        }
      }
    },
    "/policies/detectors": {
      "get": {
        "x-required-scope": "policies:read",
        "x-auth": "key",
        "summary": "List detectors",
        "operationId": "listPolicyDetectors",
        "tags": [
          "Data Governance"
        ],
        "parameters": [
          {
            "name": "include",
            "in": "query",
            "description": "`patterns` returns raw regexes and requires the editor permission. `usage` adds the rules referencing each detector.\n",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Detector catalog"
          },
          "403": {
            "description": "`include=patterns` without the editor permission"
          }
        }
      }
    },
    "/policies/detectors/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$"
          }
        }
      ],
      "put": {
        "x-required-scope": "policies:write",
        "x-auth": "key",
        "summary": "Create or replace a detector",
        "description": "A `regex` detector's pattern is validated before storage — length cap, allowed flags, and a structural scan for catastrophic backtracking, inside a time budget. An unsafe pattern is a 422, never a stored regex that later eats the evaluation budget on live traffic.\n",
        "operationId": "upsertPolicyDetector",
        "tags": [
          "Data Governance"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PolicyDetector"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied"
          },
          "422": {
            "description": "Unrecognised kind, or an invalid/unsafe pattern"
          }
        }
      },
      "delete": {
        "x-required-scope": "policies:write",
        "x-auth": "key",
        "summary": "Remove a detector",
        "operationId": "deletePolicyDetector",
        "tags": [
          "Data Governance"
        ],
        "responses": {
          "200": {
            "description": "Removed"
          },
          "422": {
            "description": "Still referenced by a rule"
          }
        }
      }
    },
    "/policies/ops": {
      "post": {
        "x-required-scope": "policies:write",
        "x-auth": "key",
        "summary": "Batch governance operations",
        "description": "Accepts an op list or any single-action shape. ATOMIC: an unrecognised action, channel or detector kind, an unsafe regex, or a delete of something still referenced rejects the WHOLE batch. A half-applied governance change leaves rules that look armed but no longer match.\n",
        "operationId": "applyPolicyOps",
        "tags": [
          "Data Governance"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "ops"
                    ],
                    "properties": {
                      "ops": {
                        "type": "array",
                        "maxItems": 200,
                        "items": {
                          "type": "object"
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "bulk",
                          "upsertRule",
                          "setRuleEnabled",
                          "removeRule",
                          "upsertClassification",
                          "removeClassification",
                          "upsertDetector",
                          "removeDetector",
                          "enableRecommendedPack",
                          "restoreRecommended"
                        ]
                      },
                      "create": {
                        "type": "boolean",
                        "description": "For upsertRule / upsertClassification / upsertDetector: declare create intent. When true and the id already exists the batch is rejected (422, already-exists) instead of merging over the existing entry — the guard that keeps a new \"Email\" detector or \"hipaa\" classification from silently replacing a built-in. Omit (or false) to edit an existing entry.\n"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied"
          },
          "400": {
            "description": "Unknown action or empty/oversized op list"
          },
          "403": {
            "description": "Missing scope or permission"
          },
          "422": {
            "description": "An unrecognised gating value — nothing was applied"
          }
        }
      }
    },
    "/policies/recommended": {
      "get": {
        "x-required-scope": "policies:read",
        "x-auth": "key",
        "summary": "Preview what installing the recommended pack would do",
        "description": "The recommended rules are already seeded into every tenant, all disabled, so installing the pack means \"enable the ones still off\". This lists exactly which rules those are — with their action, channels and matchers — before anything fires. Call it before the POST: these rules block and redact live traffic the moment they are enabled. Detector patterns are redacted.\n",
        "operationId": "previewRecommendedPolicies",
        "tags": [
          "Data Governance"
        ],
        "responses": {
          "200": {
            "description": "The rules the POST would arm, plus those already enabled"
          },
          "403": {
            "description": "Missing scope or permission"
          }
        }
      },
      "post": {
        "x-required-scope": "policies:write",
        "x-auth": "key",
        "summary": "Install the recommended starter pack",
        "description": "Adds the standard tags, detectors and rules most tenants want. Idempotent: it only adds what is missing, so re-running never resurrects something a curator deleted or re-arms something they turned off.\n",
        "operationId": "enableRecommendedPolicies",
        "tags": [
          "Data Governance"
        ],
        "responses": {
          "200": {
            "description": "Applied"
          },
          "403": {
            "description": "Missing scope or permission"
          }
        }
      }
    },
    "/policies/knowledge-approval": {
      "get": {
        "x-required-scope": "policies:read",
        "x-auth": "key",
        "summary": "Read which AI-learned facts skip the review queue",
        "description": "Facts a model extracts from conversations land in the knowledge base as Pending by default and are never sent to agents until a person approves them. This returns the tenant's approval policy: which categories (if any) auto-approve high-confidence facts, and whether onboarding-interview answers are approved immediately. Typed and imported entries are always approved.\n",
        "operationId": "getKnowledgeApprovalPolicy",
        "tags": [
          "Data Governance"
        ],
        "responses": {
          "200": {
            "description": "The policy, a one-line summary, and the category registry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "policy": {
                      "type": "object",
                      "properties": {
                        "autoApprove": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "boolean"
                          },
                          "description": "Per category — auto-approve HIGH-confidence extracted facts"
                        },
                        "interviewAnswers": {
                          "type": "boolean",
                          "description": "Store onboarding-interview answers as approved"
                        }
                      }
                    },
                    "summary": {
                      "type": "string"
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Missing scope"
          }
        }
      },
      "put": {
        "x-required-scope": "policies:write",
        "x-auth": "key",
        "summary": "Change which AI-learned facts skip the review queue",
        "description": "Merges a partial update into the policy. Non-boolean values are ignored and unknown categories dropped. Requires `policies:write` and the key owner's org AI-context permission (the rule governs org-wide agent context).\n",
        "operationId": "updateKnowledgeApprovalPolicy",
        "tags": [
          "Data Governance"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "autoApprove": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "boolean"
                    }
                  },
                  "interviewAnswers": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated policy"
          },
          "400": {
            "description": "Invalid body"
          },
          "403": {
            "description": "Missing scope or permission"
          }
        }
      },
      "post": {
        "x-required-scope": "policies:write",
        "x-auth": "key",
        "summary": "Sweep previously auto-approved facts back into the review queue",
        "description": "The remediation that goes with tightening the approval policy: facts the OLD policy auto-approved are moved back to Pending so a person reviews them. `scope` is `all` (default), `org` (shared facts only) or `personal` (the key owner's). Same hallway as the web door's requeue.\n",
        "operationId": "requeueAutoApprovedFacts",
        "tags": [
          "Data Governance"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "requeue"
                    ]
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "all",
                      "org",
                      "personal"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Counts of entries and snippets moved back to Pending",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "action": {
                      "type": "string"
                    },
                    "scope": {
                      "type": "string"
                    },
                    "requeued": {
                      "type": "integer"
                    },
                    "snippets": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Missing scope or permission"
          }
        }
      }
    },
    "/audit": {
      "get": {
        "x-required-scope": "policies:read",
        "x-auth": "key",
        "summary": "The unified audit trail for the key's company",
        "description": "One list across actors: user logins, agent tool calls (executed, denied, awaiting approval), workflow runs by trigger, API-key calls, saves and restores, agent-created assets, and files an HTML dashboard page handed a viewer (`source: files`, downloaded or opened). Each row carries `at`, `actorType` (user | agent | key | system), `actorLabel`, `action`, `assetType`/`assetId`/`assetLabel`, `outcome` and `source`, plus sharing and role changes (`source: access`). A row can carry `link`, an app page to open in a browser. Same rows as Settings → Logs; the platform-admin security-event slice is web-only.\n",
        "operationId": "getAuditTrail",
        "tags": [
          "Data Governance"
        ],
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 7,
              "maximum": 90
            }
          },
          {
            "name": "actor",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "user",
                "agent",
                "key",
                "system"
              ]
            }
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "login_history",
                "ledger",
                "usage",
                "aipi",
                "versions",
                "provenance",
                "files",
                "access"
              ]
            }
          },
          {
            "name": "outcome",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 500,
              "maximum": 5000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered, newest-first audit rows with per-source counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "days": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "returned": {
                      "type": "integer"
                    },
                    "sources": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "integer"
                      }
                    },
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "actorType": {
                            "type": "string"
                          },
                          "actorId": {
                            "type": "integer",
                            "nullable": true
                          },
                          "actorLabel": {
                            "type": "string"
                          },
                          "action": {
                            "type": "string"
                          },
                          "assetType": {
                            "type": "string",
                            "nullable": true
                          },
                          "assetId": {
                            "type": "integer",
                            "nullable": true
                          },
                          "assetLabel": {
                            "type": "string",
                            "nullable": true
                          },
                          "outcome": {
                            "type": "string"
                          },
                          "detail": {
                            "type": "string"
                          },
                          "source": {
                            "type": "string"
                          },
                          "link": {
                            "type": "object",
                            "nullable": true,
                            "description": "An app page to open in a browser while signed in; not an API URL",
                            "properties": {
                              "href": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Missing scope"
          }
        }
      }
    },
    "/policies/test": {
      "post": {
        "x-required-scope": "policies:read",
        "x-auth": "key",
        "summary": "Dry-run a payload against the rules",
        "description": "\"What would happen if I sent this?\" NOTHING IS PERSISTED, no model is called, and no ledger row is written — callers testing a PHI rule send real PHI. Requires the editor permission despite carrying only `policies:read`, because the response reveals which patterns trip which rules.\n",
        "operationId": "testDataPolicy",
        "tags": [
          "Data Governance"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "maxLength": 20000
                  },
                  "objectKey": {
                    "type": "string",
                    "description": "Evaluate as if the payload came from this object, picking up its tags"
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "ai",
                      "external",
                      "export",
                      "internal"
                    ],
                    "default": "ai"
                  },
                  "includeDisabled": {
                    "type": "boolean",
                    "default": false,
                    "description": "Evaluate unarmed rules too, to preview their effect before enabling"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verdict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/PolicyVerdict"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Provide `text`, `objectKey`, or both"
          },
          "403": {
            "description": "Missing scope or the editor permission"
          },
          "429": {
            "description": "RATE_LIMITED — 30 tests / 15 min per tenant across all doors"
          }
        }
      }
    },
    "/policies/activity": {
      "get": {
        "x-required-scope": "policies:read",
        "x-auth": "key",
        "summary": "The governance trail",
        "description": "Which rules actually fired, where, and what happened. Without it the feature is unfalsifiable — you cannot tell a rule that is protecting you from one that never matches anything. Only non-allow decisions are recorded, and entries carry rule and detector IDENTIFIERS and counts, never the matched values.\n",
        "operationId": "getPolicyActivity",
        "tags": [
          "Data Governance"
        ],
        "parameters": [
          {
            "name": "ruleId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "ai",
                "external",
                "export",
                "internal"
              ]
            }
          },
          {
            "name": "action",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "redact",
                "require_approval",
                "block"
              ]
            }
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 7,
              "maximum": 90
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Events",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "events": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/PolicyDecisionEvent"
                          }
                        },
                        "days": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unrecognised channel or action"
          },
          "403": {
            "description": "Missing scope or the editor permission"
          }
        }
      }
    },
    "/templates": {
      "get": {
        "x-required-scope": "templates:read",
        "x-auth": "key",
        "summary": "Browse the solution-template catalog",
        "description": "Prebuilt bundles of workflows, notebooks, dashboards, agents, skills and\nmanaged databases. Each template carries `databaseCount`: the number of\nmanaged databases its install provisions. An install of a template with a\n`databaseCount` above zero is billed and needs `databases:write` (see the\ninstall operation); get the template for the names and the cost first.\n",
        "operationId": "listTemplates",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "featured",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Template catalog"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `templates:read`"
          }
        }
      }
    },
    "/templates/{slug}": {
      "parameters": [
        {
          "name": "slug",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "x-required-scope": "templates:read",
        "x-auth": "key",
        "summary": "Get one template",
        "description": "Inactive templates return 404 — there is no admin bypass on this door. For a template that provisions a managed database the detail carries `databases` (one entry per database: `ref`, engine, `extensions` it is created with such as PostGIS, tables, seed rows and `defaultName`, the name it will get), `installCredits` (the one-time charge of the install) and `canProvisionDatabases` (whether the key owner holds `manage_databases`).\n",
        "operationId": "getTemplate",
        "tags": [
          "Templates"
        ],
        "responses": {
          "200": {
            "description": "Template detail"
          },
          "404": {
            "description": "Not found or inactive"
          }
        }
      }
    },
    "/templates/{slug}/cover": {
      "parameters": [
        {
          "name": "slug",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "x-required-scope": "templates:read",
        "x-auth": "key",
        "summary": "Template cover image",
        "description": "The API-key twin of the session-authed cover route.",
        "operationId": "getTemplateCover",
        "tags": [
          "Templates"
        ],
        "responses": {
          "200": {
            "description": "Image bytes",
            "content": {
              "image/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/templates/{slug}/install": {
      "parameters": [
        {
          "name": "slug",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "x-required-scope": "templates:write",
        "x-auth": "key",
        "summary": "Install a template into the tenant",
        "description": "Creates the bundle's workflows, dashboards, notebooks, agents and skills. A template whose detail lists `databases` also PROVISIONS a managed database as the key owner, applies its tables and loads its seed rows — billed like a manual create (provision fee, one database_query per DDL statement, one managed_db_import per seeded table; the whole bill is checked before anything is created). Such a template additionally needs the `databases:write` scope on the key and the `manage_databases` permission on its owner. The scope must be named on the key: a blanket `mcp` scope does not carry it, here or on an upgrade that provisions or an uninstall that deletes a database. A database name already in use in the company gets a \" (2)\" suffix.\n",
        "operationId": "installTemplate",
        "tags": [
          "Templates"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connections": {
                    "type": "object",
                    "description": "Account binding `{ serviceKey: credentialId }` for multi-account services",
                    "additionalProperties": {
                      "type": "integer"
                    }
                  },
                  "databases": {
                    "type": "object",
                    "description": "Names for the databases the template provisions, by ref from the detail: `{ \"md1\": { \"name\": \"Inventory EU\" } }`",
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Installed"
          },
          "402": {
            "description": "BILLING_REQUIRED — the company cannot afford the database the template provisions"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `templates:write`; SCOPE_REQUIRED — the template provisions a database and the key lacks `databases:write`; PERMISSION_DENIED — the key owner lacks `manage_databases`"
          },
          "409": {
            "description": "ALREADY_INSTALLED"
          }
        }
      }
    },
    "/templates/{slug}/uninstall": {
      "parameters": [
        {
          "name": "slug",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "x-required-scope": "templates:write",
        "x-auth": "key",
        "summary": "Uninstall a template",
        "description": "Removes everything the install created, tenant-fenced, then the\ninstall record. All or nothing: a member who may not delete every\nasset (a colleague's workflow, for example) is refused with 403, the\nerror names those assets, and nothing is removed.\nA database the install provisioned is KEPT with its data unless\n`databases` is `deprovision`, which soft-deletes it with a 7-day grace\n(needs `databases:write` on the key and `manage_databases` on its owner).\n",
        "operationId": "uninstallTemplate",
        "tags": [
          "Templates"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "databases": {
                    "type": "string",
                    "enum": [
                      "keep",
                      "deprovision"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Uninstalled — `removed`, `kept` (databases left in place) and `warnings`"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`templates:write` missing), SCOPE_REQUIRED (`databases` is `deprovision` and the key lacks `databases:write`), or FORBIDDEN — the key's user may not delete one or more of the installed assets (the message names them), or lacks `manage_databases` for `deprovision`. Nothing was removed and the template stays installed."
          }
        }
      }
    },
    "/templates/{slug}/upgrade": {
      "parameters": [
        {
          "name": "slug",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "x-required-scope": "templates:read",
        "x-auth": "key",
        "summary": "Preview an upgrade",
        "description": "Reports, per asset, whether it is clean (untouched since install) or dirty (locally modified) so the caller can choose what to do with each. A database asset also carries `choices` (`keep`, `apply`) and `delta`: the tables and columns `apply` would add to the live database, in `addIndexes` the declared indexes its existing tables lack (null when they could not be read), and in `enableExtensions` the extensions (PostGIS, for example) it would enable first. Its status is `unreadable`, with a `reason`, when the database exists and could not be read (suspended, for example); such a database can only be kept. `upgradeCredits` is what provisioning any database new in the version, or deleted since install, would cost.\n",
        "operationId": "previewTemplateUpgrade",
        "tags": [
          "Templates"
        ],
        "responses": {
          "200": {
            "description": "Upgrade preview"
          }
        }
      },
      "post": {
        "x-required-scope": "templates:write",
        "x-auth": "key",
        "summary": "Apply an upgrade",
        "operationId": "applyTemplateUpgrade",
        "tags": [
          "Templates"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "choices": {
                    "type": "object",
                    "description": "Per-asset ref → `replace` | `keep` | `copy`; a database ref takes `keep` | `apply` (add the new version's tables and columns — never drop, rename or retype) and defaults to `apply`",
                    "additionalProperties": {
                      "type": "string",
                      "enum": [
                        "replace",
                        "keep",
                        "copy",
                        "apply"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upgraded"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `templates:write`; SCOPE_REQUIRED — the upgrade provisions a database and the key lacks `databases:write`"
          },
          "409": {
            "description": "TEMPLATE_ERROR — `apply` would enable an extension in an installed database (`delta.enableExtensions` in the preview). Extensions are enabled in the web app only: run the update there, or choose `keep` for that database. Nothing was changed."
          }
        }
      }
    },
    "/workflows/{workflowId}/runs": {
      "get": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "summary": "Run history for a workflow",
        "description": "Per run: `status` (success | failed), `trigger` (webhook | schedule | manual | preview | api | agent | subworkflow), `startedAt`, `durationMs`, `tokens`, `nodeCount`, and for failures the `error` and the `failedNode`. Assembled from the usage ledger (every run writes there) plus the scheduler log for ticks that failed before the engine started. Runs recorded before per-run tracking appear with `legacy: true`.\n",
        "operationId": "getWorkflowRuns",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 30,
              "maximum": 90
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "include_trace",
            "in": "query",
            "description": "Include each run's per-node row counts in `nodes[]`. Off by default because it is the largest part of a run record; every run reports `hasTrace` so a client knows whether asking is worthwhile.\n",
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "true"
              ]
            }
          },
          {
            "name": "run_id",
            "in": "query",
            "description": "Return only this run, with its per-node trace. The cheap way to inspect one run without pulling traces for the whole window.\n",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Newest-first runs with a window summary",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workflow": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "title": {
                          "type": "string"
                        },
                        "is_active": {
                          "type": "boolean"
                        }
                      }
                    },
                    "days": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "runs": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "trigger": {
                            "type": "string"
                          },
                          "startedAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "finishedAt": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          },
                          "durationMs": {
                            "type": "integer",
                            "nullable": true
                          },
                          "tokens": {
                            "type": "number"
                          },
                          "nodeCount": {
                            "type": "integer"
                          },
                          "error": {
                            "type": "string",
                            "nullable": true
                          },
                          "errorCode": {
                            "type": "string",
                            "nullable": true,
                            "description": "Stable identifier for the failure, e.g. SQL_UNRESOLVED_PLACEHOLDER"
                          },
                          "errorDetail": {
                            "type": "object",
                            "nullable": true,
                            "description": "Machine-readable particulars, e.g. {\"unresolved\": [\"cost_basis\"]}"
                          },
                          "hasTrace": {
                            "type": "boolean",
                            "description": "Whether this run recorded per-node row counts"
                          },
                          "nodes": {
                            "type": "array",
                            "nullable": true,
                            "description": "Per-node row accounting, present only with `include_trace` or `run_id`. `rowsIn`/`rowsOut` are summed across ports. `prunedPorts` lists wired ports that produced NO rows — an empty port is omitted from a node's output rather than reported as zero, so this is the only way to see a branch that received nothing.\n",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "type": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "label": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "ok",
                                    "failed"
                                  ]
                                },
                                "rowsIn": {
                                  "type": "integer"
                                },
                                "rowsOut": {
                                  "type": "integer"
                                },
                                "ms": {
                                  "type": "integer"
                                },
                                "ports": {
                                  "type": "object",
                                  "additionalProperties": {
                                    "type": "integer"
                                  }
                                },
                                "prunedPorts": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              }
                            }
                          },
                          "failedNode": {
                            "type": "object",
                            "nullable": true,
                            "properties": {
                              "id": {
                                "type": "string",
                                "nullable": true
                              },
                              "type": {
                                "type": "string",
                                "nullable": true
                              },
                              "label": {
                                "type": "string",
                                "nullable": true
                              }
                            }
                          }
                        }
                      }
                    },
                    "summary": {
                      "type": "object",
                      "properties": {
                        "runs": {
                          "type": "integer"
                        },
                        "failed": {
                          "type": "integer"
                        },
                        "tokens": {
                          "type": "number"
                        },
                        "successRate": {
                          "type": "integer",
                          "nullable": true
                        },
                        "lastRunAt": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true
                        },
                        "lastStatus": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Workflow not found"
          }
        }
      }
    },
    "/workflows/{workflowId}/deliveries": {
      "get": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "summary": "Webhook deliveries and trigger subscription health",
        "description": "What reached the workflow's webhook and what became of each delivery, newest first: `outcome`, `reason`, `httpStatus`, the source address, and the `runId` of the run it started (read that run with `GET /workflows/{workflowId}/runs?run_id=`). A delivery is recorded only after the sender proved it may reach the workflow (the URL token, or Microsoft Graph's `clientState`); a bad token writes nothing. Never a body or a query string; signatures, tokens and other secret headers are never kept, the content type and the sender's delivery id are. `deliveryId` is shown only for a preset whose id is safe to show (GitHub, Telegram). Rows are kept 30 days, at most 100,000 per workflow.\n\n`subscriptions` lists the health of each managed Microsoft 365 trigger: `active`, `expiring`, `expired`, `renewal_failing`, or `not_created` with a kind (for example `auth` or `no_public_url`). Read it after a save to confirm a subscription exists.\n\n`total` and `summary` cover the newest 10,000 deliveries of the window; `totalCapped` says the window holds more. `available: false` means the delivery log is not set up on this server yet (the list is then empty, and `subscriptions` is still reported).\n",
        "operationId": "getWorkflowDeliveries",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 7,
              "minimum": 1,
              "maximum": 30
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "outcome",
            "in": "query",
            "description": "Only deliveries with this outcome. A value outside the list is no filter.",
            "schema": {
              "$ref": "#/components/schemas/WebhookDeliveryOutcome"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Newest-first deliveries with a window summary and subscription health",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workflow": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "title": {
                          "type": "string"
                        },
                        "is_active": {
                          "type": "boolean"
                        }
                      }
                    },
                    "days": {
                      "type": "integer"
                    },
                    "outcome": {
                      "type": "string",
                      "nullable": true,
                      "description": "The outcome filter that was applied, or null"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "totalCapped": {
                      "type": "boolean"
                    },
                    "available": {
                      "type": "boolean",
                      "description": "False when the delivery log is not set up on this server yet"
                    },
                    "deliveries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookDelivery"
                      }
                    },
                    "summary": {
                      "type": "object",
                      "properties": {
                        "counts": {
                          "type": "object",
                          "description": "Deliveries per outcome, over the scanned rows",
                          "additionalProperties": {
                            "type": "integer"
                          }
                        },
                        "lastAcceptedAt": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true
                        },
                        "lastRefusedAt": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true
                        },
                        "capped": {
                          "type": "boolean"
                        }
                      }
                    },
                    "subscriptions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TriggerSubscriptionStatus"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid workflow id"
          },
          "404": {
            "description": "Workflow not found"
          }
        }
      }
    },
    "/workflows/{workflowId}/nodes/{nodeId}/execute": {
      "post": {
        "x-required-scope": "workflows:execute",
        "x-auth": "key",
        "summary": "Run one node against rows you supply",
        "description": "Execute a SINGLE node of a workflow and see exactly what it emits — per output port, with the ports that produced nothing named in `emptyPorts`. Replaces the usual ritual of assembling a throwaway workflow to isolate one node.\n\nThe node runs FOR REAL against live connections. Nodes that write or send are refused unless `allow_side_effects` is set, and the tenant's data governance rules apply exactly as they do in a full run.\n\nA node directly behind a For Each Executor runs once per supplied row, with that node's retry policy; QuickBooks writes post once per row when their settings read row columns.\n",
        "operationId": "executeWorkflowNode",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "nodeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "input_rows": {
                    "type": "array",
                    "maxItems": 100,
                    "description": "Rows fed to the node as input1",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  },
                  "config": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Config keys merged over the saved config, to try a change without saving it"
                  },
                  "allow_side_effects": {
                    "type": "boolean",
                    "default": false,
                    "description": "Required for nodes that write or send"
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Values for the node's `{{dash.name}}` tokens (and an inputs/variable node's names), flat — as the execute door takes them.\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What the node emitted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "node": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "integer"
                            },
                            "type": {
                              "type": "string"
                            },
                            "label": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        },
                        "ms": {
                          "type": "integer"
                        },
                        "rowsIn": {
                          "type": "integer"
                        },
                        "rowsOut": {
                          "type": "integer"
                        },
                        "ports": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "integer"
                          }
                        },
                        "emptyPorts": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "output": {
                          "type": "object",
                          "description": "The raw output envelope"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, or SIDE_EFFECTS_REFUSED for a node that writes or sends"
          },
          "404": {
            "description": "Workflow or node not found"
          },
          "422": {
            "description": "The node ran and refused — carries `code` and `detail`"
          }
        }
      }
    },
    "/assets/apply": {
      "post": {
        "x-required-scope": [
          "workflows:write",
          "dashboards:write"
        ],
        "x-auth": "key",
        "x-scope-by-type": {
          "workflow": "workflows:write",
          "dashboard": "dashboards:write"
        },
        "x-scope-note": "Notebooks are not available through the REST API; use the MCP server for notebook items.",
        "summary": "Write several assets' contents in one call",
        "description": "Replace workflow graphs, dashboard tiles and notebook cells for several existing assets at once — the one-call-per-asset loop is what turns a 50-asset spec into dozens of sequential round trips.\n\n**NOT ATOMIC.** Each asset type has its own save hallway with its own transaction, so items are applied in order and some may succeed while others fail. The response carries `atomic: false`, a per-item `status`, and a note naming the resumable retry: re-send only the items whose status is not `applied`. A partly-applied batch is a 200, not an error — the caller needs to see which items landed.\n\nUpdates only. Creating assets — with id allocation and cross-asset references — is what `/templates/{slug}/install` is for. Agents and skills are excluded: their writes carry lifecycle semantics that do not reduce to replacing content.\n\nPass `expected_hash` per item (from `content_hash` on a GET, or from `/assets/diff`) to be refused rather than overwrite a concurrent edit. For a workflow or a dashboard the check runs inside that asset's save hallway, under its row lock. A dashboard item is announced on the board's event stream as `tiles`, with the `X-Write-Origin` header when one is sent.\n",
        "operationId": "applyAssetContents",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assets"
                ],
                "properties": {
                  "stop_on_error": {
                    "type": "boolean",
                    "default": false,
                    "description": "Stop at the first item that does not apply — for specs where later items depend on earlier ones."
                  },
                  "assets": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 50,
                    "items": {
                      "type": "object",
                      "required": [
                        "type",
                        "id"
                      ],
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "workflow",
                            "dashboard",
                            "notebook"
                          ]
                        },
                        "id": {
                          "type": "integer",
                          "description": "Existing asset id — this endpoint updates, it does not create."
                        },
                        "expected_hash": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string",
                          "description": "workflow only"
                        },
                        "description": {
                          "type": "string",
                          "description": "workflow only"
                        },
                        "nodes": {
                          "type": "array",
                          "description": "workflow only — replaces the whole node list",
                          "items": {
                            "type": "object"
                          }
                        },
                        "edges": {
                          "type": "array",
                          "description": "workflow only — references nodes array indices",
                          "items": {
                            "type": "object"
                          }
                        },
                        "tiles": {
                          "type": "array",
                          "description": "dashboard only — replaces all tiles",
                          "items": {
                            "type": "object"
                          }
                        },
                        "cells": {
                          "type": "object",
                          "description": "notebook only — { sections, meta? }"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-item outcomes. Check each `status`; the batch may be partial.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "atomic": {
                          "type": "boolean",
                          "description": "Always false — stated in the payload, not only the docs."
                        },
                        "results": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string"
                              },
                              "id": {
                                "type": "integer"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "applied",
                                  "conflict",
                                  "not_found",
                                  "invalid",
                                  "forbidden",
                                  "failed"
                                ],
                                "description": "`forbidden` means retrying will never succeed — a view-only notebook, or a dashboard shared from another company.\n"
                              },
                              "message": {
                                "type": "string"
                              },
                              "content_hash": {
                                "type": "string",
                                "description": "The new hash, on an applied item — record it as the next baseline."
                              }
                            }
                          }
                        },
                        "summary": {
                          "type": "object"
                        },
                        "note": {
                          "type": "string"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or oversized `assets` array"
          }
        }
      }
    },
    "/assets/diff": {
      "post": {
        "x-required-scope": [
          "workflows:read",
          "dashboards:read",
          "agents:read",
          "mcp:read"
        ],
        "x-auth": "key",
        "x-scope-by-type": {
          "workflow": "workflows:read",
          "dashboard": "dashboards:read",
          "agent": "agents:read",
          "skill": "agents:read"
        },
        "x-scope-note": "Notebooks are not available through the REST API; use the MCP server for notebook items.",
        "summary": "Which of these assets have drifted from the hashes you hold?",
        "description": "Send `[{type, id, hash}]` and get back match / drifted / missing per item, with the live `content_hash`. Answers \"does live still match my spec?\" without pulling and comparing every asset.\n\nWithout it, external tooling managing Intuidy assets as code records ids but not versions, so \"already applied\" is the only available signal and the only reliable move is to force re-apply everything.\n\nOmit an item's `hash` to simply read the current one — how a spec file gets its first baseline. Pass a hash back as `expected_hash` on `/assets/apply` (or on the MCP write tools) to be refused rather than silently overwrite a concurrent edit.\n\nEach asset is fenced individually: one the key cannot read reports `missing` rather than leaking its fingerprint.\n",
        "operationId": "diffAssets",
        "tags": [
          "Templates"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assets"
                ],
                "properties": {
                  "assets": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 200,
                    "items": {
                      "type": "object",
                      "required": [
                        "type",
                        "id"
                      ],
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "workflow",
                            "dashboard",
                            "agent",
                            "skill"
                          ],
                          "description": "Notebooks are an MCP-only family and are refused here; use the `diff_assets` MCP tool for those.\n"
                        },
                        "id": {
                          "type": "integer"
                        },
                        "hash": {
                          "type": "string",
                          "description": "The content_hash you last recorded. Omit to read the current one."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One result per asset, plus a summary by status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "results": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string"
                              },
                              "id": {
                                "type": "integer"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "match",
                                  "drifted",
                                  "missing",
                                  "unknown",
                                  "invalid"
                                ],
                                "description": "`unknown` means no hash was supplied, so the live one is returned; `missing` means unreadable or absent; `invalid` means a malformed entry.\n"
                              },
                              "hash": {
                                "type": "string"
                              },
                              "expected": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "summary": {
                          "type": "object",
                          "description": "Counts by status, plus `total`"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or oversized `assets` array"
          }
        }
      }
    },
    "/assets/versions": {
      "get": {
        "x-required-scope": [
          "workflows:read",
          "dashboards:read"
        ],
        "x-auth": "key",
        "x-scope-by-type": {
          "workflow": "workflows:read",
          "dashboard": "dashboards:read"
        },
        "x-scope-note": "Notebooks are not available through the REST API; use the MCP server for notebook items.",
        "summary": "An asset's version history",
        "description": "Newest-first list of an asset's snapshots, without payloads. Answers \"what did this look like before someone changed it?\"\n\nA key consumer could already read and OVERWRITE a dashboard through `PATCH /dashboards/{dashboardId}`, but had no way to see its history or roll it back — so the surface able to do the damage was the one unable to undo it.\n\nListing follows the READ fence: what you can open, you can see the history of.\n",
        "operationId": "listAssetVersions",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "type",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "workflow",
                "dashboard"
              ]
            },
            "description": "Notebooks are an MCP-only family and are refused here; use the `list_notebook_versions` MCP tool for those.\n"
          },
          {
            "in": "query",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Newest-first snapshots for the asset",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string"
                        },
                        "id": {
                          "type": "integer"
                        },
                        "versions": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string",
                                "description": "Pass to /assets/versions/restore to roll back to this snapshot."
                              },
                              "savedAt": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "savedBy": {
                                "type": "integer",
                                "nullable": true
                              },
                              "reason": {
                                "type": "string",
                                "description": "What produced the snapshot — `save`, `pre-restore`, `batch`, `agent` or `node`.\n"
                              },
                              "hash": {
                                "type": "string"
                              },
                              "summary": {
                                "type": "object",
                                "description": "Per-type counts (nodes/edges, tiles/tabs)."
                              }
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or unsupported `type`/`id`"
          },
          "403": {
            "description": "The key lacks the read scope for that asset family"
          },
          "404": {
            "description": "No such asset, or not accessible"
          }
        }
      }
    },
    "/assets/versions/restore": {
      "post": {
        "x-required-scope": [
          "workflows:write",
          "dashboards:write"
        ],
        "x-auth": "key",
        "x-scope-by-type": {
          "workflow": "workflows:write",
          "dashboard": "dashboards:write"
        },
        "x-scope-note": "Notebooks are not available through the REST API; use the MCP server for notebook items.",
        "summary": "Roll an asset back to one of its snapshots",
        "description": "Replays a snapshot through the asset's OWN save hallway, after snapshotting the current state first — so a restore is itself undoable, and can never be a softer route to a write than the save door it replays through.\n\nRestoring is a WRITE and follows the save routes' fence, not the read one: a dashboard shared from another company is read-only here.\n\nA dashboard restore answers `content_hash_before` and `content_hash` (BoardHashChain) and is announced on the board's event stream as `tiles`, source `restore`.\n",
        "operationId": "restoreAssetVersion",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "type",
                  "id",
                  "key"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "workflow",
                      "dashboard"
                    ],
                    "description": "Notebooks are an MCP-only family and are refused here; use the `restore_notebook_version` MCP tool for those.\n"
                  },
                  "id": {
                    "type": "integer"
                  },
                  "key": {
                    "type": "string",
                    "description": "The version `key` from GET /assets/versions."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The snapshot was replayed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "restored": {
                          "type": "object",
                          "properties": {
                            "key": {
                              "type": "string"
                            },
                            "savedAt": {
                              "type": "string",
                              "format": "date-time"
                            }
                          }
                        },
                        "tileCount": {
                          "type": "integer"
                        },
                        "nodeCount": {
                          "type": "integer"
                        },
                        "content_hash_before": {
                          "type": "string",
                          "nullable": true,
                          "description": "Dashboard only. See BoardHashChain."
                        },
                        "content_hash": {
                          "type": "string",
                          "nullable": true,
                          "description": "Dashboard only. See BoardHashChain."
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing `type`/`id`/`key`, or the snapshot could not be replayed"
          },
          "403": {
            "description": "The key lacks the write scope, or the asset is read-only for this caller"
          },
          "404": {
            "description": "No such asset or version"
          }
        }
      }
    },
    "/expressions/evaluate": {
      "post": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "summary": "Try a workflow expression against a sample row",
        "description": "Evaluate one expression and get back the value — or exactly why it is refused, with the supported equivalent named (INSTR → INCLUDES, CAST → NUMBER/TEXT, CASE WHEN → nested IF). NOTHING IS PERSISTED and no tenant data is read: the `row` you send is the entire input.\n\nOmit `engine` to evaluate under BOTH engines. `queryoperators/computedColumn` and `math/expression` implement the same language independently and do not support the same functions — math/expression adds STARTSWITH, INCLUDES, SPLIT, CLAMP, SIGN, a ternary and more — so which node an expression belongs in is a real question this answers in one call.\n",
        "operationId": "evaluateWorkflowExpression",
        "tags": [
          "Workflows"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "expression"
                ],
                "properties": {
                  "expression": {
                    "type": "string",
                    "maxLength": 2000,
                    "example": "IF(qty > 10, price * 0.9, price)"
                  },
                  "row": {
                    "type": "object",
                    "description": "Sample row the expression may reference",
                    "additionalProperties": true,
                    "example": {
                      "qty": 12,
                      "price": 100
                    }
                  },
                  "engine": {
                    "type": "string",
                    "enum": [
                      "computedColumn",
                      "expression"
                    ],
                    "description": "Omit to evaluate under both"
                  },
                  "onUnknownRef": {
                    "type": "string",
                    "enum": [
                      "error",
                      "null"
                    ],
                    "default": "error",
                    "description": "Match a node configured with the legacy lenient policy, under which an unknown reference yields a value instead of failing.\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The result. A refused expression is a successful evaluation with a negative answer, not a transport error — `ok: false` carries the code and the fix.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "ok": {
                          "type": "boolean"
                        },
                        "engine": {
                          "type": "string"
                        },
                        "value": {
                          "nullable": true,
                          "description": "Present when ok is true"
                        },
                        "error": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "code": {
                              "type": "string",
                              "example": "EXPR_UNKNOWN_FUNCTION"
                            },
                            "message": {
                              "type": "string"
                            },
                            "detail": {
                              "type": "object",
                              "nullable": true
                            }
                          }
                        },
                        "engines": {
                          "type": "object",
                          "description": "Present when `engine` was omitted — one result per engine"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing `expression`, or an unknown `engine`"
          },
          "429": {
            "description": "RATE_LIMITED — 300 evaluations / 15 min per tenant"
          }
        }
      }
    },
    "/integrations/policy": {
      "get": {
        "x-required-scope": "integrations:read",
        "x-auth": "key",
        "summary": "The tenant's integration policy",
        "description": "Read-only. `strictBinding: true` means ambiguous account resolution (several connections, no default) and broken account pins fail loudly instead of silently self-healing to another account — the flag to check after a run fails with \"strict binding is on\". The flag itself is managed on the Integrations page; there is deliberately no write door on this API. Requires `integrations:read`.\n",
        "operationId": "getIntegrationPolicy",
        "tags": [
          "Integrations"
        ],
        "responses": {
          "200": {
            "description": "The current policy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "strictBinding": {
                          "type": "boolean"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/integrations/banks/connect-link": {
      "get": {
        "x-required-scope": "integrations:read",
        "x-auth": "key",
        "summary": "Where to connect a bank, and which banks need attention",
        "description": "Connecting a bank (Plaid) is consent given at the bank, so it happens only in the key owner's own browser: `connectUrl` opens Intuidy's bank manager, where they sign in and choose \"Connect a bank\" (null when they may not connect integrations or bank connections are not set up — see `notReadyReason`). `banks` lists their Plaid connections with a status; one that needs them carries `whatToDo` and an `openUrl` that opens the manager on that bank. `notes` carry the credit cost on Intuidy's Plaid account and the sandbox sign-in in test mode. A connected bank is read through `/integrations/query` with `serviceKey: plaid`; its events through the `listEvents` operation. The same answer as the MCP and assistant tool `get_bank_connect_link`. Requires `integrations:read`.\n",
        "operationId": "getBankConnectLink",
        "tags": [
          "Integrations"
        ],
        "responses": {
          "200": {
            "description": "Links and bank status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "ready": {
                          "type": "boolean"
                        },
                        "notReadyReason": {
                          "type": "string"
                        },
                        "canConnect": {
                          "type": "boolean"
                        },
                        "connectUrl": {
                          "type": "string",
                          "nullable": true,
                          "description": "Page for the key owner's browser"
                        },
                        "manageUrl": {
                          "type": "string"
                        },
                        "attention": {
                          "type": "integer",
                          "description": "Banks that need the person"
                        },
                        "banks": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "credentialId": {
                                "type": "integer"
                              },
                              "name": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "example": "Sign-in needed"
                              },
                              "needsAttention": {
                                "type": "boolean"
                              },
                              "whatToDo": {
                                "type": "string"
                              },
                              "openUrl": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "notes": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "warning": {
                          "type": "string"
                        },
                        "howItWorks": {
                          "type": "string"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/integrations/query": {
      "get": {
        "x-required-scope": "integrations:read",
        "x-auth": "key",
        "summary": "Discover readable integration operations",
        "description": "The REST door for the integration read hallway — the same catalog the chat assistant's `query_integration` tool and the MCP tool of that name serve. With no `serviceKey`, lists every readable service (curated and auto-discovered from the node catalog) and its operation names. With a `serviceKey`, lists that service's operations with their required and optional parameters; paged list operations document `maxResults` (`0` or `fetchAll: true` = every record) and the resume cursor named in a result's `resumeWith`. Operation names are forgiving: `listInvoices` resolves to `quickbooksListInvoices`. Requires `integrations:read`.\n",
        "operationId": "discoverIntegrationReads",
        "tags": [
          "Integrations"
        ],
        "parameters": [
          {
            "name": "serviceKey",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Service key, e.g. `gmail`, `quickbooks`, `hubspot`. Omit to list every readable service."
          },
          {
            "name": "operation",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "An operation name to resolve; when given, the reply also carries its definition."
          }
        ],
        "responses": {
          "200": {
            "description": "The readable services, or one service's operations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "availableServices": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "description": "Present when no serviceKey was given — service key → operation names."
                        },
                        "serviceKey": {
                          "type": "string"
                        },
                        "availableOperations": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "operation": {
                                "type": "string"
                              },
                              "description": {
                                "type": "string"
                              },
                              "requiredParams": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "string"
                                }
                              },
                              "optionalParams": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "string"
                                }
                              },
                              "exampleParams": {
                                "type": "object",
                                "additionalProperties": true
                              }
                            }
                          }
                        },
                        "usage": {
                          "type": "string"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Unknown service, or an operation that matches nothing (the reply carries `didYouMean` and `availableOperations`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "x-required-scope": "integrations:read",
        "x-auth": "key",
        "summary": "Read from a connected integration",
        "description": "Execute one read operation (emails, calendar events, files, invoices, tickets, CRM records, ...) against the tenant's connected service and return its rows inline — the same hallway, metering and data-governance scans as the chat and MCP doors. `params` are the operation's parameters from discovery. Paged list operations return `metadata.paging` (`count`, `hasMore`, `resumeWith`, `pagesFetched`); pass the `resumeWith` value back under the cursor name it carries to continue, or set `maxResults: 0` to fetch every record in one call (bounded by a page cap and a time budget, both reported when hit). `credentialId` pins one of several connections for the service; omit it for the default connection and always for services covered by the company's Google Workspace connection. Each upstream page fetched is one metered `integration_api_call`. Requires `integrations:read`.\n",
        "operationId": "queryIntegration",
        "tags": [
          "Integrations"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "serviceKey",
                  "operation"
                ],
                "properties": {
                  "serviceKey": {
                    "type": "string",
                    "description": "Service key from discovery, e.g. `quickbooks`"
                  },
                  "operation": {
                    "type": "string",
                    "description": "Operation name from discovery, e.g. `quickbooksListInvoices` (`listInvoices` also resolves)"
                  },
                  "params": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Operation parameters (see requiredParams / optionalParams from discovery)"
                  },
                  "credentialId": {
                    "type": "integer",
                    "description": "Pin a specific connection; omit for the default"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The operation's rows and paging facts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "serviceKey": {
                          "type": "string"
                        },
                        "operation": {
                          "type": "string"
                        },
                        "rowCount": {
                          "type": "integer"
                        },
                        "metadata": {
                          "type": "object",
                          "additionalProperties": true,
                          "description": "Resolved account and, for paged lists, `paging` (count, totalCount, hasMore, nextCursor, resumeWith, pagesFetched, warning)"
                        },
                        "data": {
                          "description": "The rows (an array for list operations; an object for single-record reads)"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`INVALID_INPUT` — missing serviceKey/operation or a malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`POLICY_BLOCKED` (data-governance rules refused the request or its result) or `POLICY_UNEVALUABLE` (rules exist but the key has no owning user)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown service or operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "`INTEGRATION_ERROR` — the upstream service refused or failed; the message carries its remedy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/custom-apis": {
      "get": {
        "x-required-scope": "integrations:read",
        "x-auth": "key",
        "summary": "List the tenant's custom API definitions",
        "description": "The REST door onto the custom API definitions the tenant built in the API builder — the same `customApis` list the MCP and chat `list_integrations` tools describe. Headers and endpoint counts by default; `detail=endpoints` adds one page of endpoint ids, methods and paths per definition, `detail=full` one page with parameters, and `serviceId` one definition's first page with parameters. A definition can hold tens of thousands of endpoints: search them one page at a time at `/integrations/custom-apis/{id}/endpoints`. Requires `integrations:read`.\n",
        "operationId": "listCustomApis",
        "tags": [
          "Integrations"
        ],
        "parameters": [
          {
            "name": "detail",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "summary",
                "endpoints",
                "full"
              ]
            }
          },
          {
            "name": "serviceId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "One definition, with its first page of endpoints and their parameters."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Words every inlined endpoint must match (endpoints and full levels)."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The `endpointsPage.nextCursor` of a previous reply (with `serviceId`)."
          }
        ],
        "responses": {
          "200": {
            "description": "The custom API definitions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "customApis": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "serviceId": {
                                "type": "integer"
                              },
                              "serviceKey": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "baseUrl": {
                                "type": "string"
                              },
                              "auth": {
                                "type": "string"
                              },
                              "endpointCount": {
                                "type": "integer"
                              },
                              "readCount": {
                                "type": "integer"
                              },
                              "writeCount": {
                                "type": "integer"
                              },
                              "connected": {
                                "type": "boolean"
                              }
                            }
                          }
                        },
                        "usage": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/custom-apis/{id}/endpoints": {
      "get": {
        "x-required-scope": "integrations:read",
        "x-auth": "key",
        "summary": "Search one custom API's endpoints, or read one endpoint's contract",
        "description": "One page of a custom API's endpoints by words (matched against the endpoint id, method, path, summary and tags), effect and tag, with a cursor for the next page; or, with `endpointId`, one endpoint's whole contract (parameters, outputs, paging). Reads the definition Intuidy holds, never the API. The endpoint id is what `POST /integrations/query` takes with serviceKey `customapi`, operation `queryEndpoint` and `params: { serviceId, endpointId, params }`. The same hallway the MCP and chat `search_custom_api_endpoints` tools read. Requires `integrations:read`.\n",
        "operationId": "searchCustomApiEndpoints",
        "tags": [
          "Integrations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "The custom API's serviceId."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "effect",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "read",
                "write"
              ]
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 50
            }
          },
          {
            "name": "withSpec",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "Include each endpoint's parameters, outputs and paging on the page."
          },
          {
            "name": "endpointId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "One endpoint's whole contract instead of a page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of endpoints, or one endpoint",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "serviceId": {
                          "type": "integer"
                        },
                        "endpoints": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "method": {
                                "type": "string"
                              },
                              "effect": {
                                "type": "string",
                                "enum": [
                                  "read",
                                  "write"
                                ]
                              },
                              "path": {
                                "type": "string"
                              },
                              "summary": {
                                "type": "string"
                              },
                              "tags": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        },
                        "nextCursor": {
                          "type": "string",
                          "nullable": true
                        },
                        "matched": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "endpoint": {
                          "type": "object",
                          "description": "Present with `endpointId` — the whole contract."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`NOT_FOUND` — no such custom API, or no such endpoint on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/credentials/{credentialId}": {
      "patch": {
        "x-required-scope": "integrations:write",
        "x-auth": "key",
        "summary": "Rename a connection, make it the default, or change its scope",
        "description": "Connection administration over the same hallway as the Integrations page. `label` renames it (null clears it); `isDefault` makes it the default connection for its service (company connections only — exactly one default survives per service); `scope` moves it between `company` (everyone in the company resolves it) and `personal` (the key owner's alone). The row id survives a scope change, so workflow bindings and per-node pins keep working. A personal connection can only be edited by its owner — anyone else's reads as not found — and company connections, like any scope change, need the key owner's `share_integrations` permission. Deliberately narrower than the web door: no credential blob, and no allow-list or sensitivity edits — who may USE a connection is managed in Settings → Integrations only. Requires `integrations:write`.\n",
        "operationId": "updateIntegrationCredential",
        "tags": [
          "Integrations"
        ],
        "parameters": [
          {
            "name": "credentialId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "At least one field is required.",
                "properties": {
                  "label": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 100,
                    "description": "Display name; trimmed, null clears it"
                  },
                  "isDefault": {
                    "type": "boolean",
                    "description": "Company connections only"
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "company",
                      "personal"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The connection as stored",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "credential": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "integer"
                            },
                            "label": {
                              "type": "string",
                              "nullable": true
                            },
                            "isDefault": {
                              "type": "boolean"
                            },
                            "scope": {
                              "type": "string",
                              "enum": [
                                "company",
                                "personal"
                              ]
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body; a personal connection named as default (`PERSONAL_DEFAULT`); or demoting the tenant default while company siblings exist (`DEFAULT_IN_USE`)\n"
          },
          "403": {
            "description": "The key owner lacks `share_integrations`"
          },
          "404": {
            "description": "Connection not found in this tenant (another user's personal connection also reads as not found)"
          },
          "409": {
            "description": "The same account already exists at the target scope (`SCOPE_CONFLICT`), or the row is a Google Workspace domain key or org-shared (`WORKSPACE_SCOPE`, `ORG_SHARED_SCOPE`)\n"
          }
        }
      }
    },
    "/workflows/{workflowId}/connections": {
      "get": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "summary": "The workflow's account bindings",
        "description": "The `{ serviceKey: credentialId }` map every node without a per-node account pin resolves through — \"this whole workflow is Acme-US\". An empty object means the tenant's service defaults apply. Requires `workflows:read`; bindings belong to the workflow's owning company.\n",
        "operationId": "getWorkflowConnections",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The current bindings (empty object when none are set)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "connections": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "integer"
                          },
                          "description": "serviceKey → credentialId"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Workflow not found"
          }
        }
      },
      "put": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "summary": "Replace the workflow's account bindings",
        "description": "Replaces the full binding map; an empty object clears all bindings. Every credentialId must belong to the key's own company AND to the service it is bound under — a cross-tenant, wrong-service, or another user's personal credential is refused with the offending binding named. Per-node pins still outrank bindings; the per-call `connections` field on `POST …/execute` outranks bindings but not pins. Requires `workflows:write`. A binding onto a managed database's login that the workflow does not already have needs the key owner's `use_databases` permission; without it the answer is 403 `PERMISSION_DENIED`. A workflow save that binds a managed database without it answers 403 `DATABASE_USE_DENIED`.\n",
        "operationId": "setWorkflowConnections",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connections": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "integer"
                    },
                    "description": "serviceKey → credentialId (empty object clears)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The bindings as stored",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "connections": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A binding failed validation (cross-tenant, wrong service, or foreign personal credential)"
          },
          "404": {
            "description": "Workflow not found"
          }
        }
      }
    },
    "/workflows/{workflowId}/versions": {
      "get": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "summary": "Snapshots of a workflow taken before each save",
        "description": "Every save door (builder, this API, MCP, agent tools) snapshots the graph it is about to overwrite — the last 25 per workflow, identical saves skipped. Restore one with `POST …/versions/restore`.\n",
        "operationId": "listWorkflowVersions",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Newest-first snapshots (metadata only)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workflowId": {
                      "type": "integer"
                    },
                    "versions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "savedAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "savedBy": {
                            "type": "integer",
                            "nullable": true
                          },
                          "reason": {
                            "type": "string",
                            "description": "save | pre-restore"
                          },
                          "summary": {
                            "type": "object",
                            "properties": {
                              "title": {
                                "type": "string"
                              },
                              "nodeCount": {
                                "type": "integer"
                              },
                              "edgeCount": {
                                "type": "integer"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Workflow not found"
          }
        }
      }
    },
    "/workflows/{workflowId}/versions/restore": {
      "post": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "summary": "Roll a workflow back to a snapshot",
        "description": "Replays the snapshot through the graph save hallway (validated like any save) after snapshotting the current graph with reason `pre-restore`, so the restore is itself undoable. Requires `workflows:write`; writes stay within the key's own company.\n",
        "operationId": "restoreWorkflowVersion",
        "tags": [
          "Workflows"
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "key"
                ],
                "properties": {
                  "key": {
                    "type": "string",
                    "description": "A version key from GET …/versions"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Restored",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "restored": {
                      "type": "object",
                      "properties": {
                        "key": {
                          "type": "string"
                        },
                        "savedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    },
                    "nodeCount": {
                      "type": "integer"
                    },
                    "edgeCount": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Snapshot failed validation"
          },
          "404": {
            "description": "Workflow or version not found"
          }
        }
      }
    },
    "/workflows/{workflowId}/webhook/{token}": {
      "parameters": [
        {
          "name": "workflowId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "token",
          "in": "path",
          "required": true,
          "description": "HMAC-derived webhook token. This IS the credential.",
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "x-required-scope": null,
        "x-auth": "none",
        "x-scope-note": "The {token} in the path is the credential. Send no Authorization header.",
        "summary": "Trigger a workflow by webhook",
        "description": "The one public door in this API: authenticated by the token in the path, NOT by a bearer key, so third-party systems can post to it directly. Carries its own rate limit (60/min per workflow) and a 1 MB body cap. Acknowledges with 202 by default; add `?mode=sync` to wait for the run and receive its result.\n\nThe URL runs the workflow on POST only. GET and HEAD answer a registered handshake and nothing else. The workflow sees the decoded body, the request method, and only the headers and query names listed under request (`request.headers`, `request.query` on the webhook node, plus the selected provider's own event headers). A header whose name can carry a credential (authorization, cookie, token, secret, signature and similar) or a client address is never passed on, listed or not; the `mode` parameter and a handshake parameter never are either. A sync answer is always JSON: a short receipt, or the status, headers and body of the workflow's `api/response` node. That is enough for a challenge sent as a POST body that accepts a JSON reply; a sync reply cannot answer a GET or HEAD challenge, a plain-text echo or a header echo.\n\nSignatures: `provider` selects a sender preset (`github`, `telegram`, `microsoftGraph`), and the node's `security` keys set the scheme by hand: `signatureAlgorithm` (sha256, sha1), `signatureEncoding` (hex, base64), `signaturePrefix`, `signedMessage` (a template over `{body}`, `{timestamp}`, `{url}` and `{method}`) and `timestampHeader`. An explicit key wins over the preset.\n\nDe-duplication: for a node that selects a provider with a delivery id (GitHub's delivery header, Telegram's `update_id`, Microsoft Graph `created` notifications and notifications that carry an etag) or sets `dedupe.header` or `dedupe.path`, a delivery whose id was seen in the last ten minutes answers `200` with `{ received: true, duplicate: true }` and does not run, so it is not billed. Every delivery after the token check is recorded; read them with `GET /workflows/{workflowId}/deliveries`.\n\nMicrosoft Graph: with `provider: microsoftGraph` (or the stored `security.handshake: microsoftGraph`) on a webhook node the URL answers Graph's subscription validation itself (see `validationToken`). The Graph subscription for this URL is created and renewed outside it. For mail, calendar events, drive items and Teams messages use the managed triggers, which create and renew their own subscription. Each notification's `clientState` is checked against `security.clientState` and then removed from the payload the workflow receives. A signing secret or header token on the same workflow rejects every Graph notification, because Graph sends neither. Validation requests count toward the rate limit.\n",
        "operationId": "triggerWorkflowWebhook",
        "tags": [
          "Workflows"
        ],
        "security": [],
        "parameters": [
          {
            "name": "mode",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "sync"
              ]
            }
          },
          {
            "name": "validationToken",
            "in": "query",
            "description": "Microsoft Graph subscription validation. Answered only when a webhook node on this workflow selects `provider: microsoftGraph` (or sets `security.handshake: microsoftGraph`): the token comes back verbatim as `text/plain` and the workflow does not run. Otherwise the request is an ordinary delivery.\n",
            "schema": {
              "type": "string",
              "maxLength": 4096
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sync mode (`mode=sync`, or the node's `responseMode: sync`): the run finished, answered as JSON. Without an `api/response` node the body is a receipt (`received`, `ran`, `hasResult`, and `error` when the run failed). A workflow that ends at an `api/response` node answers with that node's own status, headers and JSON body instead, so the status may be other than 200. As `text/plain`: the echoed `validationToken` of a Microsoft Graph handshake. A repeated delivery id on a de-duplicating node also answers 200, with `{ received: true, duplicate: true }`, and does not run.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "received": {
                      "type": "boolean"
                    },
                    "duplicate": {
                      "type": "boolean",
                      "description": "Present and true when the delivery repeats one seen in the last ten minutes; nothing ran"
                    }
                  }
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "202": {
            "description": "Accepted and queued"
          },
          "400": {
            "description": "Malformed path, a body that could not be read, or a body that does not parse as its content type"
          },
          "401": {
            "description": "Bad token, or a configured check (signature, header token, Microsoft Graph `clientState`) failed"
          },
          "402": {
            "description": "The workflow owner's billing does not allow a run"
          },
          "403": {
            "description": "Source IP is not on the node's allowlist, or the webhook node's configuration cannot be read"
          },
          "404": {
            "description": "No such workflow, the workflow is inactive, or it has no webhook trigger"
          },
          "413": {
            "description": "Body over 1 MB. The answer carries `Connection: close`; open a new connection for the next request."
          },
          "429": {
            "description": "Too many webhook calls for this workflow"
          },
          "503": {
            "description": "The token could not be checked right now; retry the delivery"
          }
        }
      },
      "get": {
        "x-required-scope": null,
        "x-auth": "none",
        "x-scope-note": "The {token} in the path is the credential. Send no Authorization header.",
        "summary": "Answer a webhook handshake",
        "description": "Handshake only: GET never runs the workflow, reads no body and bills nothing. When a webhook node selects a provider with a handshake (today `microsoftGraph`, whose `validationToken` is echoed as `text/plain`) and the request is that handshake from an allowed source address, the answer is 200 and counts toward the 60-a-minute delivery limit. Anything else is 405 with `Allow: POST, OPTIONS`, which does not count toward that limit.\n",
        "operationId": "answerWorkflowWebhookHandshake",
        "tags": [
          "Workflows"
        ],
        "security": [],
        "parameters": [
          {
            "name": "validationToken",
            "in": "query",
            "description": "Microsoft Graph subscription validation, echoed verbatim when a node opted in",
            "schema": {
              "type": "string",
              "maxLength": 4096
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The handshake answer",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Malformed path"
          },
          "401": {
            "description": "Bad token"
          },
          "403": {
            "description": "The webhook node's configuration cannot be read"
          },
          "404": {
            "description": "No such workflow, the workflow is inactive, or it has no webhook trigger"
          },
          "405": {
            "description": "Not a registered handshake. The answer carries `Allow: POST, OPTIONS`.",
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls for this workflow"
          },
          "503": {
            "description": "The token could not be checked right now; retry"
          }
        }
      },
      "head": {
        "x-required-scope": null,
        "x-auth": "none",
        "x-scope-note": "The {token} in the path is the credential. Send no Authorization header.",
        "summary": "Answer a webhook handshake, without a body",
        "description": "The same answer as GET, with the same status and headers and no body. Never runs the workflow.\n",
        "operationId": "headWorkflowWebhookHandshake",
        "tags": [
          "Workflows"
        ],
        "security": [],
        "parameters": [
          {
            "name": "validationToken",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 4096
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The handshake answer, without its body"
          },
          "400": {
            "description": "Malformed path"
          },
          "401": {
            "description": "Bad token"
          },
          "403": {
            "description": "The webhook node's configuration cannot be read"
          },
          "404": {
            "description": "No such workflow, the workflow is inactive, or it has no webhook trigger"
          },
          "405": {
            "description": "Not a registered handshake. The answer carries `Allow: POST, OPTIONS`.",
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls for this workflow"
          },
          "503": {
            "description": "The token could not be checked right now; retry"
          }
        }
      }
    },
    "/keys/{keyId}/connections": {
      "parameters": [
        {
          "name": "keyId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": null,
        "x-auth": "session",
        "x-scope-note": "Available only from the Intuidy web app while signed in. API keys and OAuth access tokens cannot call it.",
        "summary": "Apps connected as this key",
        "description": "Lists the apps holding an OAuth connection bound to this key — one row per connection, not per token, so a client that has refreshed forty times is still one entry. A bound connection has no API key row of its own (it assumes this one), which is why it is listed here rather than beside the keys. Session-authed like its sibling key routes: a compromised API key must not be able to enumerate or sever its own connections.\n",
        "operationId": "listKeyConnections",
        "tags": [
          "API Keys"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Live connections",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "connections": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "grantId": {
                            "type": "string",
                            "description": "The connection lineage, stable across refresh rotation"
                          },
                          "clientId": {
                            "type": "string",
                            "description": "The OAuth client — a Client ID Metadata Document URL, or a registered client id"
                          },
                          "connected": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "lastRefreshed": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API key not found"
          }
        }
      }
    },
    "/keys/{keyId}/connections/{grantId}": {
      "parameters": [
        {
          "name": "keyId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "grantId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "delete": {
        "x-required-scope": null,
        "x-auth": "session",
        "x-scope-note": "Available only from the Intuidy web app while signed in. API keys and OAuth access tokens cannot call it.",
        "summary": "Disconnect one app",
        "description": "Ends a single OAuth connection bound to this key, leaving the key — and every other app connected as it — working. Revoking the key itself instead ends all of them. Permission mirrors revoking the key: company-wide keys are administrators only, personal keys are the owner's.\n",
        "operationId": "disconnectKeyConnection",
        "tags": [
          "API Keys"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Disconnected",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Not authorized to modify this key"
          },
          "404": {
            "description": "API key not found"
          }
        }
      }
    },
    "/workflows/{workflowId}/webhook/rotate": {
      "post": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "tags": [
          "Workflows"
        ],
        "summary": "Rotate a workflow's inbound webhook URL",
        "description": "Derives a new inbound webhook URL for the workflow and invalidates the current one. For a URL that has leaked — pasted into a third-party dashboard, a log or a chat thread. Whatever is posting to the old URL starts receiving 401 immediately, so send the new path to the sender. Requires `workflows:write`: this changes how the workflow is reached.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rotated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "workflow_id": {
                          "type": "integer"
                        },
                        "rotated": {
                          "type": "boolean"
                        },
                        "epoch": {
                          "type": "integer",
                          "description": "How many times this URL has been rotated"
                        },
                        "path": {
                          "type": "string",
                          "description": "The new inbound path; prefix with this deployment's origin"
                        },
                        "note": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_WORKFLOW — the path carried no usable workflow id"
          },
          "403": {
            "description": "NOT_AUTHORIZED — only the workflow's owner or a company administrator may rotate its URL"
          },
          "404": {
            "description": "NOT_FOUND — no such workflow, or not this company's (company-only even for an organization admin; a sibling company that can read the workflow still cannot revoke a URL its owner does not know it holds)"
          }
        }
      }
    },
    "/databases": {
      "get": {
        "x-required-scope": "databases:read",
        "x-auth": "key",
        "tags": [
          "Databases"
        ],
        "summary": "List managed databases",
        "description": "The managed databases this key may read. Each row carries BOTH ids: `id` is the database, `credential_id` is its connection — notebook query cells and DB workflow nodes take the credential id, and swapping the two silently points them at a different database.\n\nEach row also lists the extensions enabled in the database (`extensions`, for example `postgis` on a PostgreSQL database), so a caller knows whether spatial SQL will run. Extensions are listed here and managed in the web app, in the Extensions section of the database page.\n\nData plane only. Provisioning, database users, backups, restore, import, connection logs and enabling or disabling an extension are not published: they hand out credentials and reshape infrastructure, and stay on the session door.",
        "operationId": "listDatabases",
        "responses": {
          "200": {
            "description": "The databases this key may read",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "databases": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "integer"
                              },
                              "name": {
                                "type": "string"
                              },
                              "credential_id": {
                                "type": "integer",
                                "nullable": true,
                                "description": "The CONNECTION id — what notebook cells and DB nodes take"
                              },
                              "status": {
                                "type": "string"
                              },
                              "engine": {
                                "type": "string",
                                "description": "The engine's display name, e.g. MySQL or PostgreSQL. SQL against this database uses its dialect."
                              },
                              "engine_type": {
                                "type": "string",
                                "enum": [
                                  "mysql",
                                  "postgres"
                                ],
                                "description": "The engine's machine key"
                              },
                              "engine_version": {
                                "type": "string",
                                "nullable": true
                              },
                              "extensions": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "description": "Keys of the extensions enabled in the database, for example postgis on a PostgreSQL database. Empty when none is enabled. This is the recorded list; it is managed in the web app."
                              },
                              "size_mb": {
                                "type": "integer",
                                "nullable": true
                              },
                              "max_size_mb": {
                                "type": "integer",
                                "nullable": true
                              },
                              "created": {
                                "type": "string",
                                "format": "date-time"
                              }
                            }
                          }
                        },
                        "total": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the databases:read scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/databases/{databaseId}/tables": {
      "parameters": [
        {
          "name": "databaseId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "databases:read",
        "x-auth": "key",
        "tags": [
          "Databases"
        ],
        "summary": "List the tables in one managed database",
        "description": "Table names with row counts, sizes and comments, from the same introspection hallway the app uses. Relations that an extension owns (PostGIS's spatial_ref_sys and geometry_columns, for example) are not listed and can still be queried by name. The key owner needs the `query_databases` permission; without it the answer is 403 `PERMISSION_DENIED`.\n",
        "operationId": "listDatabaseTables",
        "responses": {
          "200": {
            "description": "The tables in this database",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "database_id": {
                          "type": "integer"
                        },
                        "tables": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "total": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "DATABASE_NOT_ACTIVE, NO_CREDENTIAL or CREDENTIAL_NOT_FOUND — the database exists but cannot be introspected yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Database not found, or not this company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/databases/{databaseId}/health": {
      "parameters": [
        {
          "name": "databaseId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "fresh",
          "in": "query",
          "required": false,
          "schema": {
            "type": "string",
            "enum": [
              "1"
            ]
          },
          "description": "Bypass the cached answer. A probe opens a real connection, so the hallway caches it — a monitor polling every minute would otherwise cost one connection per poll."
        }
      ],
      "get": {
        "x-required-scope": "databases:read",
        "x-auth": "key",
        "tags": [
          "Databases"
        ],
        "summary": "Check a managed database's health",
        "operationId": "checkDatabaseHealth",
        "responses": {
          "200": {
            "description": "Reachability and size",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "database_id": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND — no managed database with this id exists for the key owner's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/databases/{databaseId}/query": {
      "parameters": [
        {
          "name": "databaseId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "databases:read",
        "x-auth": "key",
        "tags": [
          "Databases"
        ],
        "summary": "Run SQL against a managed database",
        "description": "READ or WRITE is decided by the statement, not by the caller — the same shared classifier the query console forks on. A read (SELECT, SHOW, DESCRIBE, EXPLAIN) needs `databases:read`; anything that mutates needs `databases:write`, so a reporting key cannot change data by sending an UPDATE. Anything that is neither is refused 422 and runs nowhere.\n\nA read passes the tenant's data rules on the way out, and `data_rules_applied` counts how many fired. The rules for the `ai` channel apply as on MCP `query_managed_db`: a rule on a table's classification can mask columns or refuse the read (`403 POLICY_BLOCKED`). It is capped and server-timed out.\n\nDROP, TRUNCATE, `ALTER … DROP` and RENAME destroy a schema object and additionally need `allow_destructive_ddl: true`. No write scope is taken to authorise them on its own, and the refusal names the statement. It cannot be undone.\n\nOn a PostgreSQL database, `CREATE EXTENSION`, `ALTER EXTENSION` and `DROP EXTENSION` are refused with `SQL_STATEMENT_BLOCKED`, with or without `allow_destructive_ddl`. Extensions are enabled and disabled on the database's page in the web app.\n\nBeside the scope, the key owner's role decides: a read needs the `query_databases` permission and a write needs `edit_databases`. Without it the answer is 403 `PERMISSION_DENIED`, naming the permission.",
        "operationId": "queryDatabase",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "sql"
                ],
                "properties": {
                  "sql": {
                    "type": "string",
                    "description": "One statement. Multi-statement input is refused."
                  },
                  "params": {
                    "type": "array",
                    "items": {},
                    "description": "Prepared-statement values. WRITES only — a read that sends them is refused 400."
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Values for `{{dash.name}}` tokens in a dashboard SQL tile's query. Bound, never spliced."
                  },
                  "row_limit": {
                    "type": "integer",
                    "description": "Rows to return (default 1000, capped)"
                  },
                  "allow_destructive_ddl": {
                    "type": "boolean",
                    "description": "Required for DROP, TRUNCATE, ALTER … DROP and RENAME. Set it only when the object is meant to go."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rows for a read, or the affected-row counts for a write",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "database_id": {
                          "type": "integer"
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "columns": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "total_rows": {
                          "type": "integer"
                        },
                        "truncated": {
                          "type": "boolean"
                        },
                        "data_rules_applied": {
                          "type": "integer",
                          "description": "Present when the tenant's data rules changed the rows"
                        },
                        "affected_rows": {
                          "type": "integer",
                          "description": "Writes only"
                        },
                        "insert_id": {
                          "type": "integer",
                          "description": "Writes only"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "DB_SQL — the statement itself failed (syntax, unknown table, duplicate key); DB_REJECTED — the database refused it (a constraint or permission); the database's own message is returned. Also INVALID_INPUT — params on a read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`INSUFFICIENT_SCOPE` (a write without databases:write), `SQL_STATEMENT_BLOCKED` (server-level, account or extension statement) or `SQL_DESTRUCTIVE_DDL` (set allow_destructive_ddl to run it), `POLICY_BLOCKED` (a data rule refused the rows) or `POLICY_UNEVALUABLE` (rules are on, but this key has no owning user to evaluate them for)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "SQL_STATEMENT_REFUSED — neither a read nor a write this door runs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "DB_UNKNOWN — the database driver failed for a reason the door could not classify",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "DB_CONNECTIVITY, DB_AUTH or DB_CONFIG — the database could not be reached, refused the credential, or is misconfigured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "DB_TIMEOUT — the statement ran past the server-side limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/workflows/freshness": {
      "post": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "tags": [
          "Workflows"
        ],
        "summary": "When did these workflows last really run?",
        "description": "One timestamp per workflow, from the stamp the engine writes after every non-preview execution. Ask this instead of running a workflow to find out whether it is still firing: running it bills, and changes the answer you were asking about.\n\nReads only, and bills NOTHING — a health check that costs credits is one people stop running. It takes `workflows:read`, not `workflows:execute`.\n\n`stale` is reported only when you pass `since`; without it you get the times and `stale: null`, because inventing a threshold would mean reporting a verdict nobody asked for. A workflow with `lastRunAt: null` has not run in the 30 days the stamp lives, or has never run — both count as stale against any `since`.\n\nAn id outside this key's reach comes back with `reachable: false` rather than failing the call, so one wrong id does not cost you the nineteen that were right. Those ids are listed in `unreachable`.",
        "operationId": "checkWorkflowFreshness",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "workflow_ids"
                ],
                "properties": {
                  "workflow_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "maxItems": 200,
                    "description": "The workflows to ask about. `workflowIds` is accepted too."
                  },
                  "since": {
                    "type": "string",
                    "format": "date-time",
                    "description": "ISO 8601. A run at or after it counts as fresh."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A freshness entry per workflow id",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "workflows": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "object",
                            "properties": {
                              "lastRunAt": {
                                "type": "string",
                                "format": "date-time",
                                "nullable": true
                              },
                              "runTrigger": {
                                "type": "string",
                                "nullable": true,
                                "description": "webhook, schedule, manual, api, agent, dashboard"
                              },
                              "runId": {
                                "type": "string",
                                "nullable": true
                              },
                              "stale": {
                                "type": "boolean",
                                "nullable": true,
                                "description": "Null unless `since` was given"
                              },
                              "reachable": {
                                "type": "boolean"
                              }
                            }
                          }
                        },
                        "unreachable": {
                          "type": "array",
                          "items": {
                            "type": "integer"
                          },
                          "description": "Ids this key cannot see"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`INVALID_INPUT` (no ids, or an unparseable `since`) or `TOO_MANY_IDS` (over 200)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/workflows/{workflowId}/schedule": {
      "get": {
        "x-required-scope": "workflows:read",
        "x-auth": "key",
        "tags": [
          "Workflows"
        ],
        "summary": "Read a workflow's schedule",
        "description": "What schedule the workflow runs on, if any: whether it is active, its cron expression and timezone, when it next runs and when it last did, and why it was paused if it was.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The schedule, or null when the workflow has none",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "workflowId": {
                          "type": "integer"
                        },
                        "schedule": {
                          "oneOf": [
                            {
                              "$ref": "#/components/schemas/WorkflowSchedule"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_WORKFLOW — the path carried no usable workflow id"
          },
          "404": {
            "description": "NOT_FOUND — no such workflow, or out of this key's reach (a read reaches as far as GET /workflows/{id}); USER_NOT_FOUND — the key's user could not be resolved"
          }
        }
      },
      "put": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "tags": [
          "Workflows"
        ],
        "summary": "Put a workflow on a schedule",
        "description": "Writes the workflow's own Schedule Trigger node, which is what makes the schedule visible in the builder and durable: a caller that wrote only the schedule row had it derived away by the next graph save. An interval below 5 minutes is refused.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkflowScheduleWrite"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scheduled",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "workflowId": {
                          "type": "integer"
                        },
                        "created": {
                          "type": "boolean",
                          "description": "true when the workflow had no Schedule Trigger node and one was added"
                        },
                        "schedule": {
                          "$ref": "#/components/schemas/WorkflowSchedule"
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_WORKFLOW — the path carried no usable workflow id; INVALID_BODY — the body was not JSON"
          },
          "403": {
            "description": "FORBIDDEN — the key's user does not hold edit_workflows; setting a schedule writes the workflow's graph and is gated exactly as saving it is, on every door"
          },
          "404": {
            "description": "NOT_FOUND — no such workflow, or not this company's (a write stops at the company, widened to an organization admin's reach); USER_NOT_FOUND — the key's user could not be resolved"
          },
          "409": {
            "description": "GRAPH_INCONSISTENT — the workflow has an edge with no matching node; open and save it in the builder first"
          },
          "422": {
            "description": "INVALID_SCHEDULE — the schedule could never run (unknown type, unreadable cron, interval below the floor, a time of day that is not HH:MM); GRAPH_REFUSED — the workflow's graph would not validate"
          }
        }
      },
      "delete": {
        "x-required-scope": "workflows:write",
        "x-auth": "key",
        "tags": [
          "Workflows"
        ],
        "summary": "Turn a workflow's schedule off",
        "description": "Deactivates the schedule while keeping its run history and the times that were chosen, so it can be turned back on. `remove_node=true` takes the Schedule Trigger node out of the graph.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "remove_node",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cleared (or already had no schedule)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "workflowId": {
                          "type": "integer"
                        },
                        "cleared": {
                          "type": "boolean",
                          "description": "false when the workflow had no schedule to clear"
                        },
                        "removedNode": {
                          "type": "boolean"
                        },
                        "schedule": {
                          "oneOf": [
                            {
                              "$ref": "#/components/schemas/WorkflowSchedule"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_WORKFLOW — the path carried no usable workflow id"
          },
          "403": {
            "description": "FORBIDDEN — the key's user does not hold edit_workflows; disarming a schedule is a graph write too"
          },
          "404": {
            "description": "NOT_FOUND — no such workflow, or not this company's; USER_NOT_FOUND — the key's user could not be resolved"
          },
          "409": {
            "description": "GRAPH_INCONSISTENT — the workflow has an edge with no matching node (other than the trigger's own, which go with it); open and save it in the builder first"
          },
          "422": {
            "description": "GRAPH_REFUSED — the workflow's graph would not validate after the change"
          }
        }
      }
    },
    "/keys/{keyId}/probe": {
      "parameters": [
        {
          "name": "keyId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": null,
        "x-auth": "session",
        "x-scope-note": "Available only from the Intuidy web app while signed in. API keys and OAuth access tokens cannot call it.",
        "summary": "What would this key reach?",
        "description": "Resolves the same ownership filter the real doors use and counts what it matches, so the answer cannot drift from actual authorization — answered WITHOUT the secret, which is only ever stored hashed. Session-authed like its sibling key routes: a compromised API key must not be able to enumerate the reach of other keys.\n",
        "operationId": "probeApiKey",
        "tags": [
          "API Keys"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Reach report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "keyId": {
                      "type": "integer"
                    },
                    "name": {
                      "type": "string"
                    },
                    "scopes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "scopeLevel": {
                      "type": "string"
                    },
                    "active": {
                      "type": "boolean"
                    },
                    "expired": {
                      "type": "boolean"
                    },
                    "reach": {
                      "type": "object",
                      "properties": {
                        "workflows": {
                          "type": "integer"
                        },
                        "notebooks": {
                          "type": "integer"
                        },
                        "dashboards": {
                          "type": "integer"
                        },
                        "agents": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Key not found or not visible to the caller"
          },
          "429": {
            "description": "Too many access checks"
          }
        }
      }
    },
    "/users": {
      "get": {
        "x-required-scope": "users:read",
        "x-auth": "key",
        "summary": "List the organization's human users",
        "description": "Rows carry roles and month-to-date creditsUsed; password hashes and\nthe settings JSON are never selected. `?client_id` narrows to one\ncompany inside the key's scope (403 outside it).\n",
        "operationId": "listOrgUsers",
        "tags": [
          "Organization"
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 100
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Name/email contains"
          },
          {
            "name": "client_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Must be inside the key's scope"
          }
        ],
        "responses": {
          "200": {
            "description": "User list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "users": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/OrgUser"
                          }
                        },
                        "pagination": {
                          "type": "object",
                          "properties": {
                            "page": {
                              "type": "integer"
                            },
                            "limit": {
                              "type": "integer"
                            },
                            "total": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`users:read` missing), or FORBIDDEN — client_id outside the key's scope"
          }
        }
      },
      "post": {
        "x-required-scope": "users:write",
        "x-auth": "key",
        "summary": "Create (invite) a user",
        "description": "Requires the key owner's manage_users permission — see the section\nnote. Role ids must belong to the target company. `roleIds` and\n`role_ids` are accepted as aliases.\n",
        "operationId": "createOrgUser",
        "tags": [
          "Organization"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "password"
                ],
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "first_name": {
                    "type": "string"
                  },
                  "last_name": {
                    "type": "string"
                  },
                  "client_id": {
                    "type": "integer",
                    "description": "Defaults to the key's company; must be inside the key's scope"
                  },
                  "is_active": {
                    "type": "boolean",
                    "default": true
                  },
                  "roleIds": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created user",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "user": {
                          "$ref": "#/components/schemas/OrgUser"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (missing email/password, a role outside the target company)"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`users:write` missing), or FORBIDDEN — the key's owner lacks `manage_users`"
          },
          "409": {
            "description": "A user with this email already exists"
          }
        }
      }
    },
    "/users/{userId}": {
      "parameters": [
        {
          "name": "userId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "users:read",
        "x-auth": "key",
        "summary": "Get one user",
        "description": "A user outside the key's scoped companies is a 404 — the door never confirms an id it will not serve.",
        "operationId": "getOrgUser",
        "tags": [
          "Organization"
        ],
        "responses": {
          "200": {
            "description": "The user",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "user": {
                          "$ref": "#/components/schemas/OrgUser"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "User not found or outside the key's scope"
          }
        }
      },
      "patch": {
        "x-required-scope": "users:write",
        "x-auth": "key",
        "summary": "Update a user",
        "description": "The web PUT's fields, as a PATCH (the v1 CORS contract has no PUT in\nAllow-Methods). Requires the key owner's manage_users permission.\nRole-belongs-to-client validation rides along from the shared\nhallway.\n",
        "operationId": "updateOrgUser",
        "tags": [
          "Organization"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "first_name": {
                    "type": "string"
                  },
                  "last_name": {
                    "type": "string"
                  },
                  "client_id": {
                    "type": "integer",
                    "description": "Moves the user to another company in the key's scope. The move clears the user's roles and default dashboard, so send that company's roleIds in the same request."
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "password": {
                    "type": "string"
                  },
                  "roleIds": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated user"
          },
          "400": {
            "description": "Invalid input"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`users:write` missing), or FORBIDDEN — the key's owner lacks `manage_users`, or the target is outside the key's scope"
          },
          "404": {
            "description": "User not found"
          }
        }
      },
      "delete": {
        "x-required-scope": "users:write",
        "x-auth": "key",
        "summary": "Delete a user",
        "description": "The key's OWNER is the actor, so a key cannot delete its own owner —\nthe shared hallway's self-delete refusal rides along.\n\nTwo refusals ask for an acknowledgement and are retried with a query\nparameter: `LAST_ACTIVE_USER` (the company's last active user; retry\nwith `allowLastActiveUser=1`) and `HAS_OWNED_CONTENT` (the user still\nowns dashboards, workflows, notebooks or agents; retry with\n`successorUserId`, an active user of the same company who inherits\nthem, or `force=1` to leave them ownerless). A successor from another\ncompany is refused (403), even one inside the key's scope, and so is\nan inactive successor (422).\n",
        "operationId": "deleteOrgUser",
        "tags": [
          "Organization"
        ],
        "parameters": [
          {
            "name": "allowLastActiveUser",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "Confirm removing the company's last active user (billing notices would reach nobody)."
          },
          {
            "name": "successorUserId",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "An active user of the same company who inherits the content the deleted user owned."
          },
          {
            "name": "force",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "Delete even though owned content stays ownerless."
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted"
          },
          "400": {
            "description": "Refused — a user cannot delete themselves"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`users:write` missing), or FORBIDDEN — the key's owner lacks `manage_users`, the target is outside the key's scope, or the successor is in another company"
          },
          "404": {
            "description": "User (or successor) not found"
          },
          "409": {
            "description": "LAST_ACTIVE_USER (retry with `allowLastActiveUser=1`) or HAS_OWNED_CONTENT (retry with `successorUserId` or `force=1`)"
          },
          "422": {
            "description": "INVALID_INPUT — the successor is not an active user"
          }
        }
      }
    },
    "/roles": {
      "get": {
        "x-required-scope": "users:read",
        "x-auth": "key",
        "summary": "List a company's roles",
        "description": "With per-role user counts. `?client_id` picks a company inside the\nkey's scope; defaults to the key's company.\n",
        "operationId": "listOrgRoles",
        "tags": [
          "Organization"
        ],
        "parameters": [
          {
            "name": "client_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Role list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "roles": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/OrgRole"
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`users:read` missing), or FORBIDDEN — client_id outside the key's scope"
          }
        }
      },
      "post": {
        "x-required-scope": "users:write",
        "x-auth": "key",
        "summary": "Create a role",
        "description": "Requires the key owner's manage_roles permission. Enum fields are\nvalidated against the shared lists (see GET /roles/permissions for the\naccepted values) — unknown values are a 400, unlike the lenient web\ndoor whose UI can only send valid ones. Snake_case aliases\n(credit_budget, budget_period, overage_action) are accepted. The\norg's enforce_roles budget policy applies.\n",
        "operationId": "createOrgRole",
        "tags": [
          "Organization"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "context": {
                    "type": "string"
                  },
                  "permissions": {
                    "type": "object",
                    "description": "{permissionId: boolean} — ids from GET /roles/permissions",
                    "additionalProperties": {
                      "type": "boolean"
                    }
                  },
                  "creditBudget": {
                    "type": "number",
                    "nullable": true
                  },
                  "budgetPeriod": {
                    "type": "string"
                  },
                  "overageAction": {
                    "type": "string"
                  },
                  "client_id": {
                    "type": "integer",
                    "description": "Defaults to the key's company; must be inside the key's scope"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created role"
          },
          "400": {
            "description": "Invalid input — unknown enum value, bad permissions shape, or a budget-policy violation"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`users:write` missing), or FORBIDDEN — the key's owner lacks `manage_roles`, or client_id outside the key's scope"
          }
        }
      }
    },
    "/roles/{roleId}": {
      "parameters": [
        {
          "name": "roleId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "users:read",
        "x-auth": "key",
        "summary": "Get one role",
        "description": "A role outside the key's scoped companies is a 404, never a 403 that would confirm it exists.",
        "operationId": "getOrgRole",
        "tags": [
          "Organization"
        ],
        "responses": {
          "200": {
            "description": "The role",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "role": {
                          "$ref": "#/components/schemas/OrgRole"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Role not found or outside the key's scope"
          }
        }
      },
      "patch": {
        "x-required-scope": "users:write",
        "x-auth": "key",
        "summary": "Update a role",
        "description": "A REAL patch, unlike the web PUT which always replaces the permission\nmap and budget triple wholesale (its editor UI always sends them):\nfields omitted from the body keep their current values. Requires the\nkey owner's manage_roles permission. System-role guards ride along\nfrom the shared hallway — a system role's permissions are immutable.\n",
        "operationId": "updateOrgRole",
        "tags": [
          "Organization"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "context": {
                    "type": "string"
                  },
                  "permissions": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "boolean"
                    }
                  },
                  "creditBudget": {
                    "type": "number",
                    "nullable": true
                  },
                  "budgetPeriod": {
                    "type": "string"
                  },
                  "overageAction": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated role"
          },
          "400": {
            "description": "Invalid input, or a system role's permissions were touched"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`users:write` missing), or FORBIDDEN — the key's owner lacks `manage_roles`"
          },
          "404": {
            "description": "Role not found or outside the key's scope"
          }
        }
      },
      "delete": {
        "x-required-scope": "users:write",
        "x-auth": "key",
        "summary": "Delete a role",
        "description": "System roles are never deletable — the shared hallway refuses.",
        "operationId": "deleteOrgRole",
        "tags": [
          "Organization"
        ],
        "responses": {
          "200": {
            "description": "Deleted"
          },
          "400": {
            "description": "Refused — a system role cannot be deleted"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`users:write` missing), or FORBIDDEN — the key's owner lacks `manage_roles`"
          },
          "404": {
            "description": "Role not found or outside the key's scope"
          }
        }
      }
    },
    "/roles/permissions": {
      "get": {
        "x-required-scope": "users:read",
        "x-auth": "key",
        "summary": "The assignable permission catalog",
        "description": "The same module the Role editor renders, so an API consumer building\na role can validate permission ids without scraping the UI: the\ngrouped form, a flat {id, label, description?, group} list, the\nimplication map (broader flags that also satisfy a narrower check),\nand the budget enums the role endpoints accept.\n\nDeliberately excluded: the internal platform-admin flags — those\nsubdivide Intuidy platform access, which no tenant role can hold and\nno API key can act with.\n",
        "operationId": "listRolePermissions",
        "tags": [
          "Organization"
        ],
        "responses": {
          "200": {
            "description": "The catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "groups": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "permissions": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "description": {
                                "type": "string"
                              },
                              "group": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "implies": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "budgetPeriods": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "overageActions": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `users:read`"
          }
        }
      }
    },
    "/devices": {
      "post": {
        "x-required-scope": null,
        "x-auth": "person",
        "summary": "Register this installation's push address",
        "description": "Stores the device token the credential's own user should receive\npushes on. Idempotent on `token`: a repeat refreshes `last_seen`; a\nregistration by another person re-points the row, because a token\nidentifies an installation, not a person.\n\nPushes follow the in-app notifications for approvals\n(`approval_required`) and interactive or team run completions\n(`agent_complete`); the badge is the user's unread count. A push\ncarries generic text from the type, `notification_id`, `type` and a\nsame-origin `link`; the client loads the title and message from\n`GET /notifications/{id}`. A company admin can opt the company into\nfull text in the alert.\n\nNo scope, but the credential must be the person: an OAuth sign-in or a\nuser-scope key. A company key, or a connection bound to another\nperson's key, gets `403 PERSON_CREDENTIAL_REQUIRED`.\nInternal identities are refused. The response never echoes the token.\n",
        "operationId": "registerDevice",
        "tags": [
          "Devices"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "token",
                  "platform",
                  "bundle_id"
                ],
                "properties": {
                  "token": {
                    "type": "string",
                    "description": "The provider's device token. For `apns`, 64–200 hexadecimal characters (stored lowercase)."
                  },
                  "platform": {
                    "type": "string",
                    "enum": [
                      "apns"
                    ],
                    "description": "The push provider"
                  },
                  "bundle_id": {
                    "type": "string",
                    "description": "The application identifier the provider knows the token under"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "device"
                    ],
                    "default": "device"
                  },
                  "environment": {
                    "type": "string",
                    "enum": [
                      "sandbox",
                      "production"
                    ],
                    "default": "production",
                    "description": "Which provider gateway holds the token"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registered (or refreshed)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "kind": {
                          "type": "string"
                        },
                        "platform": {
                          "type": "string"
                        },
                        "bundle_id": {
                          "type": "string"
                        },
                        "environment": {
                          "type": "string"
                        },
                        "created": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "last_seen": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Malformed body or field"
          },
          "401": {
            "description": "Missing or invalid credential, or an internal identity"
          },
          "429": {
            "description": "Too many registrations"
          }
        }
      }
    },
    "/devices/{token}": {
      "parameters": [
        {
          "name": "token",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "delete": {
        "x-required-scope": null,
        "x-auth": "person",
        "summary": "Stop pushes to this installation",
        "description": "Revokes the caller's own registration for the token. Another person's\ntoken is a 404, never a 403 that confirms it exists. The credential must be the person: an OAuth sign-in or a\nuser-scope key. A company key, or a connection bound to another\nperson's key, gets `403 PERSON_CREDENTIAL_REQUIRED`.\nInternal identities are refused.\n",
        "operationId": "unregisterDevice",
        "tags": [
          "Devices"
        ],
        "responses": {
          "200": {
            "description": "Revoked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "revoked": {
                          "type": "boolean"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Malformed token"
          },
          "401": {
            "description": "Missing or invalid credential, or an internal identity"
          },
          "404": {
            "description": "No registered device with that token for this user"
          }
        }
      }
    },
    "/notifications": {
      "get": {
        "x-required-scope": null,
        "x-auth": "person",
        "summary": "List the caller's own notifications",
        "description": "The inbox of the credential's own user, newest first. Dismissed\nnotifications are left out unless `status=dismissed` is asked for.\n`unread_count` is the badge a push carries. No scope, but the credential must be the person: an OAuth sign-in or a\nuser-scope key. A company key, or a connection bound to another\nperson's key, gets `403 PERSON_CREDENTIAL_REQUIRED`.\n",
        "operationId": "listNotifications",
        "tags": [
          "Notifications"
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "unread",
                "read",
                "dismissed"
              ]
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "A notification type, e.g. `approval_required`"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of notifications",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "notifications": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Notification"
                          }
                        },
                        "total": {
                          "type": "integer"
                        },
                        "unread_count": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "offset": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credential"
          }
        }
      },
      "patch": {
        "x-required-scope": null,
        "x-auth": "person",
        "summary": "Mark the caller's notifications read or dismissed",
        "description": "Marks the listed `ids`, or every unread notification with `all: true`.\nOnly the caller's own notifications change; other ids are ignored.\nAnswers the new unread count, so a client can update its badge.\n",
        "operationId": "markNotifications",
        "tags": [
          "Notifications"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ids": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  },
                  "all": {
                    "type": "boolean"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "read",
                      "dismissed"
                    ],
                    "default": "read"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Marked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "updated": {
                          "type": "integer"
                        },
                        "unread_count": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Neither `ids` nor `all`, a non-integer id, or an unknown status"
          },
          "401": {
            "description": "Missing or invalid credential"
          }
        }
      }
    },
    "/notifications/preferences": {
      "get": {
        "x-required-scope": null,
        "x-auth": "person",
        "summary": "Read the caller's own notification preferences",
        "description": "Which notification types the caller turned off (`disabledTypes`) and\nwhich data rules' \"blocked\" notices the caller muted (`mutedRuleIds`).\nThey apply before a notification is written, so a type turned off\nhere does not reach `GET /notifications` or any other door. No scope, but the credential must\nbe the person: an OAuth sign-in or a user-scope key. A company key,\nor a connection bound to another person's key, gets\n`403 PERSON_CREDENTIAL_REQUIRED`.\n",
        "operationId": "getNotificationPreferences",
        "tags": [
          "Notifications"
        ],
        "responses": {
          "200": {
            "description": "The caller's preferences (empty lists when none are set), the types that can be listed, and the rules the caller can mute",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "preferences": {
                          "$ref": "#/components/schemas/NotificationPreferences"
                        },
                        "types": {
                          "type": "array",
                          "description": "Every notification type the caller can receive, one entry each. A `locked` type cannot be turned off. A type sent only to platform admins is listed only for them.",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "group": {
                                "type": "string",
                                "enum": [
                                  "action",
                                  "update"
                                ]
                              },
                              "locked": {
                                "type": "boolean"
                              }
                            }
                          }
                        },
                        "rules": {
                          "type": "array",
                          "description": "The company's data rules, for an admin of them only; an empty list for everyone else.",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "enabled": {
                                "type": "boolean"
                              }
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credential"
          },
          "403": {
            "description": "PERSON_CREDENTIAL_REQUIRED — a company key, or a connection bound to another person's key"
          }
        }
      },
      "put": {
        "x-required-scope": null,
        "x-auth": "person",
        "summary": "Replace the caller's own notification preferences",
        "description": "Replaces both lists. The answer is what was stored: an unknown type,\nor a type that cannot be turned off (an approval waiting on the\ncaller, security, billing), is dropped.\n",
        "operationId": "setNotificationPreferences",
        "tags": [
          "Notifications"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationPreferences"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The stored preferences",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "preferences": {
                          "$ref": "#/components/schemas/NotificationPreferences"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body is not JSON"
          },
          "401": {
            "description": "Missing or invalid credential"
          },
          "403": {
            "description": "PERSON_CREDENTIAL_REQUIRED — a company key, or a connection bound to another person's key"
          }
        }
      }
    },
    "/notifications/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": null,
        "x-auth": "person",
        "summary": "Read one of the caller's notifications",
        "description": "The title, message and metadata of one notification. A push carries\nonly its id and generic text; the client loads the content here.\nAnother person's id is a 404.\n",
        "operationId": "getNotification",
        "tags": [
          "Notifications"
        ],
        "responses": {
          "200": {
            "description": "The notification",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Notification"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credential"
          },
          "404": {
            "description": "No notification with that id for this user"
          }
        }
      }
    },
    "/notifications/events": {
      "get": {
        "x-required-scope": null,
        "x-auth": "person",
        "summary": "Follow the caller's own inbox as server-sent events",
        "description": "The streaming twin of `GET /notifications`: hold this open and the\nbadge and list stay current without polling.\n\nFrames (`event:` names): `unread` — `{ unread_count }`, sent on open\nand whenever the badge changes without a new notification (mark read,\ndismiss, or a change made on another client); `notification` —\n`{ notification, unread_count }` for each new notification, shaped as\n`GET /notifications` lists it; `ping` every 15 seconds; `reconnect`\nafter four minutes; `error` with a code (`TOO_MANY_STREAMS` past four\nstreams per person on one server).\n\nThere is no replay: refresh the list once on open. The server\nre-counts unread on every `ping` and sends `unread` if it moved, so a\nmissed change corrects itself within 15 seconds.\n\nNo scope, but the credential must be the person: an OAuth sign-in or\na user-scope key. A company key, or a connection bound to another\nperson's key, gets `403 PERSON_CREDENTIAL_REQUIRED`.\n",
        "operationId": "streamNotifications",
        "tags": [
          "Notifications"
        ],
        "responses": {
          "200": {
            "description": "Server-sent events until the client leaves or `reconnect`",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "SSE frames — `unread`, `notification`, `ping`, `reconnect`, `error`"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credential"
          },
          "403": {
            "description": "The credential does not stand for one person"
          }
        }
      }
    },
    "/me": {
      "get": {
        "x-required-scope": null,
        "x-auth": "key",
        "x-scope-note": "Works with any valid API key or OAuth access token. It returns only the caller's own identity.",
        "summary": "Who this credential acts as",
        "description": "The person, company and organization the credential acts as, and the\ncredential itself: its kind, scopes, scope level and name (the OAuth\nclient's for a sign-in, the key's own and its prefix for a pasted\nkey). For a company key, or a connection bound to another person's\nkey, `user` is the key owner and `credential.acts_as_person` is\nfalse. Any valid credential, no scope. Never returns key material.\n",
        "operationId": "getMe",
        "tags": [
          "Identity"
        ],
        "responses": {
          "200": {
            "description": "The identity",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "user": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "id": {
                              "type": "integer"
                            },
                            "name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "first_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "last_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          }
                        },
                        "company": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "id": {
                              "type": "integer"
                            },
                            "name": {
                              "type": "string"
                            }
                          }
                        },
                        "organization": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "id": {
                              "type": "integer"
                            },
                            "name": {
                              "type": "string"
                            },
                            "single_company": {
                              "type": "boolean",
                              "description": "The one-company organization every company gets; hide organization chrome"
                            }
                          }
                        },
                        "credential": {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "enum": [
                                "oauth",
                                "key"
                              ]
                            },
                            "bound_to_key": {
                              "type": "boolean"
                            },
                            "acts_as_person": {
                              "type": "boolean"
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "scope_level": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "client_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "key_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "key_prefix": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credential"
          }
        }
      }
    },
    "/recent/views": {
      "get": {
        "x-required-scope": null,
        "x-auth": "person",
        "summary": "List the caller's recently viewed items",
        "description": "The credential's own user's recently viewed dashboards, workflows,\nnotebooks and agents, newest first. The same history the web Recent\npanel ranks on, so an item opened on any client moves up everywhere.\n\nIds only: join them to `GET /dashboards`, `GET /workflows`,\n`GET /notebooks` and `GET /agents`, which apply each family's own\nvisibility. An id that joins to nothing is an item the caller can no\nlonger see; skip it.\n\nNo scope, but the credential must be the person: an OAuth sign-in or\na user-scope key. A company key, or a connection bound to another\nperson's key, gets `403 PERSON_CREDENTIAL_REQUIRED`.\n",
        "operationId": "listRecentViews",
        "tags": [
          "Recent"
        ],
        "responses": {
          "200": {
            "description": "The view history",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "views": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/RecentView"
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credential"
          },
          "403": {
            "description": "The credential does not stand for one person"
          }
        }
      },
      "post": {
        "x-required-scope": null,
        "x-auth": "person",
        "summary": "Record that the caller opened an item",
        "description": "Stamps a view with the server's clock (a client time is never\naccepted) and answers the updated history. A repeat view of the same\nitem within 30 seconds is the same visit and changes nothing.\n",
        "operationId": "recordRecentView",
        "tags": [
          "Recent"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "type",
                  "id"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "dashboard",
                      "workflow",
                      "notebook",
                      "agent"
                    ]
                  },
                  "id": {
                    "type": "integer",
                    "minimum": 1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Recorded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "views": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/RecentView"
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unknown type or a non-positive id"
          },
          "401": {
            "description": "Missing or invalid credential"
          },
          "403": {
            "description": "The credential does not stand for one person"
          }
        }
      }
    },
    "/home/summary": {
      "get": {
        "x-required-scope": null,
        "x-auth": "person",
        "summary": "The counts a home screen opens on",
        "description": "One call for a home screen's badges: the unread notification count,\nwhat waits for this person's approval, and their own runs still\nrunning.\n\n`approvals.held_actions` counts held tool calls the caller can release\nnow: their own, or everyone's for a person with org AI-governance\npermission. `approvals.held_runs` counts paused missions on the same\nrule. `approvals.total` is the sum.\n\nA family the credential has no scope for is `null`, not 0:\n`approvals` needs `approvals:read`, `running_runs` needs\n`agents:read` or `agents:execute`. No scope is needed to call the\ndoor, but the credential must be the person: an OAuth sign-in or a\nuser-scope key. A company key, or a connection bound to another\nperson's key, gets `403 PERSON_CREDENTIAL_REQUIRED`.\n",
        "operationId": "getHomeSummary",
        "tags": [
          "Home"
        ],
        "responses": {
          "200": {
            "description": "The counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "unread_count": {
                          "type": "integer"
                        },
                        "approvals": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "held_actions": {
                              "type": "integer"
                            },
                            "held_runs": {
                              "type": "integer"
                            },
                            "total": {
                              "type": "integer"
                            }
                          }
                        },
                        "running_runs": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid credential"
          },
          "403": {
            "description": "The credential does not stand for one person"
          }
        }
      }
    },
    "/auth/web-handoff": {
      "post": {
        "x-required-scope": null,
        "x-auth": "key",
        "x-scope-note": "Takes an OAuth access token (vat_) only. An API key (vntg_) is refused.",
        "summary": "Mint a one-time URL that signs an embedded web view in",
        "description": "For a client that signed in through OAuth and holds a `vat_` access\ntoken. Web-shaped screens need the browser session cookie; this door\nturns the token into a one-time handoff URL so the person is not asked\nto sign in again. Load `handoff_url` in the web view: the server burns\nthe code, sets the session cookie there, and redirects to `return_to`.\n\nOAuth access tokens only. An AIPI key is refused with `403\nOAUTH_IDENTITY_REQUIRED`, so a leaked key can never become a browser\nsession. A token issued to any client other than the first-party one\n(a per-install public client, a connector) is refused with `403\nFIRST_PARTY_CLIENT_REQUIRED`: the person can sign in again through the\nfirst-party client. No route scope is required beyond a valid token.\n\nThe code lives 60 seconds and is single-use. The session it mints is\ncapped at 24 hours regardless of later renewals; repeat the handoff\nwhenever a web view opens. Revoking the connection refuses new handoffs\nat once. Rate-limited per IP beside the per-credential ceiling.\n",
        "operationId": "mintWebHandoff",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "return_to": {
                    "type": "string",
                    "description": "A same-origin path to land on after sign-in (default `/`). A scheme, host or protocol-relative value falls back to `/`.",
                    "example": "/workflow/12"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The handoff URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "handoff_url": {
                          "type": "string",
                          "description": "Load this in the web view; it carries the one-time code",
                          "example": "https://intuidy.example.com/auth/handoff?code=vho_…"
                        },
                        "expires_in": {
                          "type": "integer",
                          "description": "Seconds the code can be redeemed",
                          "example": 60
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Body is not a JSON object, or return_to is not a string"
          },
          "401": {
            "description": "Missing or invalid credential"
          },
          "403": {
            "description": "The credential is an AIPI key, not an OAuth access token (OAUTH_IDENTITY_REQUIRED), or a token from a client other than the first-party one (FIRST_PARTY_CLIENT_REQUIRED)"
          },
          "429": {
            "description": "Too many handoffs"
          }
        }
      }
    },
    "/approvals": {
      "get": {
        "x-required-scope": "approvals:read",
        "x-auth": "key",
        "summary": "The approvals inbox",
        "description": "Two kinds of things wait for a human here: `held_actions` — single\ntool calls the policy gate denied in a non-interactive run because a\ndata-governance rule demanded a human — and `held_runs` — hibernated team missions waiting on human\ninput, each carrying its `hitl_request`.\n\nHeld actions are listed in the REDACTED shape: `args_preview` only.\nThe full args live behind GET /approvals/actions/{actionId}, the\ninformed-approval door — read the detail before you approve.\n\nA key owner without `manage_ai_org_snippets` still sees other users'\nholds, but each one comes back with `args_preview: {}` and\n`args_redacted: true`. The owner's own holds are not redacted.\n\n`held_runs` lists the key owner's own paused missions, or the whole\ncompany's when the owner holds `manage_ai_org_snippets` (the same bar\nthat resuming another user's mission requires).\n",
        "operationId": "listApprovals",
        "tags": [
          "Approvals"
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "held",
                "releasing",
                "released",
                "rejected",
                "failed",
                "expired",
                "decided",
                "all"
              ],
              "default": "held"
            },
            "description": "Held-actions filter (held_runs are always current). `decided` is the decision history, every settled action, including decisions made in a chat or on a dashboard."
          },
          {
            "name": "agent_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "triage",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "exception",
                "reusable",
                "system_gap"
              ]
            },
            "description": "Only settled decisions filed under this triage bin (use with `status=all` or a settled status)"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The inbox",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "held_actions": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/HeldAction"
                          }
                        },
                        "held_runs": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "job_id": {
                                "type": "integer"
                              },
                              "team_id": {
                                "type": "integer"
                              },
                              "title": {
                                "type": "string",
                                "nullable": true
                              },
                              "hitl_request": {
                                "nullable": true
                              },
                              "held_at": {
                                "type": "string",
                                "format": "date-time",
                                "nullable": true
                              }
                            }
                          }
                        },
                        "counts": {
                          "type": "object",
                          "properties": {
                            "held_actions": {
                              "type": "integer"
                            },
                            "held_runs": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unknown status value"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `approvals:read`"
          }
        }
      }
    },
    "/approvals/actions/{actionId}": {
      "parameters": [
        {
          "name": "actionId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "approvals:read",
        "x-auth": "key",
        "summary": "One held action, args included",
        "description": "Deliberately the ONLY place the raw held args are readable: approving\na call is only meaningful when the approver saw exactly what it will\ndo, and a list is not where anyone reads carefully. Read this before\nyou POST approve.\n",
        "operationId": "getHeldAction",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Full detail including raw args",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "held_action": {
                          "$ref": "#/components/schemas/HeldActionDetail"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `approvals:read`"
          },
          "404": {
            "description": "Held action not found"
          }
        }
      },
      "post": {
        "x-required-scope": "approvals:write",
        "x-scope-note": "Approving with edited `args` also needs `agents:execute`, the scope that starts an agent run, because an edit is a new tool call. Approving the call as proposed, rejecting and triaging need `approvals:write` only.",
        "x-auth": "key",
        "summary": "Release, reject or triage a held action",
        "description": "`{ action: \"approve\", reason?, args? }` RELEASES the hold: the held\ncall executes through the real headless tool registry, as the key's\nuser, right now — this is the previously denied write actually going\nout, marked approved the way the interactive consume path marks it.\nSend `args` (the complete argument object, not a patch) to run the\ncall with edited arguments in place of the proposed ones: today's\ndata rules are applied to the edit, the proposal stays readable as\n`args`, and what ran is `edited_args` with `changed_keys`. An edit\nis a new tool call, so the key also needs `agents:execute` (the\nscope that starts an agent run); without it the door answers\n`403 INSUFFICIENT_SCOPE` and runs nothing. Omit `args` to approve\nthe call as proposed with `approvals:write` alone.\n`{ action: \"reject\", reason? }` settles it without executing.\n`{ action: \"triage\", bin, note? }` files a SETTLED action under\n`exception` (a one-off, kept as context; teaches nothing),\n`reusable` (a decision that should hold next time: one lesson is\nwritten into the agent's memory and shown to the agent beside that\ntool on its later runs) or `system_gap` (the ontology, a constraint\nor a workflow should change: the note, or else the decision reason,\ngoes to the Learned knowledge review queue as a pending fact). It\nruns nothing. A later triage replaces the earlier one and withdraws\nwhat it wrote; `learning` in the response says what happened.\n\nReleasing a hold that belongs to a DIFFERENT user is an\norg-governance act — allowed only when the key owner holds\n`manage_ai_org_snippets`; releasing your own is not.\n",
        "operationId": "settleHeldAction",
        "tags": [
          "Approvals"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "action"
                ],
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "approve",
                      "reject",
                      "triage"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why the action is approved or rejected. Kept with the decision."
                  },
                  "args": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "approve only. The complete arguments to run in place of the proposed ones. Needs `agents:execute` as well as `approvals:write`."
                  },
                  "bin": {
                    "type": "string",
                    "enum": [
                      "exception",
                      "reusable",
                      "system_gap"
                    ],
                    "description": "triage only (required there)"
                  },
                  "note": {
                    "type": "string",
                    "description": "triage only. What was learned. For `system_gap`, what should change; it becomes the fact a person reviews."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The settled action. A release carries the execution result; a triage carries `triage` and `learning`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "held_action": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "integer"
                            },
                            "tool": {
                              "type": "string",
                              "nullable": true
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "released",
                                "rejected",
                                "failed",
                                "expired"
                              ],
                              "description": "`released` or `failed` after an approve, `rejected` after a reject, and the settled status a triage filed"
                            },
                            "result_status": {
                              "type": "string",
                              "description": "approve only. `ok` when the call succeeded, `error` when it failed."
                            },
                            "summary": {
                              "type": "string",
                              "description": "approve only. A short, credential-masked summary of what the call returned."
                            },
                            "edited": {
                              "type": "boolean",
                              "description": "approve only. Whether the call ran with edited arguments."
                            },
                            "changed_keys": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "type": "string"
                              },
                              "description": "approve only. The top-level argument keys the edit changed; null when the call was not edited."
                            },
                            "triage": {
                              "type": "object",
                              "description": "triage only. How the decision is now filed.",
                              "properties": {
                                "bin": {
                                  "type": "string",
                                  "enum": [
                                    "exception",
                                    "reusable",
                                    "system_gap"
                                  ]
                                },
                                "label": {
                                  "type": "string"
                                },
                                "note": {
                                  "type": "string"
                                },
                                "by": {
                                  "type": "integer",
                                  "nullable": true
                                },
                                "at": {
                                  "type": "string",
                                  "format": "date-time",
                                  "nullable": true
                                }
                              }
                            },
                            "learning": {
                              "$ref": "#/components/schemas/DecisionLearning"
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body or unknown action"
          },
          "402": {
            "description": "The release's execution hit a billing limit"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`approvals:write` missing, or `agents:execute` missing on an approve with edited `args`), or FORBIDDEN — the hold belongs to another user and the key's owner lacks `manage_ai_org_snippets`"
          },
          "404": {
            "description": "Held action not found"
          },
          "409": {
            "description": "Already settled, or being settled by someone else right now; for triage, not settled yet"
          },
          "422": {
            "description": "The hold expired or cannot be executed as held; `args` is not an object or is too large; unknown `bin`"
          }
        }
      }
    },
    "/approvals/runs/{jobId}": {
      "parameters": [
        {
          "name": "jobId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "approvals:write",
        "x-auth": "key",
        "summary": "Resume or reject a hibernated team mission",
        "description": "`{ action: \"approve\", input }` re-enters the team orchestration with\nthe human response the mission's `hitl_request` asked for (read it\nvia GET /approvals first), fires it DETACHED, and answers with the\njob id and a `poll_url` on the standard run-status door.\n`{ action: \"reject\", reason? }` settles the mission failed with a\nnote saying who declined; nothing resumes.\n\nResuming a mission that belongs to a DIFFERENT user is org\ngovernance, same rule as releasing another user's held action: the\nkey owner must hold `manage_ai_org_snippets`.\n",
        "operationId": "settleHeldRun",
        "tags": [
          "Approvals"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "action"
                ],
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "approve",
                      "reject"
                    ]
                  },
                  "input": {
                    "type": "string",
                    "description": "The human response the mission asked for (approve)"
                  },
                  "reason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resumed (job id + poll_url) or rejected"
          },
          "400": {
            "description": "Invalid body or unknown action"
          },
          "402": {
            "description": "The resume hit a billing limit"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`approvals:write` missing), or FORBIDDEN — the mission belongs to another user and the key's owner lacks `manage_ai_org_snippets`"
          },
          "404": {
            "description": "No hibernating run with this id"
          },
          "409": {
            "description": "The mission is no longer waiting"
          }
        }
      }
    },
    "/approvals/grants": {
      "get": {
        "x-required-scope": "approvals:read",
        "x-auth": "key",
        "summary": "The key owner's standing tool grants",
        "description": "The \"always allow\" grants — tool, agent scope, expiry, provenance.\nSELF-ONLY BY CONSTRUCTION: every read and write here targets the\nkey's owner. The approval policy is a per-user settings row, and a\nuser-delegated key managing that user's own grants is the user\nacting. There is deliberately no way to name another user.\n",
        "operationId": "listApprovalGrants",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "The standing grants",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "grants": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `approvals:read`"
          }
        }
      },
      "post": {
        "x-required-scope": "approvals:write",
        "x-auth": "key",
        "summary": "Grant a tool \"always allow\"",
        "description": "Grants are stamped source `api`, so the Approvals UI shows exactly\nwhich door granted them. `agent_id` scopes the grant to one agent;\nomitted, it applies across all agents.\n",
        "operationId": "createApprovalGrant",
        "tags": [
          "Approvals"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tool_name"
                ],
                "properties": {
                  "tool_name": {
                    "type": "string"
                  },
                  "agent_id": {
                    "type": "integer"
                  },
                  "expires_in_days": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated grant list"
          },
          "400": {
            "description": "Missing tool_name, bad agent_id, or a shape refusal (over-length name, bad expiry)"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `approvals:write`"
          }
        }
      },
      "delete": {
        "x-required-scope": "approvals:write",
        "x-auth": "key",
        "summary": "Revoke a standing grant",
        "description": "`?tool_name=<name>` alone revokes the tool in EVERY scope (the\nhistorical revoke); `&agent_id=<n>` revokes that agent's grant only;\n`&agent_id=global` revokes only the all-agents grant.\n",
        "operationId": "revokeApprovalGrant",
        "tags": [
          "Approvals"
        ],
        "parameters": [
          {
            "name": "tool_name",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agent_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "A positive integer, or the literal `global`"
          }
        ],
        "responses": {
          "200": {
            "description": "The updated grant list"
          },
          "400": {
            "description": "Missing tool_name or a bad agent_id"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `approvals:write`"
          }
        }
      }
    },
    "/notebooks": {
      "get": {
        "x-required-scope": "notebooks:read",
        "x-auth": "key",
        "summary": "List notebooks reachable by this key",
        "description": "Summaries only — `cells` can be large enough to make paging meaningless, so fetch a notebook's content with GET /notebooks/{notebookId}.\nReach is the key owner's own: their notebooks, plus the ones shared with their company or organization. A notebook whose owner scoped its sharing to their own company is not listed to a sibling company, and each row carries an `access` object saying whether this key may write to it.\n",
        "operationId": "listNotebooks",
        "tags": [
          "Notebooks"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Notebooks",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "notebooks": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "integer"
                              },
                              "title": {
                                "type": "string"
                              },
                              "is_shared": {
                                "type": "boolean"
                              },
                              "owner_id": {
                                "type": "integer",
                                "nullable": true
                              },
                              "created": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "modified": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "access": {
                                "type": "object",
                                "properties": {
                                  "level": {
                                    "type": "string",
                                    "nullable": true,
                                    "enum": [
                                      "owner",
                                      "company",
                                      "organization",
                                      null
                                    ]
                                  },
                                  "can_write": {
                                    "type": "boolean"
                                  }
                                }
                              }
                            }
                          }
                        },
                        "total": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "x-required-scope": "notebooks:write",
        "x-auth": "key",
        "summary": "Create a notebook",
        "description": "Creates a notebook owned by the key's user, private until shared.",
        "operationId": "createNotebook",
        "tags": [
          "Notebooks"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title"
                ],
                "properties": {
                  "title": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "cells": {
                    "type": "object",
                    "description": "Canonical content, shaped as an object with a \"sections\" array; each section carries a title, a type and its own \"cells\" array. A bare array of cells is accepted and migrated into one section.\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Notebook created"
          },
          "400": {
            "description": "Title is required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/notebooks/{notebookId}": {
      "parameters": [
        {
          "name": "notebookId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "notebooks:read",
        "x-auth": "key",
        "summary": "Get a notebook and its cells",
        "description": "Returns the canonical content shape PATCH accepts, so a read → edit → write round-trip needs no reshaping.\nA notebook this key cannot reach is a 404, never a 403 — a 403 would confirm the notebook exists to a caller enumerating ids.\n",
        "operationId": "getNotebook",
        "tags": [
          "Notebooks"
        ],
        "responses": {
          "200": {
            "description": "Notebook"
          },
          "404": {
            "description": "Notebook not found or not reachable by this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "x-required-scope": "notebooks:write",
        "x-auth": "key",
        "summary": "Replace a notebook's cells",
        "description": "Requires WRITE access, which is not the same as being able to read it. A notebook's owner can share it read-only, or mark individual people as viewers; this door refuses those callers with a 403, exactly as the web editor does.\nWrites go through the guarded writer: the notebook is snapshotted first (so the change is recoverable from version history) and a concurrent edit is refused with a 409 rather than overwritten.\n",
        "operationId": "updateNotebookCells",
        "tags": [
          "Notebooks"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cells": {
                    "type": "object",
                    "description": "Canonical { \"sections\": [...] } content, or a bare array of cells. Charts, pivots and metrics that name no source are linked to the nearest data cell (query / compute / workflow_source)."
                  },
                  "refresh": {
                    "type": "object",
                    "nullable": true,
                    "description": "Scheduled server-side refresh of the notebook's data cells. `null` turns it off. One of `cells` or `refresh` is required.\n",
                    "properties": {
                      "enabled": {
                        "type": "boolean"
                      },
                      "interval_minutes": {
                        "type": "integer",
                        "enum": [
                          15,
                          30,
                          60,
                          180,
                          360,
                          720,
                          1440,
                          10080
                        ],
                        "description": "Default 1440 (daily)"
                      },
                      "alert_user_ids": {
                        "type": "array",
                        "items": {
                          "type": "integer"
                        },
                        "description": "Extra users notified when a metric cell crosses its alert threshold"
                      },
                      "stale_after_hours": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Notebook updated"
          },
          "403": {
            "description": "You have view-only access to this notebook",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The notebook changed while this write was in flight",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Content shape rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "x-required-scope": "notebooks:write",
        "x-auth": "key",
        "summary": "Delete a notebook",
        "description": "Permanently deletes a notebook.\nDeletion is the owner's, or an administrator's of the company or organization that owns it. A sharing grant never confers it, however generous — being able to edit a notebook is not being able to destroy it.\n",
        "operationId": "deleteNotebook",
        "tags": [
          "Notebooks"
        ],
        "responses": {
          "204": {
            "description": "Notebook deleted"
          },
          "403": {
            "description": "Only the owner or a company administrator can delete this notebook",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Notebook not found or not reachable by this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/notebooks/{notebookId}/export": {
      "parameters": [
        {
          "name": "notebookId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "format",
          "in": "query",
          "required": false,
          "schema": {
            "type": "string",
            "enum": [
              "markdown",
              "html",
              "pdf"
            ],
            "default": "pdf"
          }
        }
      ],
      "get": {
        "x-required-scope": "notebooks:read",
        "x-auth": "key",
        "summary": "Export a notebook as a file",
        "description": "The same document a user downloads from the editor: markdown, standalone HTML (charts rendered as inline SVG, pivots and metrics computed, provenance on every data cell) or PDF. The response IS the file (see Content-Type and Content-Disposition), not a JSON envelope.\nRequires the key owner to hold the `export_data` permission, applies the notebook's read access (including its in-document sharing settings) and data governance for the export channel, and meters one `notebook_export`.\n",
        "operationId": "exportNotebook",
        "tags": [
          "Notebooks"
        ],
        "responses": {
          "200": {
            "description": "The exported file",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing export_data permission, or blocked by data governance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Notebook not found or not reachable by this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/notebooks/{notebookId}/run": {
      "parameters": [
        {
          "name": "notebookId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "notebooks:write",
        "x-auth": "key",
        "summary": "Run a notebook's data cells and save the results",
        "description": "Executes every SQL query, compute (sandboxed JavaScript) and workflow-source cell of the notebook server-side — sources first, then compute cells after the cells they read — and persists each result snapshot with its provenance, so the charts, pivots and metrics that read them are current. The same hallway the agent's `run_notebook_cells` tool and the editor's Refresh use.\nRequires WRITE access (results are content). Each cell bills its own operation (database_query, notebook_compute_run, workflow_run).\n**Scopes.** `notebooks:write` admits the run, but it does not widen what the key reaches. A query cell runs connector SQL, so it also needs `integrations:read`; a workflow-source cell executes a workflow, so it also needs `workflows:execute` — the scopes those capabilities require at their own endpoints. A cell the key may not reach is reported as a failed cell in `ran` (with the missing scope named in its `error`), not as a failed request, so the cells the key MAY run still run.\n",
        "operationId": "runNotebookCells",
        "tags": [
          "Notebooks"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cell_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Only these cell ids (default every data cell)"
                  },
                  "skip_cache": {
                    "type": "boolean",
                    "description": "Re-run workflow sources instead of using their cached result"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-cell outcome",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "notebook_id": {
                      "type": "integer"
                    },
                    "ran": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "cell_id": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "query",
                              "compute",
                              "workflow_source"
                            ]
                          },
                          "title": {
                            "type": "string"
                          },
                          "ok": {
                            "type": "boolean"
                          },
                          "row_count": {
                            "type": "integer"
                          },
                          "error": {
                            "type": "string",
                            "nullable": true
                          },
                          "sample": {
                            "type": "array",
                            "items": {
                              "type": "object"
                            },
                            "description": "First 5 rows"
                          }
                        }
                      }
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "modified": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Billing required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "You have view-only access to this notebook",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Notebook not found or not reachable by this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/dashboards": {
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "List dashboards reachable by this key",
        "operationId": "listDashboards",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 100
            }
          },
          {
            "name": "kind",
            "in": "query",
            "description": "Narrow to one kind of board. The kind is derived from each board's\nattributes and tab layouts (see `DashboardSummary.kind`). An\nunrecognised value is ignored and everything is returned, rather\nthan an empty page that would read as data loss.\n",
            "schema": {
              "type": "string",
              "enum": [
                "dashboard",
                "generative",
                "html"
              ]
            }
          },
          {
            "name": "feature",
            "in": "query",
            "description": "Narrow by what a board does, as the Dashboards index facets do.\n`generative` keeps boards with generated-content upkeep on\n(`features.generative`). `pages` keeps boards with at least one tab\nthat shows an HTML page. `all` keeps every board. Unlike `kind`,\nthis finds a board with both grid and page tabs, and a generative\nboard whose tabs are all pages. An unrecognised value is ignored.\n",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "generative",
                "pages"
              ]
            }
          },
          {
            "name": "has",
            "in": "query",
            "description": "`pages` keeps boards with at least one tab that shows an HTML page,\nas the index search `has:pages` finds them. An unrecognised value\nis ignored.\n",
            "schema": {
              "type": "string",
              "enum": [
                "pages"
              ]
            }
          },
          {
            "name": "folder_id",
            "in": "query",
            "description": "Only items filed directly in this folder (either tree; see the\nfolders endpoint). `root` returns the items not filed in the\ncompany's shared tree. An unknown folder is a 404.\n",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Dashboard list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboards": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "integer"
                              },
                              "name": {
                                "type": "string"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "dashboard",
                                  "generative",
                                  "html"
                                ]
                              },
                              "is_shared": {
                                "type": "boolean"
                              },
                              "tile_count": {
                                "type": "integer"
                              },
                              "icon": {
                                "type": "string",
                                "nullable": true,
                                "description": "The board's icon (a lucide icon name)"
                              },
                              "tags": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "description": "The tags the Dashboards index searches with tag:"
                              },
                              "folder_id": {
                                "type": "string",
                                "nullable": true,
                                "description": "Folder in the company's shared tree"
                              },
                              "my_folder_id": {
                                "type": "string",
                                "nullable": true,
                                "description": "Folder in the key owner's own tree"
                              },
                              "created": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "modified": {
                                "type": "string",
                                "format": "date-time"
                              }
                            }
                          }
                        },
                        "total": {
                          "type": "integer"
                        },
                        "page": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `dashboards:read`"
          }
        }
      },
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Create a dashboard",
        "description": "Parity with the web save door and the MCP `create_dashboard` tool: all\nthree mint a row through the same hallway, so a board created over\nREST is indistinguishable from one created in the browser — same row,\nsame meta row, same kind rules.\n\nA board starts from `attributes` (see `DashboardAttributes`), from a\nlegacy `kind` preset, or from the defaults. `kind` is kept for older\ncallers: `html` starts a board whose tabs are locked to HTML pages,\n`generative` one with generated-content upkeep on, `dashboard` the\ndefaults. Nothing is fixed at create — change the attributes with\n`PUT /dashboards/{dashboardId}/settings/attributes` and a tab's layout\nwith `PATCH /dashboards/{dashboardId}/tabs/{tabId}`. An unrecognised\nkind is refused rather than coerced.\n",
        "operationId": "createDashboard",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "overview": {
                    "type": "string",
                    "nullable": true
                  },
                  "attributes": {
                    "$ref": "#/components/schemas/DashboardAttributesPatch"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "dashboard",
                      "generative",
                      "html"
                    ],
                    "default": "dashboard",
                    "description": "A legacy preset; prefer `attributes`"
                  },
                  "is_shared": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The created dashboard",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboard": {
                          "$ref": "#/components/schemas/DashboardSummary"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_BODY — name missing or empty; INVALID_ATTRIBUTES — an unknown attribute or a value of the wrong type (the message names each)"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — key lacks `dashboards:write`"
          },
          "409": {
            "description": "The attributes combine in a way the rules refuse (GENERATIVE_NEEDS_GRID, HIDE_CURSOR_NEEDS_OPEN_FULLSCREEN), or a seeded tab's layout fights the tab-layout lock (TAB_LAYOUT_LOCKED)"
          },
          "422": {
            "description": "invalid_dashboard_kind — kind is not one of dashboard, generative, html"
          }
        }
      }
    },
    "/dashboards/generate/estate": {
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "What a dashboard brief can be written against",
        "description": "The managed-database tables, workflows, connected integrations and\ndescribed objects this key can reach — the estate a generative\ndashboard is planned over. Each integration carries `readable`, the\ncount of read operations a plan may source a dataset from (source\nkind `integration`: the operation's records, flattened, one row per\nrecord). Deterministic and free (no model call, no integration\nreads); memoized for five minutes per key user. Read it before\nplanning so the brief names sources that exist.\n\nRequires the `view_dashboard` permission on the key's user.\n",
        "operationId": "getDashboardEstate",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "The estate summary",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "estate": {
                          "type": "object",
                          "properties": {
                            "tables": {
                              "type": "array",
                              "items": {
                                "type": "object"
                              }
                            },
                            "workflows": {
                              "type": "array",
                              "items": {
                                "type": "object"
                              }
                            },
                            "integrations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "serviceKey": {
                                    "type": "string"
                                  },
                                  "label": {
                                    "type": "string"
                                  },
                                  "readable": {
                                    "type": "integer",
                                    "description": "Read operations a plan may source a dataset from"
                                  }
                                }
                              }
                            },
                            "describedObjects": {
                              "type": "integer"
                            },
                            "industry": {
                              "type": "string",
                              "nullable": true
                            },
                            "errors": {
                              "type": "array",
                              "items": {
                                "type": "object"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          }
        }
      }
    },
    "/dashboards/generate/plan": {
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Plan a generative dashboard from a brief",
        "description": "One planning call (token-metered, billed to the key's tenant) returns\na storyboard — sections, datasets, tiles — with an itemized credit\nestimate of building it. Nothing is created; the storyboard is a\npending plan (`planId`) the caller edits and then approves through\n`/dashboards/generate/materialize`. Pending plans expire after 24\nhours.\n\nThe same hallway and gates as the in-app composer: the key's user\nneeds `edit_dashboard`, AI enabled and an account in good billing\nstanding.\n",
        "operationId": "planDashboard",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "brief"
                ],
                "properties": {
                  "brief": {
                    "type": "string",
                    "maxLength": 2000,
                    "description": "What the dashboard should show, and for whom"
                  },
                  "audience": {
                    "type": "string",
                    "enum": [
                      "executive",
                      "operator",
                      "analyst"
                    ],
                    "default": "executive"
                  },
                  "sourceHints": {
                    "type": "array",
                    "maxItems": 20,
                    "items": {
                      "type": "string"
                    },
                    "description": "Pin sources: 'managed-db:<id>', 'workflow:<id>' or 'integration:<serviceKey>' (a pinned integration's read operations are sampled for the planner even when the brief does not name the service)"
                  },
                  "notes": {
                    "type": "string",
                    "maxLength": 1000,
                    "description": "Re-plan notes — what to change from previousPlan"
                  },
                  "previousPlan": {
                    "type": "object",
                    "description": "The plan to revise, from an earlier reply"
                  },
                  "dashboardId": {
                    "type": "integer",
                    "description": "When re-planning an existing generative board, or planning a tab of an existing board. Refused with 409 `TABS_LOCKED_TO_PAGES` when that board's `layout.tabLayouts` is `page`."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The storyboard and its estimate",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "planId": {
                          "type": "string"
                        },
                        "plan": {
                          "type": "object"
                        },
                        "layout": {
                          "type": "object"
                        },
                        "estimate": {
                          "type": "object"
                        },
                        "grounding": {
                          "type": "object"
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "dropped": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "expiresAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "noData": {
                          "type": "boolean",
                          "description": "True when no tile on the plan reads data (no listed source answered the brief). Such a storyboard cannot be built — `/dashboards/generate/materialize` refuses it with `NO_DATA_TILES` — plan again with a source."
                        },
                        "remedies": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Present when `noData` — what would make the brief answerable (connect a database or integration holding the data; name a workflow that already produces it; add a note and re-plan)"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "402": {
            "description": "Billing required — the tenant is out of credits"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "409": {
            "description": "TABS_LOCKED_TO_PAGES — `dashboardId` names a board whose `layout.tabLayouts` attribute is `page`, so it cannot take a build. Refused before the planning call, so nothing is billed."
          },
          "422": {
            "description": "The plan exceeds a limit (`PLAN_OVER_LIMIT`)"
          }
        }
      }
    },
    "/dashboards/generate/materialize": {
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Approve a storyboard and build the dashboard",
        "description": "Creates the (empty) generative board synchronously and starts the\nbuild job that binds datasets, writes the tiles and enriches them.\nPoll `/dashboards/{dashboardId}/generate/status` for progress; the\nin-app SSE stream is the browser's view of the same job.\n\nRefused with `BUILD_IN_PROGRESS` (409) while the key's user already\nhas a build running, with `ESTIMATE_CHANGED` (409) when the fresh\nestimate exceeds `acceptedEstimate` by more than the tolerance, and\nwith `NO_DATA_TILES` (422) when the storyboard has no tile that reads\ndata (the plan reply said `noData: true`) — plan again with a source.\n",
        "operationId": "materializeDashboard",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "planId"
                ],
                "properties": {
                  "planId": {
                    "type": "string"
                  },
                  "edits": {
                    "type": "object",
                    "description": "Storyboard edits: { title?, tiles?: [{ id, drop?, title?, type?, intent?, locked? }], datasets?: [{ id, sql? }] }. `locked: true` builds the tile exactly as written and keeps it as-is through every later refine and regeneration."
                  },
                  "acceptedEstimate": {
                    "type": "number",
                    "description": "The `toMaterialize` estimate the caller accepted"
                  },
                  "target": {
                    "type": "object",
                    "description": "Build into an EXISTING board instead of creating one. The\nbuild goes into `tabId` when that tab is an empty grid tab;\notherwise (or with no `tabId`) into a new tab, and a tab\nthat holds tiles is never cleared. Refused with\n`TABS_LOCKED_TO_PAGES` (409) on a board whose\n`layout.tabLayouts` attribute is `page`, and with\n`INVALID_TARGET` (400) for a malformed target. The first\nbuild into a board turns its `features.generative`\nattribute on.\n",
                    "required": [
                      "dashboardId"
                    ],
                    "properties": {
                      "dashboardId": {
                        "type": "integer"
                      },
                      "tabId": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The board and its build job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboardId": {
                          "type": "integer"
                        },
                        "jobId": {
                          "type": "string"
                        },
                        "generationId": {
                          "type": "string"
                        },
                        "estimate": {
                          "type": "object"
                        },
                        "queuePosition": {
                          "type": "integer"
                        },
                        "tabId": {
                          "type": "string",
                          "description": "The tab the build goes into (a build into an existing board)"
                        },
                        "tabCreated": {
                          "type": "boolean",
                          "description": "Whether the build opened a new tab for itself"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "402": {
            "description": "Billing required — the tenant is out of credits"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "404": {
            "description": "The storyboard was not found or has expired (`PLAN_NOT_FOUND`)"
          },
          "409": {
            "description": "A build is already running, or the estimate changed"
          },
          "422": {
            "description": "Nothing on the storyboard reads data (`NO_DATA_TILES`; `detail.remedies` says what would fix it), an edited SQL was refused (`DATASET_SQL_REFUSED`), or the plan exceeds a limit (`PLAN_OVER_LIMIT`)"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/generate/status": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "A generative board's generation record and any live build",
        "description": "The board's generative row (mode, plan, datasets, headline band, the\nthree most recent generations) and the running build job, if any.\nSame access rule as reading the dashboard.\n",
        "operationId": "getDashboardGenerationStatus",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "The generation record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "generative": {
                          "type": "object",
                          "nullable": true
                        },
                        "job": {
                          "type": "object",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "404": {
            "description": "Dashboard not found"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/generate/regenerate": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Recompute a board's AI layer from live rows",
        "description": "Recomputes the board's AI layer from live rows: the per-tile insight\ncaptions, callouts, section takeaways, the headline band and the\nproposed actions (any stock AI tiles an older board carries —\nsummary, forecast, predictiveinsights, biintelligence,\nscenarioplanner — go through the AI-result hallway, forced).\nBilled. Only the company that owns the board may regenerate it; the\nkey's user needs `edit_dashboard`, AI enabled and billing standing.\n\nOn a board whose `features.generative` attribute is off, only the AI\ntiles are recomputed. The insight captions, the headline band and the\nactions are skipped: `band` and `actions` are null and `upkeep` is\nfalse.\n",
        "operationId": "regenerateDashboardAi",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tileIds": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "description": "Only these tiles; omit for every AI tile"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-tile outcomes, the new band and the re-proposed actions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "results": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "tileId": {
                                "type": "integer"
                              },
                              "kind": {
                                "type": "string"
                              },
                              "ok": {
                                "type": "boolean"
                              },
                              "cached": {
                                "type": "boolean"
                              },
                              "error": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "band": {
                          "type": "object",
                          "nullable": true
                        },
                        "actions": {
                          "type": "object",
                          "nullable": true,
                          "description": "The proposal made from the new band: `{ cards, dropped, … }`\nas `POST …/actions` returns it, `{ error }` when proposing\nfailed (the regeneration still succeeded), or null when\nthere were no findings to propose from.\n"
                        },
                        "upkeep": {
                          "type": "boolean",
                          "description": "Present and false when the board's `features.generative` attribute is off, so the captions, band and actions were skipped."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "402": {
            "description": "Billing required — the tenant is out of credits"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "404": {
            "description": "Dashboard not found"
          },
          "409": {
            "description": "The board is being built (`BUILD_IN_PROGRESS`)"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/generate/refine": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Re-plan a generative board from a refinement request",
        "description": "One planning call (billed) over the board's brief and current plan\nplus your notes. Nothing on the board changes. The reply is the new\nstoryboard with `diff`: per tile, kept (locked and edited tiles are\nalways kept), rebuilt, added or removed. Apply it with\n`…/generate/refine/apply`. Only the company that owns the board may\nrefine it; the key's user needs `edit_dashboard`, AI enabled and\nbilling standing.\n",
        "operationId": "refineDashboardPlan",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "type": "string",
                    "maxLength": 1000,
                    "description": "What should change (the hallway's LIMITS.MAX_NOTES_CHARS)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new storyboard and its diff",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "planId": {
                          "type": "string"
                        },
                        "plan": {
                          "type": "object"
                        },
                        "estimate": {
                          "type": "object"
                        },
                        "diff": {
                          "type": "object",
                          "properties": {
                            "keep": {
                              "type": "array",
                              "items": {
                                "type": "object"
                              }
                            },
                            "replace": {
                              "type": "array",
                              "items": {
                                "type": "object"
                              }
                            },
                            "add": {
                              "type": "array",
                              "items": {
                                "type": "object"
                              }
                            },
                            "remove": {
                              "type": "array",
                              "items": {
                                "type": "object"
                              }
                            },
                            "summary": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`text` is missing, or longer than 1000 characters (code NOTES_TOO_LONG)"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "402": {
            "description": "Billing required — the tenant is out of credits"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "404": {
            "description": "Dashboard not found, or not a generative board"
          },
          "409": {
            "description": "GENERATIVE_UPKEEP_OFF — the board's `features.generative` attribute is off. Turn it on with `PUT /dashboards/{dashboardId}/settings/attributes` first."
          }
        }
      }
    },
    "/dashboards/{dashboardId}/generate/refine/apply": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Apply a refinement as a build job",
        "description": "Applies the diff of a refinement: kept tiles keep their rows (and\ntheir AI results), removed ones go, new and rebuilt ones are bound\nand written, then the band and the actions are rebuilt. `decisions`\noverrides the diff per plan tile. Poll `…/generate/status` for the\njob. Billed as a build.\n",
        "operationId": "applyDashboardRefinement",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "planId"
                ],
                "properties": {
                  "planId": {
                    "type": "string"
                  },
                  "decisions": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string",
                      "enum": [
                        "apply",
                        "keep",
                        "remove"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The build job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboardId": {
                          "type": "integer"
                        },
                        "jobId": {
                          "type": "string"
                        },
                        "generationId": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`planId` is missing"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "402": {
            "description": "Billing required — the tenant is out of credits"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "404": {
            "description": "Dashboard or storyboard not found"
          },
          "409": {
            "description": "A build is already running, or the storyboard was planned for another board; or GENERATIVE_UPKEEP_OFF — the board's `features.generative` attribute is off. Turn it on with `PUT /dashboards/{dashboardId}/settings/attributes` first."
          }
        }
      }
    },
    "/dashboards/{dashboardId}/generate/schedule": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "A generative board's regeneration cadence",
        "operationId": "getDashboardRegenerationSchedule",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "The schedule (null when manual), with its next and last run"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "404": {
            "description": "Dashboard not found, or not a generative board"
          }
        }
      },
      "put": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Set the board's regeneration cadence",
        "description": "The AI layer (tiles, band, actions) is recomputed on the schedule as\nthe key's user, who is re-verified on every run. Each run bills like\nRegenerate. Only the company that owns the board may schedule it;\nthe key's user needs `edit_dashboard` and AI enabled. Refused (409\n`GENERATIVE_UPKEEP_OFF`) on a board whose `features.generative`\nattribute is off, and a scheduled run on such a board is skipped.\n",
        "operationId": "setDashboardRegenerationSchedule",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "scheduleType"
                ],
                "properties": {
                  "scheduleType": {
                    "type": "string",
                    "enum": [
                      "interval",
                      "daily",
                      "weekly",
                      "monthly"
                    ]
                  },
                  "intervalMinutes": {
                    "type": "integer",
                    "minimum": 15,
                    "maximum": 10080
                  },
                  "timeOfDay": {
                    "type": "string",
                    "example": "09:00"
                  },
                  "dayOfWeek": {
                    "type": "string",
                    "example": "1"
                  },
                  "dayOfMonth": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 28
                  },
                  "timezone": {
                    "type": "string",
                    "example": "UTC"
                  },
                  "notify": {
                    "type": "boolean"
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "ai",
                      "all"
                    ],
                    "description": "`ai` (default) recomputes the AI layer only. `all` re-plans\nthe board over the current data first (one planning call;\nlocked and edited tiles are always kept) and applies the\ndiff unattended, then recomputes the AI layer.\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The schedule as set"
          },
          "400": {
            "description": "Invalid schedule"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "404": {
            "description": "Dashboard not found, or not a generative board"
          },
          "409": {
            "description": "GENERATIVE_UPKEEP_OFF — the board's `features.generative` attribute is off. Turn it on with `PUT /dashboards/{dashboardId}/settings/attributes` first."
          }
        }
      },
      "delete": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Stop the board's regeneration cadence",
        "operationId": "clearDashboardRegenerationSchedule",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "Stopped"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "404": {
            "description": "Dashboard not found, or not a generative board"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/actions": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "A board's recommended actions",
        "description": "The action cards proposed from the board's computed findings, each\nwith its state (proposed, running, held, done, failed, dismissed),\nits rationale, the findings and tiles it rests on, and its mechanism\n(one of the tenant's own workflows, agents or notebooks).\n",
        "operationId": "listDashboardActions",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "The actions row",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "cards": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "dismissed": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "generatedAt": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "404": {
            "description": "Dashboard not found"
          }
        }
      },
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Propose recommended actions from the board's findings",
        "description": "One structured model call on the planning lane. Every proposed\nmechanism is checked against the allowlist of workflows, agents and\nnotebooks the key's user can reach; anything else is dropped.\nReplaces the current proposals; dismissals are remembered and fed\nback. Billed. Only the company that owns the board may propose; the\nkey's user needs `edit_dashboard`, AI enabled and billing standing.\n",
        "operationId": "proposeDashboardActions",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "The new proposals",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "cards": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "dropped": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "402": {
            "description": "Billing required — the tenant is out of credits"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "404": {
            "description": "Dashboard not found"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/actions/run": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Run one recommended action or Button tile",
        "description": "Runs a recommended action card (`cardId`) or a Button tile on this\nboard (`tileId`; the workflow or agent comes from the saved tile).\nA workflow mechanism runs now under the board owner's client (the\nrun is billed as any run). An agent mechanism becomes a one-off\nagent job; anything destructive it attempts waits in Approvals, and\nthe card is `held` meanwhile. An agent mechanism also needs AI\nenabled for the key's user. A notebook mechanism is not run — the\nresponse says where to open it. Billed. The key's user needs\n`view_dashboard` and billing standing. Besides `dashboards:write`,\nthe key needs `workflows:execute` to run a workflow mechanism or\n`agents:execute` to run an agent mechanism; this is checked before\nanything runs.\n",
        "operationId": "runDashboardAction",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "Send `cardId` or `tileId`.",
                "properties": {
                  "cardId": {
                    "type": "string",
                    "description": "The action card id"
                  },
                  "tileId": {
                    "type": "integer",
                    "description": "A Button tile on this board"
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Choices for the board's variables by name (see the board's settings): text, a number, a YYYY-MM-DD day, a list for a multi-select, or a date range `{ start, end }` / `{ preset }`. A variable left out takes the board's default.\n"
                  },
                  "timeZone": {
                    "type": "string",
                    "description": "IANA zone for the day boundaries of a date-range preset (default UTC)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The card's new state, or the run's outcome for a tile",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "card": {
                          "type": "object",
                          "nullable": true,
                          "description": "The card's new state; null for a tile run"
                        },
                        "lastRun": {
                          "type": "object",
                          "description": "The run's outcome, for a tile run (a card carries its own lastRun)"
                        },
                        "navigate": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Neither cardId nor tileId, the tile is not a Button tile, or the button runs no workflow or agent"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "402": {
            "description": "Billing required — the tenant is out of credits"
          },
          "403": {
            "description": "The key lacks a required scope, its user lacks the permission or has AI disabled, or the company does not own the board"
          },
          "404": {
            "description": "Dashboard, action, tile or its mechanism not found"
          },
          "409": {
            "description": "The action is not in a runnable state"
          },
          "429": {
            "description": "Too many agent runs for the tenant"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/actions/dismiss": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Dismiss one recommended action",
        "description": "Marks the card dismissed with a reason the next proposal is told\nabout. The key's user needs `edit_dashboard`.\n",
        "operationId": "dismissDashboardAction",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cardId": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string",
                    "enum": [
                      "not_relevant",
                      "already_done",
                      "wrong_target",
                      "too_risky",
                      "other"
                    ]
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Why it was dismissed. A note longer than 2048 characters is\nrefused with 400; the card and the dismissal memory keep\nonly its first 200 characters.\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The dismissed card and the dismissal memory"
          },
          "400": {
            "description": "`cardId` is missing, `reason` is not one of the listed values, or `note` is longer than 2048 characters"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "404": {
            "description": "Dashboard or action not found"
          },
          "409": {
            "description": "The action cannot be dismissed from its state"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/ai-results": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "Every persisted AI result of a board",
        "description": "The stored result of each AI tile (summary, forecast,\npredictiveinsights, biintelligence, scenarioplanner), keyed by tile\nid, with the hash of the config and data that produced it. A fresh\nrow is served without a model call. Same access rule as reading the\ndashboard.\n",
        "operationId": "getDashboardAiResults",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "tileId → result row",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "aiResults": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "404": {
            "description": "Dashboard not found"
          }
        }
      },
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Compute one AI tile's result",
        "description": "(Re)computes one AI tile's persisted result: summary, forecast,\npredictiveinsights, biintelligence or scenarioplanner. A model runs\nonly when the tile's config, data or `params` changed since the\nstored row, or when `force` is true; otherwise the cached row is\nreturned. Billed when it runs. Only the owning company may compute;\nthe key's user needs `edit_dashboard`, AI enabled and billing standing.\n",
        "operationId": "computeDashboardAiResult",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tileId"
                ],
                "properties": {
                  "tileId": {
                    "type": "integer"
                  },
                  "force": {
                    "type": "boolean",
                    "default": false
                  },
                  "params": {
                    "type": "object",
                    "description": "Runtime inputs the result is keyed on. Only a scenarioplanner\ntile reads them: `{ variables?: [{ name, value, unit? }], prompt? }`.\nAbsent means the tile's configured defaults. Ignored for\nother kinds.\n"
                  },
                  "rows": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    },
                    "description": "Rows to analyze instead of running the tile's own sources —\nfor a tile with no source of its own. A payload over the\nAI input size limit is refused with 413 (`ROWS_TOO_LARGE`).\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The result row, and whether it was served from the store",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "cached": {
                          "type": "boolean"
                        },
                        "row": {
                          "type": "object"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "402": {
            "description": "Billing required — the tenant is out of credits"
          },
          "403": {
            "description": "The key lacks the scope, or its user lacks the permission"
          },
          "404": {
            "description": "Dashboard not found"
          },
          "413": {
            "description": "`rows` is over the AI input size limit (`ROWS_TOO_LARGE`)"
          },
          "422": {
            "description": "The tile is not an AI tile, is unbound, or its workflow returned no rows"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/view-link": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "dashboards:read",
        "x-auth": "person",
        "summary": "Open a dashboard in an embedded web view",
        "description": "Answers a one-time `url` (valid 60 seconds). Load it in an embedded\nweb view: it sets a session cookie limited to this dashboard and\nlands on the board exactly as the web shows it, without the app's\nnavigation or any editing.\n\nThat session may load the board and its tiles, refresh them, follow\nlive updates and keep the person's own view of the board (filters,\nvariables). Everything else is refused: other pages redirect to\nsign-in, other API routes answer 403. Tiles that read company data\noutside the board (CRM, finance, Asana, calendar, event feeds,\nAI-mode charts, audio) show their error state. Minting another link\non the same connection adds its board to the session (up to 8), so\nseveral boards can be open at once. A full sign-in of the same\nperson already in the web view is kept as it is.\n\nRequires `dashboards:read`, and the dashboard must be visible to the\ncredential (otherwise 404). OAuth access tokens only, on the\nperson's own connection, from any client: a pasted API key never\nbecomes a browser session.\n",
        "operationId": "createDashboardViewLink",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "The one-time URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "string",
                          "format": "uri"
                        },
                        "expires_in": {
                          "type": "integer",
                          "description": "Seconds the URL can be loaded"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "dashboardId is not a positive integer"
          },
          "401": {
            "description": "Missing or invalid credential"
          },
          "403": {
            "description": "A pasted key (OAUTH_IDENTITY_REQUIRED) or a connection bound to another person's key (PERSON_CREDENTIAL_REQUIRED)"
          },
          "404": {
            "description": "Dashboard not found or not visible to this credential"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/events": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "A dashboard's live changes as server-sent events",
        "description": "The key-door twin of the browser's live stream: the same frames from\nthe same hallway. On connect, any events missed since `Last-Event-ID`\n(or `?after=<rev>`) are replayed first, then a `hello` frame carries the\nboard's current rev and the latest rows per tile. Then `tile.data`,\n`dashboard.saved`, `custom` and the other bus events as they happen,\n`ping` every 15 seconds, and `reconnect` after four minutes. Every\nframe carries its rev as `id:`, so a reconnect catches up.\n\n`dashboard.saved` is sent for every write to the board's tiles,\ndetails, settings or sharing, on any door, after the write commits\n(not for the data-pointer refresh a tile's own load makes; a request\nthat writes more than one of these can send one event for each):\n`{ type: \"dashboard.saved\", scope, by: { userId, source, origin }, modified }`.\n`scope` says what changed: `tiles` (a tile may have been added,\nremoved or changed), `details` (title, overview, icon, tags, tabs or\nsharing; no tile changed), or `settings` (the board's default view,\nvariable definitions, or cache and refresh policy: what decides the\ndata a viewer fetches). An event with no `scope` is `tiles`. `source`\nnames the door, for example `web`, `api`, `mcp`, `agent` or\n`restore`. `modified` is when the write was announced. `origin` is\nthe `X-Write-Origin` header the writer sent, or null: a client that\nsends one on its own writes can skip the event its write caused. It is\na client claim, not an authority.\n\nThe `hello` frame and the snapshot also carry `saved`: the last\n`dashboard.saved` per scope, `{ tiles?, details?, settings? }`, each\n`{ rev, at, by }`, kept for 24 hours. A client that reconnects without\n`after` compares those revs with the one it last handled to learn what\nit missed. The `hello` frame leaves `saved` out when the board has\nnone; the `?snapshot=1` answer carries `saved: {}`.\n\n`?snapshot=1` answers the same current state as plain JSON in the v1\nenvelope — the poll fallback for a client behind a proxy that buffers\nevent streams.\n\nSame fence as the dashboard detail door: a board it serves is\nstreamable, one it hides is a 404.\n",
        "operationId": "streamDashboardEvents",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "The last rev seen (the `Last-Event-ID` header does the same)"
          },
          {
            "name": "snapshot",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "Return the current state as JSON instead of a stream"
          }
        ],
        "responses": {
          "200": {
            "description": "Server-sent events, or the JSON snapshot with `?snapshot=1`",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "SSE frames — replayed events, `hello`, bus events, `ping`, `reconnect`, `error`"
                }
              },
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "rev": {
                          "type": "integer"
                        },
                        "tiles": {
                          "type": "object",
                          "additionalProperties": true
                        },
                        "saved": {
                          "type": "object",
                          "description": "The last `dashboard.saved` per scope. Identifiers only.",
                          "properties": {
                            "tiles": {
                              "$ref": "#/components/schemas/BoardSavedMarker"
                            },
                            "details": {
                              "$ref": "#/components/schemas/BoardSavedMarker"
                            },
                            "settings": {
                              "$ref": "#/components/schemas/BoardSavedMarker"
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid dashboardId"
          },
          "404": {
            "description": "Dashboard not found or not reachable by this credential"
          }
        }
      }
    },
    "/dashboards/{dashboardId}": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "Dashboard detail with its tiles",
        "description": "Same fence as the list door, so a dashboard the list shows is always\nfetchable and one it hides is a 404 — never a 403 that confirms\nexistence. Each tile carries what a caller needs to pick an export\ntarget: id, title, type, and its `export_path`.\n",
        "operationId": "getDashboard",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "The dashboard and its tiles",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "name": {
                          "type": "string"
                        },
                        "overview": {
                          "type": "string",
                          "nullable": true
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "dashboard",
                            "generative",
                            "html"
                          ]
                        },
                        "attributes": {
                          "$ref": "#/components/schemas/DashboardAttributes"
                        },
                        "is_shared": {
                          "type": "boolean"
                        },
                        "icon": {
                          "type": "string",
                          "description": "The board's icon on the Dashboards index (a lucide icon name)"
                        },
                        "tags": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "The tags the Dashboards index searches with tag:"
                        },
                        "created": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "modified": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "content_hash": {
                          "type": "string",
                          "description": "Fingerprint of this dashboard's content as read. Compare it later with POST /assets/diff, or pass it back as `expected_hash` on a write to be refused rather than overwrite a concurrent edit.\n"
                        },
                        "tiles": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "integer"
                              },
                              "title": {
                                "type": "string",
                                "nullable": true
                              },
                              "type": {
                                "type": "string",
                                "nullable": true
                              },
                              "export_path": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Dashboard not found or not reachable by this key"
          }
        }
      },
      "patch": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Update a dashboard's sharing, name, overview, icon or tags",
        "description": "Sharing used to live only as a field of the web save payload, so a\ndashboard built through this API could not be shared with anyone. This\ndoor and the MCP `update_dashboard` tool call the same hallways as the\nweb save, so the rules are identical everywhere: sharing is owner-only\n(or a company administrator); a rename is fenced to the board's own\ncompany; tiles are edited through the tile doors, not here.\n\n`icon` and `tags` are what the Dashboards index shows and searches\n(`tag:ops`). They go through the same details hallway as the web\npage's Save: the same fence, a version snapshot, and a row lock. An\nicon is a lucide icon name; tags are up to 50 strings of up to 64\ncharacters, and the list sent replaces the stored one.\n\n`kind` may be sent as an assertion of what the board already is, but a\nvalue that disagrees with the stored one is REFUSED rather than\nignored — a client trying to convert a grid board into a map should\nhear that it cannot, not watch the call succeed and change nothing.\n\nA write of `name` or `overview` changes the board's `content_hash`,\nand the answer carries `content_hash_before` and `content_hash`\n(BoardHashChain). Sharing, icon and tags do not change the hash. Each\nwrite is announced on the board's event stream as `details`; a request\nthat changes sharing and also the name, overview, icon or tags is\nannounced once for each.\n",
        "operationId": "updateDashboard",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "At least one of `shared`, `name`, `overview`, `icon`, `tags`.",
                "properties": {
                  "shared": {
                    "type": "boolean",
                    "description": "true to share with the company, false to make it private"
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "overview": {
                    "type": "string",
                    "nullable": true
                  },
                  "icon": {
                    "type": "string",
                    "maxLength": 40,
                    "description": "A lucide icon name, e.g. BarChart3"
                  },
                  "tags": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "type": "string",
                      "maxLength": 64
                    },
                    "description": "Replaces the board's tags"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "dashboard",
                      "generative",
                      "html"
                    ],
                    "description": "An assertion only; a board cannot change kind."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The dashboard after the update",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "title": {
                          "type": "string",
                          "nullable": true
                        },
                        "overview": {
                          "type": "string",
                          "nullable": true
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "dashboard",
                            "generative",
                            "html"
                          ]
                        },
                        "isShared": {
                          "type": "boolean"
                        },
                        "icon": {
                          "type": "string"
                        },
                        "tags": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "ownerId": {
                          "type": "integer",
                          "nullable": true
                        },
                        "content_hash_before": {
                          "type": "string",
                          "nullable": true,
                          "description": "With `name` or `overview` only. See BoardHashChain."
                        },
                        "content_hash": {
                          "type": "string",
                          "nullable": true,
                          "description": "With `name` or `overview` only. See BoardHashChain."
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT — no updatable field was sent, or a field has the wrong type"
          },
          "403": {
            "description": "Only the dashboard owner or a company administrator can change sharing settings"
          },
          "404": {
            "description": "Dashboard not found or not reachable by this key"
          },
          "422": {
            "description": "dashboard_kind_mismatch — `kind` is only an assertion of what the board's attributes and tab layouts derive; a mismatch is refused and `details.change` names the attributes to change instead"
          }
        }
      },
      "delete": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Delete a dashboard",
        "description": "Permanently deletes a dashboard and its tiles.\nReaching a dashboard is not authority over it: deletion is the owner's, or an administrator's of the company or organization that owns the row. A colleague who can open a shared board cannot delete it.\n",
        "operationId": "deleteDashboard",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "204": {
            "description": "Dashboard deleted"
          },
          "403": {
            "description": "Only the owner or a company administrator can delete this dashboard",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Dashboard not found or not reachable by this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/dashboards/{dashboardId}/duplicate": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Copy a dashboard",
        "description": "Makes a private copy of a board owned by the key's user: the same\nkind as the original, its tiles, tags, icon and tabs, and — for a\ngenerative board — its authored brief, plan, layout and dataset\nregistry (never its computed band, generations, AI results or\nregeneration schedule). Written in one transaction, so a copy is\nnever half-made.\n\nReach is the read rule, and copying is an act on the board: only the\ncompany that owns it may copy it. A board the key cannot see is a\n404; one it can see but does not own is a 403. The key's user needs\n`edit_dashboard`, like every other door that mints a board. The same\nhallway as the web ⋯ Duplicate and the MCP `duplicate_dashboard` tool.\n",
        "operationId": "duplicateDashboard",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "maxLength": 255,
                    "description": "Title for the copy; defaults to \"<original title> (Copy)\""
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The copy, in the shape POST /dashboards returns",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboard": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "integer"
                            },
                            "name": {
                              "type": "string"
                            },
                            "overview": {
                              "type": "string",
                              "nullable": true
                            },
                            "kind": {
                              "type": "string",
                              "enum": [
                                "dashboard",
                                "generative",
                                "html"
                              ]
                            },
                            "is_shared": {
                              "type": "boolean"
                            },
                            "copied_from": {
                              "type": "integer"
                            },
                            "created": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "modified": {
                              "type": "string",
                              "format": "date-time"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid dashboardId, or `title` is not a non-empty string"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:write`, its user lacks `edit_dashboard`, or another company owns the board (code NOT_OWNER_CLIENT)"
          },
          "404": {
            "description": "Dashboard not found or not reachable by this key"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/ai-view": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "Read an AI tile's result for your own view",
        "description": "The key's user's stored AI result for their own view of an AI tile\n(their date range and filters), or null, and the credits a run\ncosts. Free. A view with no date range and no filters is the tile's\ndefault view (400 VIEW_REQUIRED) — its shared result applies.\n",
        "operationId": "getDashboardAiViewResult",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "name": "tileId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "view",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "JSON: { dateRange?, filters? }"
          },
          {
            "name": "vars",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "JSON: the user's choices for the board's variables by name. Choices that differ from the defaults make the view the user's own"
          },
          {
            "name": "timeZone",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "IANA zone the date range resolves in (default UTC)"
          }
        ],
        "responses": {
          "200": {
            "description": "The stored result (or null) and the run price",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "viewKey": {
                          "type": "string"
                        },
                        "row": {
                          "type": "object",
                          "nullable": true
                        },
                        "price": {
                          "type": "number",
                          "description": "The least a run costs in credits: the model call plus the data refresh (a forecast's narration can add to it)"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid view, or the default view (VIEW_REQUIRED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Dashboard or tile not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Run an AI tile for your own view",
        "description": "Runs an AI tile (summary, forecast, predictiveinsights,\nbiintelligence, scenarioplanner) over its rows cut to the key's\nuser's view — the date range reaches the tile's workflows and the\nfilters cut the rows. Billed to the key's user; the result is stored\nfor them only (their last few views of the tile) and never replaces\nthe tile's shared result, so any viewer of the board may run it. A\nfresh stored result for the same view is served free unless force.\n",
        "operationId": "runDashboardAiForView",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tileId",
                  "view"
                ],
                "properties": {
                  "tileId": {
                    "type": "integer"
                  },
                  "view": {
                    "$ref": "#/components/schemas/DashboardViewModifiers"
                  },
                  "vars": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "The user's choices for the board's variables by name"
                  },
                  "timeZone": {
                    "type": "string"
                  },
                  "force": {
                    "type": "boolean"
                  },
                  "params": {
                    "type": "object",
                    "description": "Runtime inputs (scenario planner variables)"
                  },
                  "rows": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    },
                    "description": "Rows for a tile with no source of its own"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The result for the view",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "cached": {
                          "type": "boolean"
                        },
                        "viewKey": {
                          "type": "string"
                        },
                        "row": {
                          "type": "object"
                        },
                        "price": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid view, or the default view (VIEW_REQUIRED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Billing required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The view leaves no rows to analyze",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/dashboards/{dashboardId}/view": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "Read your view of a dashboard",
        "description": "The key's user's own view of a board — the date range, period,\naggregation, top N, comparison and value filters they laid over it,\nboard-wide (`board`) and per tile (`tiles`, keyed by tile id) — and\nthe board's default view. A view reshapes what one viewer sees; it\nnever changes the board. Reach is the dashboard read rule. The same\nhallway as the web view door and the MCP `get_dashboard_view` tool.\n",
        "operationId": "getDashboardView",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "The view and the board default",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboardId": {
                          "type": "integer"
                        },
                        "view": {
                          "$ref": "#/components/schemas/DashboardViewState"
                        },
                        "boardDefault": {
                          "nullable": true,
                          "allOf": [
                            {
                              "$ref": "#/components/schemas/DashboardViewModifiers"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Dashboard not found or not reachable by this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Replace your view of a dashboard",
        "description": "Stores the key's user's own view of a board. Only that user sees it;\nthe board is unchanged. Every modifier is validated: an invalid view\nis refused with 400 `INVALID_VIEW` naming each error. Tile ids must\nbe saved tile ids. Variable choices (`vars`) are lenient where the\nboard itself moved: a NEW name the board does not declare is refused,\nbut a declared name whose value the board no longer accepts is\ndropped from the saved view rather than refused, and a null (the\nboard's default) stores nothing. The same hallway as the web view\ndoor and the MCP `set_dashboard_view` tool.\n",
        "operationId": "setDashboardView",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "view"
                ],
                "properties": {
                  "view": {
                    "type": "object",
                    "properties": {
                      "board": {
                        "$ref": "#/components/schemas/DashboardViewModifiers"
                      },
                      "tiles": {
                        "type": "object",
                        "additionalProperties": {
                          "$ref": "#/components/schemas/DashboardViewModifiers"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The stored view",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboardId": {
                          "type": "integer"
                        },
                        "view": {
                          "$ref": "#/components/schemas/DashboardViewState"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid view (INVALID_VIEW)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Dashboard not found or not reachable by this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/dashboards/{dashboardId}/view-default": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "put": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Set a dashboard's default view",
        "description": "Sets the view every viewer starts from: the board's (`scope: board`)\nor one tile's (`scope: tile` with `tileId`, written to that tile's\n`config.view` only and limited to the modifiers the tile can show).\nAn empty `modifiers` clears the default. An edit every viewer sees:\nthe key's user needs `edit_dashboard`, and only the company that owns\nthe board may set it (403 `NOT_OWNER_CLIENT`). A tile with no data to\nreshape is a 422 `VIEW_NOT_APPLICABLE`. The same hallway as the web\nview-default door and the MCP `set_dashboard_view_default` tool.\n\nA tile default stamps that tile's `modified` and the answer returns\nit: a caller that resends the tile later (PUT /tiles) sends this\nstamp, or is refused STALE_TILE. Announced on the board's event\nstream as `tiles` (tile scope) or `settings` (board scope). The\nview is not part of `content_hash`.\n",
        "operationId": "setDashboardViewDefault",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "scope",
                  "modifiers"
                ],
                "properties": {
                  "scope": {
                    "type": "string",
                    "enum": [
                      "board",
                      "tile"
                    ]
                  },
                  "tileId": {
                    "type": "integer"
                  },
                  "modifiers": {
                    "$ref": "#/components/schemas/DashboardViewModifiers"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The default that was stored",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboardId": {
                          "type": "integer"
                        },
                        "scope": {
                          "type": "string",
                          "enum": [
                            "board",
                            "tile"
                          ]
                        },
                        "tileId": {
                          "type": "integer",
                          "nullable": true
                        },
                        "modifiers": {
                          "$ref": "#/components/schemas/DashboardViewModifiers"
                        },
                        "view": {
                          "type": "object",
                          "additionalProperties": true,
                          "description": "Tile scope: the tile's `config.view` as stored"
                        },
                        "modified": {
                          "type": "string",
                          "format": "date-time",
                          "description": "Tile scope: the tile's new `modified` stamp"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid scope, tile id or view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing edit_dashboard, or not the owning company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Dashboard or tile not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The tile has no data a view can reshape",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/dashboards/{dashboardId}/tabs": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "List a dashboard's tabs",
        "description": "Every tab on the board, in the order it is displayed, with the number\nof tiles on each — plus `orphaned_tile_count`, the tiles whose tab no\nlonger exists. Those render on no tab at all (the grid draws only the\nactive tab's tiles) and are reachable only by moving them onto one\nwith `PUT /dashboards/{dashboardId}/tabs/{tabId}`.\n\nA tile sits on a tab by its `config.tabId`; one with no `tabId`\nbelongs to the first tab, which is how the grid renders it.\n\nThe same hallway as the web tab strip, the `list_dashboard_tabs` MCP\ntool and the agent tool of that name. Needs `view_dashboard`.\n",
        "operationId": "listDashboardTabs",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "The board's tabs, in display order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/DashboardTabList"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:read`, or its user lacks `view_dashboard`"
          },
          "404": {
            "description": "Dashboard not found or not reachable by this key"
          }
        }
      },
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Add a tab to a dashboard",
        "description": "Appends a tab, or inserts it at `position`. A board may have at most\n10 tabs — the cap the tab strip is drawn for.\n\nThe new tab is empty: put tiles on a grid tab with\n`PUT /dashboards/{dashboardId}/tabs/{tabId}`, or by setting\n`config.tabId` when you write tiles. A `page` tab shows an \"add a\npage\" prompt until its HTML is written through the pages endpoints.\n\n`layout` is `grid` or `page`. On a board whose `layout.tabLayouts`\nattribute locks every tab to one layout, the other is refused (409\n`TAB_LAYOUT_LOCKED`) and a create that names none takes the lock's.\n\nReach is the read rule and this is an act on the board, so only the\ncompany that owns it may add a tab; the key's user needs\n`edit_dashboard`.\n\nAnnounced on the board's event stream as `details`. A tab list is\nnot part of `content_hash`.\n",
        "operationId": "createDashboardTab",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Shown in the tab strip; trimmed, and may not be empty"
                  },
                  "icon": {
                    "type": "string",
                    "description": "A lucide icon name, resolved when the tab is drawn and\nfalling back to Layout. The editor offers Layout, BarChart,\nPieChart, Activity, DollarSign, Users, Target, Briefcase,\nShoppingCart, CreditCard, Box, Globe — any lucide name is\naccepted.\n",
                    "default": "Layout"
                  },
                  "layout": {
                    "type": "string",
                    "enum": [
                      "grid",
                      "page"
                    ],
                    "description": "`grid` (the default) or `page` (one HTML page). On a locked board, omitted means the lock's layout."
                  },
                  "position": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "0-based slot to insert at; appended when omitted"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new tab, and the board's tabs after it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/DashboardTabList"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "tab": {
                              "$ref": "#/components/schemas/DashboardTab"
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`name` missing, empty or over 60 characters; `icon` not an icon name; `layout` not grid or page (code INVALID_TAB_LAYOUT); `position` out of range"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:write`, its user lacks `edit_dashboard`, or another company owns the board (code NOT_OWNER_CLIENT)"
          },
          "404": {
            "description": "Dashboard not found or not reachable by this key"
          },
          "409": {
            "description": "The board already has 10 tabs (code TAB_LIMIT_REACHED), or its `layout.tabLayouts` locks every tab to the other layout (code TAB_LAYOUT_LOCKED)"
          }
        }
      },
      "put": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Reorder a dashboard's tabs",
        "description": "Sets the left-to-right order. `order` must name **every** tab on the\nboard exactly once: a caller working from a stale list is refused\nrather than silently reordering around a tab it never saw, and\nre-sending the current order is a no-op.\n\nTab order is the array order — there is no separate index to keep in\nstep. Announced on the board's event stream as `details`.\n",
        "operationId": "reorderDashboardTabs",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "order"
                ],
                "properties": {
                  "order": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Every tab id, in the order they should appear"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The board's tabs, in their new order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/DashboardTabList"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`order` is not an array, repeats a tab, names a tab that is not on the board, or omits one (code INVALID_TAB_ORDER)"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:write`, its user lacks `edit_dashboard`, or another company owns the board"
          },
          "404": {
            "description": "Dashboard not found or not reachable by this key"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/tabs/{tabId}": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "tabId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The tab id, from GET /dashboards/{dashboardId}/tabs"
        }
      ],
      "patch": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Rename a tab, change its icon or its layout",
        "description": "Changes `name`, `icon`, `layout`, or any of them; anything not sent is\nleft as it is. At least one must be given. A `layout` change moves no\ntile: a `page` tab that holds grid tiles still shows them as a grid.\nOn a board whose `layout.tabLayouts` attribute locks every tab, only\nthe lock's layout is accepted (409 `TAB_LAYOUT_LOCKED`). Announced on\nthe board's event stream as `details`.\n",
        "operationId": "updateDashboardTab",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "minProperties": 1,
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "icon": {
                    "type": "string",
                    "description": "A lucide icon name"
                  },
                  "layout": {
                    "type": "string",
                    "enum": [
                      "grid",
                      "page"
                    ],
                    "description": "`grid` (tiles on a grid) or `page` (one HTML page)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The tab, and the board's tabs after the change",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/DashboardTabList"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "tab": {
                              "$ref": "#/components/schemas/DashboardTab"
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "None of name, icon or layout given, or one of them is invalid (INVALID_TAB_NAME, INVALID_TAB_ICON, INVALID_TAB_LAYOUT)"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:write`, its user lacks `edit_dashboard`, or another company owns the board"
          },
          "404": {
            "description": "Dashboard not found, or no tab with that id (code TAB_NOT_FOUND)"
          },
          "409": {
            "description": "The board's `layout.tabLayouts` locks every tab to the other layout (code TAB_LAYOUT_LOCKED)"
          }
        }
      },
      "put": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Move tiles onto a tab",
        "description": "Moves tiles onto this tab — `tile_ids` to name them, or `from_tab_id`\nto take everything from another tab. Tiles already on the destination\nare counted in `skipped_count` and not rewritten.\n\nThis is also how to rescue tiles that sit on no tab: pass their ids\n(from `orphaned_tile_ids` on the list call). They need not be on any\nexisting tab. Older builds left tiles behind when a tab was deleted,\nand until this door existed nothing could move a tile between tabs —\n`config.tabId` was written when a tile was created and by nothing\nafterwards.\n\nEvery named tile must belong to this dashboard; if any does not, the\nwhole call is refused and nothing moves.\n\nA tile's tab is part of `content_hash`, so the answer carries\n`content_hash_before` and `content_hash` (BoardHashChain), and every\nmoved tile takes one new `modified` stamp, returned as `modified`.\nAnnounced on the board's event stream as `tiles`.\n",
        "operationId": "moveDashboardTilesToTab",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "minProperties": 1,
                "properties": {
                  "tile_ids": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "description": "The tiles to move. Omit to move everything from `from_tab_id`."
                  },
                  "from_tab_id": {
                    "type": "string",
                    "description": "Move every tile on this tab instead of naming ids"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What moved, and the board's tabs after it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/DashboardTabList"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "moved_tile_ids": {
                              "type": "array",
                              "items": {
                                "type": "integer"
                              }
                            },
                            "moved_count": {
                              "type": "integer"
                            },
                            "skipped_count": {
                              "type": "integer",
                              "description": "Named tiles that were already on the destination"
                            },
                            "to_tab_id": {
                              "type": "string"
                            },
                            "modified": {
                              "type": "string",
                              "format": "date-time",
                              "nullable": true,
                              "description": "The stamp every moved tile now carries; null when nothing moved"
                            },
                            "content_hash_before": {
                              "type": "string",
                              "nullable": true
                            },
                            "content_hash": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Neither `tile_ids` nor `from_tab_id` given, or `tile_ids` is empty"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:write`, its user lacks `edit_dashboard`, or another company owns the board"
          },
          "404": {
            "description": "Dashboard not found, no such tab (code TAB_NOT_FOUND), or a named tile is not this dashboard's (code TILE_NOT_FOUND)"
          }
        }
      },
      "delete": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Delete a tab",
        "description": "Deletes the tab. **A tab holding tiles is refused** with 409\n`TAB_NOT_EMPTY`, which carries `tile_count` and `tile_ids`, unless\n`delete_tiles=true` confirms that those tiles are destroyed with it.\nThat destroys the tiles, so it is never the default — to keep the tiles,\nmove them to another tab first with `PUT`, then delete the empty tab.\n\nA board must keep at least one tab: deleting the last one is refused\nwith 409 `LAST_TAB`, because a board with no tabs renders nothing.\n\nBefore tiles are deleted, a version of the board is saved (see the\ndashboard version endpoints). The delete uses the tiles on the tab\nwhen it commits: a tile moved off the tab meanwhile stays. If a tile\nthat the version does not hold is on the tab, the call is refused with\n409 `TAB_CHANGED` and nothing is deleted.\n\nA delete that takes tiles with it changes `content_hash`, and the\nanswer carries `content_hash_before` and `content_hash`\n(BoardHashChain); it is announced on the board's event stream as\n`tiles`. A delete of an empty tab leaves the hash alone and is\nannounced as `details`.\n",
        "operationId": "deleteDashboardTab",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          },
          {
            "name": "delete_tiles",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Confirm that the tiles on this tab are destroyed with it"
          }
        ],
        "responses": {
          "200": {
            "description": "The deleted tab, the tiles that went with it, and the tabs that remain",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/DashboardTabList"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "deleted": {
                              "$ref": "#/components/schemas/DashboardTab"
                            },
                            "deleted_tile_ids": {
                              "type": "array",
                              "items": {
                                "type": "integer"
                              }
                            },
                            "content_hash_before": {
                              "type": "string",
                              "nullable": true,
                              "description": "With deleted tiles only. See BoardHashChain."
                            },
                            "content_hash": {
                              "type": "string",
                              "nullable": true,
                              "description": "With deleted tiles only. See BoardHashChain."
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:write`, its user lacks `edit_dashboard`, or another company owns the board"
          },
          "404": {
            "description": "Dashboard not found, or no tab with that id (code TAB_NOT_FOUND)"
          },
          "409": {
            "description": "The tab holds tiles and `delete_tiles` was not set (code\nTAB_NOT_EMPTY, with `tile_count` and `tile_ids`), it is the\nboard's last tab (code LAST_TAB), or tiles were added to the tab\nwhile it was being deleted (code TAB_CHANGED). Nothing is deleted\nfor TAB_CHANGED; send the request again.\n"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/pages": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "List an HTML dashboard's pages",
        "description": "An HTML dashboard (`kind: html`) is pages an author writes, each one\nthe whole board. A page is a tab holding exactly one HTML tile; this\nlists every tab in order, each as the page it is — what it reads and\nmay run, without its markup — or as what it is instead (`empty`, or a\n`grid` of other tiles).\n\n`reference=true` adds the authoring reference: the `window.vantage`\nAPI a page calls and the theme tokens it styles with. Read it before\nwriting a page.\n\nThe same hallway as the page builder, the `list_html_dashboard_pages`\nMCP tool and the agent tool of that name. Needs `view_dashboard`.\n",
        "operationId": "listHtmlDashboardPages",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "name": "reference",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The dashboard's tabs and pages, in display order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/HtmlPageList"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:read`, or its user lacks `view_dashboard` (PERMISSION_DENIED)"
          },
          "404": {
            "description": "Dashboard not found or not reachable by this key"
          },
          "409": {
            "description": "NOT_A_PAGE_TAB — the tab is a grid tab, which has tiles rather than a page; give it the page layout first"
          }
        }
      },
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Add a page to an HTML dashboard",
        "description": "Adds a tab and its HTML tile in one step, with its first content when\n`page` is sent and the starter page otherwise. `page_id` names an\nexisting EMPTY tab to put the page on instead of making a new one.\n\nA dashboard may have at most 10 tabs. Create the dashboard itself with\n`POST /dashboards` and `kind: html`.\n\nOnly the company that owns the dashboard may add a page; the key's\nuser needs `edit_dashboard`, and must be able to reach every workflow\nthe page names.\n\nThe answer carries `content_hash_before` and `content_hash`\n(BoardHashChain). Announced on the board's event stream as `tiles`.\n",
        "operationId": "addHtmlDashboardPage",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Shown on the page's tab. Required unless `page_id` is sent."
                  },
                  "icon": {
                    "type": "string",
                    "description": "A lucide icon name"
                  },
                  "position": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "0-based slot among the tabs; appended when omitted"
                  },
                  "page_id": {
                    "type": "string",
                    "description": "An existing empty tab to put the page on"
                  },
                  "page": {
                    "$ref": "#/components/schemas/HtmlPageChange"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The page that was added",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboard_id": {
                          "type": "integer"
                        },
                        "title": {
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        },
                        "page": {
                          "$ref": "#/components/schemas/HtmlPage"
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "content_hash_before": {
                          "type": "string",
                          "nullable": true,
                          "description": "See BoardHashChain"
                        },
                        "content_hash": {
                          "type": "string",
                          "nullable": true,
                          "description": "See BoardHashChain"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_TAB_NAME, INVALID_INPUT, INVALID_LABEL, DUPLICATE_LABEL, DUPLICATE_BINDING, INVALID_CHANNEL, INVALID_THEME, UNKNOWN_FIELD, AGENT_IS_A_TEAM, TILE_NOT_FOUND, TILE_NOT_ON_PAGE or INVALID_TILE_CONFIG"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:write`, its user lacks `edit_dashboard` (PERMISSION_DENIED), or NOT_OWNER_CLIENT"
          },
          "404": {
            "description": "DASHBOARD_NOT_FOUND, PAGE_NOT_FOUND (`page_id`), WORKFLOW_NOT_FOUND or AGENT_NOT_FOUND — a workflow or agent the page names is not reachable by this key"
          },
          "409": {
            "description": "NOT_A_PAGE_TAB, TAB_LAYOUT_LOCKED (the board locks its tabs to grid), TAB_LIMIT_REACHED, PAGE_EXISTS (the tab named by `page_id` already holds tiles) or TOO_MANY_BINDINGS"
          },
          "413": {
            "description": "HTML_TOO_LARGE — a page is at most 1 MB"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/pages/{pageId}": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "pageId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The page id, from GET /dashboards/{dashboardId}/pages"
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "Read one page, with its HTML",
        "operationId": "getHtmlDashboardPage",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "The page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboard_id": {
                          "type": "integer"
                        },
                        "title": {
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        },
                        "page": {
                          "$ref": "#/components/schemas/HtmlPage"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:read`, or its user lacks `view_dashboard` (PERMISSION_DENIED)"
          },
          "404": {
            "description": "DASHBOARD_NOT_FOUND or PAGE_NOT_FOUND"
          },
          "409": {
            "description": "NOT_A_PAGE_TAB; PAGE_EMPTY — the tab has no page yet; NOT_A_PAGE — the tab holds other tiles and renders as a grid"
          }
        }
      },
      "patch": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Change a page",
        "description": "Sets any of the page's `html`, `sources`, `actions`, `refreshable`,\n`live_channel`, `theme` and `title`, and the `name` and `icon` of its\ntab. Only the fields sent change; a list that is sent replaces that\nlist.\n\nThe write is the same one a tile write makes — a version of the\ndashboard is taken first, the tile contract is checked, and whoever is\nwatching the dashboard is told it changed. Send `expected_modified`\n(the page's `modified` from the last read) to be refused with\n`STALE_TILE` if the page was saved since; without it, only a save\nlanding while the change is applied is refused. On `STALE_TILE`, read\nthe page again and resend.\n\nA change that writes the page's tile answers `content_hash_before` and\n`content_hash` (BoardHashChain) and is announced as `tiles`. A change\nof only the tab's `name` or `icon` changes no hashed content, answers\nno chain and is announced as `details`.\n",
        "operationId": "setHtmlDashboardPage",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/HtmlPageChange"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "maxLength": 60
                      },
                      "icon": {
                        "type": "string"
                      },
                      "expected_modified": {
                        "type": "string",
                        "format": "date-time",
                        "description": "The page's `modified` from the last read. The change is refused (STALE_TILE) if the page was saved since."
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The page as it now stands",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboard_id": {
                          "type": "integer"
                        },
                        "title": {
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        },
                        "page": {
                          "$ref": "#/components/schemas/HtmlPage"
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "content_hash_before": {
                          "type": "string",
                          "nullable": true,
                          "description": "When the tile was written. See BoardHashChain."
                        },
                        "content_hash": {
                          "type": "string",
                          "nullable": true,
                          "description": "When the tile was written. See BoardHashChain."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "NOTHING_TO_CHANGE, UNKNOWN_FIELD, INVALID_INPUT, INVALID_HTML, INVALID_LABEL, DUPLICATE_LABEL, DUPLICATE_BINDING, INVALID_CHANNEL, INVALID_THEME, INVALID_TAB_NAME, AGENT_IS_A_TEAM, TILE_NOT_FOUND, TILE_NOT_ON_PAGE or INVALID_TILE_CONFIG"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:write`, its user lacks `edit_dashboard` (PERMISSION_DENIED), or NOT_OWNER_CLIENT"
          },
          "404": {
            "description": "DASHBOARD_NOT_FOUND, PAGE_NOT_FOUND, WORKFLOW_NOT_FOUND or AGENT_NOT_FOUND"
          },
          "409": {
            "description": "NOT_A_PAGE_TAB, PAGE_EMPTY, NOT_A_PAGE, TOO_MANY_BINDINGS or STALE_TILE"
          },
          "413": {
            "description": "HTML_TOO_LARGE — a page is at most 1 MB"
          }
        }
      },
      "delete": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Remove a page",
        "description": "Removes the page's tab and the HTML tile on it, in one transaction. A\nversion of the dashboard is taken first, so restoring it brings the\npage back. The last tab cannot be removed, and a tab that holds other\ntiles is not a page and is refused — delete that through the tabs\nendpoints.\n\nA removal that takes the page's tile answers `content_hash_before`\nand `content_hash` (BoardHashChain). Announced on the board's event\nstream as `tiles`.\n",
        "operationId": "removeHtmlDashboardPage",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "responses": {
          "200": {
            "description": "What was removed, and the tabs that remain",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/HtmlPageList"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "removed": {
                              "type": "object",
                              "properties": {
                                "page_id": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "tile_ids": {
                                  "type": "array",
                                  "items": {
                                    "type": "integer"
                                  }
                                }
                              }
                            },
                            "content_hash_before": {
                              "type": "string",
                              "nullable": true,
                              "description": "When a tile was removed. See BoardHashChain."
                            },
                            "content_hash": {
                              "type": "string",
                              "nullable": true,
                              "description": "When a tile was removed. See BoardHashChain."
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "The key lacks `dashboards:write`, its user lacks `edit_dashboard` (PERMISSION_DENIED), or NOT_OWNER_CLIENT"
          },
          "404": {
            "description": "DASHBOARD_NOT_FOUND or PAGE_NOT_FOUND"
          },
          "409": {
            "description": "NOT_A_PAGE_TAB, NOT_A_PAGE, LAST_TAB or TAB_CHANGED"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/tiles": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "put": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Replace a dashboard's tiles",
        "description": "Atomically replaces every tile on the dashboard — the REST twin of the\nMCP `update_dashboard_tiles` tool, over the same hallway: preset ids\nmust exist and be reachable by the dashboard's company, each config is\nchecked against the tile contract (see the `dashboard-builder` skill\nfor every tile type's keys), a version snapshot is taken first, and the\ndelete-then-create runs in one transaction.\n\nReaching a dashboard is not authority over its tiles: a board shared\ninto this company from a sibling company in the organization is\nreadable here but only the OWNING company can rewrite it. The key's\nhuman also needs the `edit_dashboard` catalogue permission — a key\nnever out-reaches its owner.\n\nA tile sent with the `id` of a row on the board updates that row and\nkeeps its id; one without an id is added; a row no tile names is\nremoved. An id that is not on the board, or a `modified` older than\nthe stored row's, is refused with 409 `STALE_TILE`: the caller's copy\nis old.\n\nPass the `content_hash` read from `GET /dashboards/{dashboardId}` (or\nthe previous write's `content_hash`) as `expected_hash` to have the\nwrite refused with 409 `HASH_MISMATCH` if the board changed in\nbetween, on any door; omit it for last-writer-wins. The check runs\nunder the board's row lock, in the write's own transaction. The\nanswer carries `content_hash_before` and `content_hash`\n(BoardHashChain). Announced on the board's event stream as `tiles`.\n\nThe answer's `modified` is the stamp this write left on every tile.\nSend it as the `modified` of each tile you keep on the next write.\n",
        "operationId": "replaceDashboardTiles",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tiles"
                ],
                "properties": {
                  "tiles": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "preset"
                      ],
                      "properties": {
                        "id": {
                          "type": "integer",
                          "description": "An existing tile's id, to update that row and keep the id. Omit to add a tile."
                        },
                        "modified": {
                          "type": "string",
                          "format": "date-time",
                          "description": "The tile's `modified` from the last read, or the `modified` of the last write's answer. A row saved since is refused with STALE_TILE."
                        },
                        "preset": {
                          "type": "integer",
                          "description": "tile_presets id, as returned by GET /dashboards/{dashboardId}"
                        },
                        "position": {
                          "type": "object",
                          "description": "{ x, y, w, h } on the grid"
                        },
                        "config": {
                          "type": "object",
                          "description": "The tile config; keys per the tile contract"
                        }
                      }
                    }
                  },
                  "expected_hash": {
                    "type": "string",
                    "description": "content_hash from the dashboard detail or the previous write; optimistic-concurrency guard"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tiles replaced",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboard_id": {
                          "type": "integer"
                        },
                        "tile_count": {
                          "type": "integer"
                        },
                        "updated_ids": {
                          "type": "array",
                          "items": {
                            "type": "integer"
                          },
                          "description": "Tiles that kept their id"
                        },
                        "created_count": {
                          "type": "integer"
                        },
                        "created_ids": {
                          "type": "array",
                          "items": {
                            "type": "integer"
                          },
                          "description": "Ids of the tiles added, in the order sent"
                        },
                        "removed_ids": {
                          "type": "array",
                          "items": {
                            "type": "integer"
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Contract warnings (unknown keys ignored, etc.) — the write went through"
                        },
                        "content_hash_before": {
                          "type": "string",
                          "nullable": true,
                          "description": "See BoardHashChain"
                        },
                        "content_hash": {
                          "type": "string",
                          "nullable": true,
                          "description": "The board this write left: the next `expected_hash`"
                        },
                        "modified": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true,
                          "description": "The stamp this write left on every tile: the `modified` to send for each tile kept on the next write"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT, INVALID_PRESET (a preset id does not exist or is not reachable), INVALID_TILE_CONFIG (contract errors, listed in `detail.errors`), or for an HTML tile whose lists this write adds to: AGENT_IS_A_TEAM, TILE_NOT_FOUND (a tile it may refresh is not on the board) or TILE_NOT_ON_PAGE (a tile it places is not on its tab)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`dashboards:write` missing), the key's user lacks `edit_dashboard`, or the dashboard is owned by another company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Dashboard not found or not reachable by this key, or an HTML tile this write adds a workflow or agent to names one the key's user cannot reach (WORKFLOW_NOT_FOUND, AGENT_NOT_FOUND)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "HASH_MISMATCH — `expected_hash` no longer matches the live dashboard; or STALE_TILE — a tile id is not on the board, or a tile was saved after its `modified` (ids in `error.unknownIds` and `error.staleIds`). Nothing was written; read the board again and retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/dashboards/{dashboardId}/settings": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "Read a dashboard's settings",
        "description": "The board's own settings: how long its tiles may reuse their rows\n(`cache`), how often the board refreshes itself (`refresh`), the\nvariables it declares, its `attributes` (every part and field, each at\nits value or default) with the `warnings` their combination earns,\nand which tiles override the cache default (`tileOverrides`). Reach is the dashboard read rule — every viewer's\ntiles obey these, and the age stamp on each tile is explained by them.\nThe same hallway as the web settings door and the MCP\n`get_dashboard_settings` tool.\n",
        "operationId": "getDashboardSettings",
        "tags": [
          "Dashboards"
        ],
        "responses": {
          "200": {
            "description": "The board's settings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboardId": {
                          "type": "integer"
                        },
                        "cache": {
                          "$ref": "#/components/schemas/DashboardCachePolicy"
                        },
                        "refresh": {
                          "$ref": "#/components/schemas/DashboardRefreshPolicy"
                        },
                        "variables": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/DashboardVariableDefinition"
                          }
                        },
                        "attributes": {
                          "$ref": "#/components/schemas/DashboardAttributes"
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/DashboardAttributeWarning"
                          }
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true
                        },
                        "tileOverrides": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Dashboard not found"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/settings/policy": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "put": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Set a dashboard's data-freshness defaults",
        "description": "Sets what every tile that has not chosen its own follows: the cache\ndefault and the auto-refresh default. A part left out is left\nunchanged; a part sent as `null` goes back to the product default\n(cache `ttl` 60 minutes, auto-refresh off). A default every viewer\nstarts from, so the key's user needs `edit_dashboard` and only the\ncompany that owns the board may set it (403 `NOT_OWNER_CLIENT`). An\nunknown mode or interval is refused naming the accepted values (400\n`INVALID_POLICY`). The same hallway as the web policy door and the MCP\n`set_dashboard_policy` tool. Announced on the board's event stream as\n`settings`; the policy is not part of `content_hash`.\n",
        "operationId": "setDashboardPolicy",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cache": {
                    "$ref": "#/components/schemas/DashboardCachePolicy"
                  },
                  "refresh": {
                    "$ref": "#/components/schemas/DashboardRefreshPolicy"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The settings as stored"
          },
          "400": {
            "description": "An unknown cache mode or refresh interval"
          },
          "403": {
            "description": "Not the owning company, or edit_dashboard missing"
          },
          "404": {
            "description": "Dashboard not found"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/settings/attributes": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "put": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Set some of a dashboard's attributes",
        "description": "Sets what the board does and how it looks: its tab-layout lock and\ngrid width, generated-content upkeep, what viewers may refresh, and\nwhat view mode shows them (see `DashboardAttributes`). `attributes`\nis a patch: only the fields named change, a field sent as `null`\nreturns to its default, and sending the same patch again changes\nnothing more.\n\nWhat every viewer sees, so the key's user needs `edit_dashboard` and\nonly the company that owns the board may set it (403\n`NOT_OWNER_CLIENT`). An unknown part, field or value is refused naming\nit (400 `INVALID_ATTRIBUTES`). A combination that cannot work is\nrefused with its rule's code (409), checked against the board as it\nis when the write lands. A combination that works but is worth saying\ncomes back in `warnings`.\n\nThe same hallway as the web attributes door and the MCP and agent\n`set_dashboard_attributes` tools. Not versioned, like the board's\nother settings. Announced on the board's event stream as `settings`;\nthe attributes are not part of `content_hash`.\n",
        "operationId": "setDashboardAttributes",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "attributes"
                ],
                "properties": {
                  "attributes": {
                    "$ref": "#/components/schemas/DashboardAttributesPatch"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The attributes as stored, the notes their combination earns, and the board's other freshness settings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboardId": {
                          "type": "integer"
                        },
                        "attributes": {
                          "$ref": "#/components/schemas/DashboardAttributes"
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "dashboard",
                            "generative",
                            "html"
                          ],
                          "description": "What the board now reads as, for readers that still read a kind. Derived from the attributes and tab layouts; absent when it could not be derived."
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/DashboardAttributeWarning"
                          }
                        },
                        "cache": {
                          "$ref": "#/components/schemas/DashboardCachePolicy"
                        },
                        "refresh": {
                          "$ref": "#/components/schemas/DashboardRefreshPolicy"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No `attributes` patch (INVALID_INPUT), or an unknown part, field or value (INVALID_ATTRIBUTES, naming each)"
          },
          "403": {
            "description": "Not the owning company, or edit_dashboard missing"
          },
          "404": {
            "description": "Dashboard not found"
          },
          "409": {
            "description": "A combination that cannot work, with the rule's code: GENERATIVE_NEEDS_GRID (upkeep on a board locked to pages) or HIDE_CURSOR_NEEDS_OPEN_FULLSCREEN"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/settings/variables": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "put": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Set a dashboard's variables",
        "description": "Replaces the variables a board declares. Send the FULL list; an empty\nlist removes them all. Each viewer's own choices live in their view\n(`PUT /dashboards/{dashboardId}/view` with `view.vars`) and are not\ntouched. A default every viewer starts from, so the key's user needs\n`edit_dashboard` and only the company that owns the board may set it\n(403 `NOT_OWNER_CLIENT`). The same hallway as the web variables door\nand the MCP `set_dashboard_variables` tool. Announced on the board's\nevent stream as `settings`; the definitions are not part of\n`content_hash`.\n",
        "operationId": "setDashboardVariables",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "variables": {
                    "type": "array",
                    "maxItems": 30,
                    "items": {
                      "$ref": "#/components/schemas/DashboardVariableDefinition"
                    }
                  }
                },
                "required": [
                  "variables"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The variables as stored, with the board's other settings"
          },
          "400": {
            "description": "An invalid definition (INVALID_VARIABLES, naming each error), or no `variables` list"
          },
          "403": {
            "description": "Not the owning company, or edit_dashboard missing"
          },
          "404": {
            "description": "Dashboard not found, or an options workflow the board's company cannot run (OPTIONS_WORKFLOW_NOT_FOUND)"
          },
          "422": {
            "description": "An options workflow reads the variable it feeds, or options depend on each other in a loop (OPTIONS_WORKFLOW_READS_VARIABLE)"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/tiles/{tileId}/refresh": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "tileId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "Refresh one dashboard tile",
        "description": "Re-runs the tile's sources and reports what came back: each source's\nrow count, when it ran, and whether anything was answered from cache.\nEvery source runs rather than answering from the result cache, so this\nis the way to ask for fresh numbers over the API — an export answers\nfrom the same cache the board does. The runs are billed as a dashboard\nrefresh, exactly as a refresh on the web is. Reach is the dashboard\nread rule; the tile must belong to the addressed board (404\n`TILE_NOT_FOUND`). Optionally refresh for one view window with\n`viewParams`. The same hallway as the web refresh door and the MCP\n`refresh_dashboard_tile` tool.\n\nOn a board whose `freshness.viewerManualRefresh` attribute is off, a\ncaller who cannot edit the board is refused (403\n`REFRESH_NOT_ALLOWED`) before anything runs or is billed. To be\nexempt, a key needs `dashboards:write` (or a blanket `mcp` /\n`mcp:write` grant, which can already edit the board through MCP), and\nits user needs edit rights on the board.\n",
        "operationId": "refreshDashboardTile",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "viewParams": {
                    "type": "object",
                    "description": "A view window to refresh for (whole days).",
                    "properties": {
                      "startDate": {
                        "type": "string",
                        "example": "2026-01-01"
                      },
                      "endDate": {
                        "type": "string",
                        "example": "2026-03-31"
                      }
                    }
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Choices for the board's variables by name (see the board's settings): text, a number, a YYYY-MM-DD day, a list for a multi-select, or a date range `{ start, end }` / `{ preset }`. A variable left out takes the board's default.\n"
                  },
                  "timeZone": {
                    "type": "string",
                    "description": "IANA zone for the day boundaries of a date-range preset (default UTC)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What the refresh ran",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboardId": {
                          "type": "integer"
                        },
                        "tileId": {
                          "type": "integer"
                        },
                        "refreshedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "ran": {
                          "type": "integer",
                          "description": "How many sources actually executed."
                        },
                        "sources": {
                          "type": "object",
                          "description": "Per workflow id — generatedAt, cached, rowCount, dataRefId.",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Billing required"
          },
          "403": {
            "description": "REFRESH_NOT_ALLOWED — the board's freshness.viewerManualRefresh attribute is off and this caller cannot edit the board. Nothing ran and nothing was billed."
          },
          "404": {
            "description": "Dashboard or tile not found"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/push": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Push rows onto a dashboard tile by its live channel",
        "description": "Puts rows on a tile NOW, for everyone watching the board, naming the\ntile by the live CHANNEL its author gave it (`liveChannel` in the\ntile's config) rather than by id. The channel is the name that\nsurvives a board being duplicated, a tile being replaced, or three\nboards wanting the same feed — a client written once against\n`orders` keeps working; a hard-coded tile id does not. The workflow\nnode, the MCP tool and the agent tool already push by channel; this\nis the REST form.\n\nOtherwise identical to `POST /dashboards/{dashboardId}/tiles/{tileId}/push`:\nno reload, no workflow run, nothing written to the tile's config; the\nlatest push per tile is kept for a day. Needs `edit_dashboard` and\nthe owning company. At most 5000 rows and 256KB per push including\n`meta` (413 `PAYLOAD_TOO_LARGE`); throttled per company.\n\n`meta` is bounded: only `source`, `workflowId`, `runId` and `label`\nare kept, each a string (256 chars max), number or boolean; other\nkeys are dropped and `rowCount` is always the server's.\n",
        "operationId": "pushDashboardChannelData",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "channel"
                ],
                "properties": {
                  "channel": {
                    "type": "string",
                    "example": "orders",
                    "description": "The tile's `liveChannel`, as its author set it. Exactly one tile on the board must listen on it."
                  },
                  "rows": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "description": "The rows to show. At most 5000."
                  },
                  "event": {
                    "type": "object",
                    "description": "Instead of rows — a named event for an HTML tile's `vantage.onEvent`, which leaves what the tile shows alone. Exactly one of `rows` or `event` per push; both at once is refused with 400 INVALID_INPUT.\n",
                    "required": [
                      "name"
                    ],
                    "properties": {
                      "name": {
                        "type": "string",
                        "example": "orders.updated"
                      },
                      "payload": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    }
                  },
                  "meta": {
                    "type": "object",
                    "description": "What produced this, for anyone reading the board's event log. Only the listed keys are kept.",
                    "properties": {
                      "source": {
                        "type": "string",
                        "maxLength": 256
                      },
                      "workflowId": {
                        "type": "integer"
                      },
                      "runId": {
                        "type": "string",
                        "maxLength": 256
                      },
                      "label": {
                        "type": "string",
                        "maxLength": 256
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What was pushed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "ok": {
                          "type": "boolean"
                        },
                        "dashboardId": {
                          "type": "integer"
                        },
                        "tileId": {
                          "type": "integer",
                          "description": "The tile the channel resolved to."
                        },
                        "rev": {
                          "type": "integer",
                          "description": "The board's revision after this push."
                        },
                        "rowCount": {
                          "type": "integer",
                          "nullable": true
                        },
                        "event": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No channel, neither rows nor an event, rows and an event together (INVALID_INPUT), or the event name is not a name (INVALID_BODY / INVALID_INPUT)"
          },
          "403": {
            "description": "Needs edit_dashboard, or the board belongs to another company"
          },
          "404": {
            "description": "Dashboard not found, or no tile on it listens on that channel (CHANNEL_NOT_FOUND)"
          },
          "409": {
            "description": "Two tiles on the board claim that channel — give each its own, or push by tileId (CHANNEL_AMBIGUOUS)"
          },
          "413": {
            "description": "More than 5000 rows, or over 256KB including meta, or a meta value over 256 characters"
          },
          "429": {
            "description": "This company has pushed too often in the last minute"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/tiles/{tileId}/push": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "tileId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Push rows onto a dashboard tile, live",
        "description": "Puts rows on a tile NOW, for everyone watching the board — no reload\nand no workflow run. For driving a board from outside: a system that\nalready has the numbers pushes them straight at a tile, and anyone\nlooking sees them within about a heartbeat.\n\nA push is not a tile load. It writes nothing to the tile's config, so a\nviewer who reloads gets the tile's own sources back — which is the\nhonest answer about where a board's data comes from. The latest push\nper tile is kept for a day, so someone opening the board later still\nsees it.\n\nNeeds `edit_dashboard` and the owning company, because a push changes\nwhat every viewer sees rather than one person's view. At most 5000\nrows and 256KB per push (413 `PAYLOAD_TOO_LARGE`); throttled per\ncompany. The same hallway as the `dashboardTiles/pushToTile` workflow\nnode, the web push door and the MCP `push_dashboard_tile_data` tool.\n",
        "operationId": "pushDashboardTileData",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rows": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "description": "The rows to show. At most 5000."
                  },
                  "event": {
                    "type": "object",
                    "description": "Instead of rows — a named event for an HTML tile's `vantage.onEvent`, which leaves what the tile shows alone. Exactly one of `rows` or `event` per push; both at once is refused with 400 INVALID_INPUT.\n",
                    "required": [
                      "name"
                    ],
                    "properties": {
                      "name": {
                        "type": "string",
                        "example": "orders.updated"
                      },
                      "payload": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    }
                  },
                  "meta": {
                    "type": "object",
                    "description": "What produced this, for anyone reading the board's event log. Only the listed keys are kept; other keys are dropped and `rowCount` is always the server's.",
                    "properties": {
                      "source": {
                        "type": "string",
                        "maxLength": 256
                      },
                      "workflowId": {
                        "type": "integer"
                      },
                      "runId": {
                        "type": "string",
                        "maxLength": 256
                      },
                      "label": {
                        "type": "string",
                        "maxLength": 256
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What was pushed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "ok": {
                          "type": "boolean"
                        },
                        "dashboardId": {
                          "type": "integer"
                        },
                        "tileId": {
                          "type": "integer"
                        },
                        "rev": {
                          "type": "integer",
                          "description": "The board's revision after this push."
                        },
                        "rowCount": {
                          "type": "integer",
                          "nullable": true
                        },
                        "event": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Neither rows nor an event was given, or the event name is not a name"
          },
          "403": {
            "description": "Needs edit_dashboard, or the board belongs to another company"
          },
          "404": {
            "description": "Dashboard or tile not found, or no tile listens on that channel"
          },
          "409": {
            "description": "Two tiles on the board claim that channel — give each its own, or push by tileId"
          },
          "413": {
            "description": "More than 5000 rows, or over 256KB"
          },
          "429": {
            "description": "This company has pushed too often in the last minute"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/tiles/{tileId}/run": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "tileId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "post": {
        "x-required-scope": "dashboards:write",
        "x-auth": "key",
        "summary": "Run a workflow a tile allows",
        "description": "Runs one of the workflows a tile's author listed, named by the LABEL\nthey gave it: an HTML tile's `allowedWorkflows`, a Table tile's\n`rowActions`, or a Map tile's `runWorkflow` card actions\n(`layers[].card.actions`). The workflow id is read from the SAVED\ntile, never from this request — the same door the tile's own markup\nuses through `vantage.runWorkflow('label')`, and the reason an\nauthor's list is the fence: the tile runs for every later viewer of\nthe board.\n\nFor a row or card action, `payload` is the clicked row. A Table tile\nkeeps the action's `fields`; a Map tile keeps the layer's `key` and\nthe columns its card shows.\n\nReach is the dashboard VIEW rule (running what a board offers is not an\nedit of it) plus the owning company, and the key additionally needs\n`workflows:execute`. Billed like pressing a Button tile, and throttled\nper company because the author's script decides how often it fires.\n\nOn an HTML tile whose page is told its viewer (`shareViewer`), the\nrun's trigger payload carries this key's user as `viewer` (id, email,\nname) — the same attribution rule as a run the page itself starts.\n\nA refused REQUEST is a 4xx. A refused RUN — a node's own error, an\nunresolved board variable — is a 200 carrying `ok: false` with the\nnode's sentence, because the request was fine and the workflow was not.\nThe same hallway as `POST /api/dashboard/tile-run` and the MCP\n`run_dashboard_tile_workflow` tool.\n",
        "operationId": "runDashboardTileWorkflow",
        "tags": [
          "Dashboards"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "target"
                ],
                "properties": {
                  "target": {
                    "type": "string",
                    "description": "The label of one of the tile's `allowedWorkflows`, `rowActions` or `runWorkflow` card actions (its workflow id as a string also works). Anything else is 404 `WORKFLOW_NOT_ALLOWED`.\n",
                    "example": "refresh-orders"
                  },
                  "payload": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "A JSON object handed to the workflow as its trigger data, under 64KB. For anything larger, give the workflow its own input (413 `PAYLOAD_TOO_LARGE`).\n"
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Choices for the board's variables by name, so the run acts on a selection rather than the board's defaults.\n"
                  },
                  "timeZone": {
                    "type": "string",
                    "description": "IANA zone for the day boundaries of a date-range preset (default UTC)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The run's outcome — `ok` false when the workflow itself failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "ok": {
                          "type": "boolean"
                        },
                        "runId": {
                          "type": "string",
                          "nullable": true
                        },
                        "label": {
                          "type": "string"
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "additionalProperties": true
                          },
                          "description": "The rows the run produced, capped at 1000."
                        },
                        "totalRows": {
                          "type": "integer"
                        },
                        "dataRefId": {
                          "type": "string",
                          "nullable": true
                        },
                        "code": {
                          "type": "string",
                          "description": "Present when ok is false."
                        },
                        "error": {
                          "type": "string",
                          "description": "Present when ok is false."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "target missing, a payload that is not a JSON object, or a tile that runs no workflow by label"
          },
          "402": {
            "description": "Billing required"
          },
          "403": {
            "description": "The key lacks workflows:execute, or the board belongs to another company"
          },
          "404": {
            "description": "Dashboard or tile not found, or the target is not on the tile's list"
          },
          "413": {
            "description": "The payload is larger than 64KB"
          },
          "429": {
            "description": "This company has run tile workflows too often in the last minute"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/tiles/{tileId}/export": {
      "parameters": [
        {
          "name": "dashboardId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "tileId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "x-required-scope": "dashboards:read",
        "x-auth": "key",
        "summary": "Export a tile's rows",
        "description": "CSV by default (RFC-4180 quoting, formula-injection guard, served as\nan attachment with nosniff), or JSON with `?format=json`. Runs the\nSAME production hallway as the web tile refresh: access rule, billing\ngate, data-source precedence and the usage row are all decided there\nonce. The tile must live on the addressed dashboard — otherwise any\nreachable dashboard id would export any tile.\n\nThe egress governance scan runs on the rows actually leaving (this\ndoor bypasses the dashboard UI, so the content is checked here or\nnowhere): a block rule answers 403 POLICY_BLOCKED; a redact rule\nrewrites the rows.\n",
        "operationId": "exportDashboardTile",
        "tags": [
          "Dashboards"
        ],
        "parameters": [
          {
            "name": "startDate",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "A view's date window start (YYYY-MM-DD). The tile's workflows that\nread a date window run for it (their own cache entry), and the rows\nare cut to it on the tile's time column. Invalid → 400 INVALID_INPUT.\n"
          },
          {
            "name": "endDate",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "The window's end day (included)."
          },
          {
            "name": "fresh",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "true",
                "yes"
              ]
            },
            "description": "Re-run the tile's sources instead of answering from cache (billed\nas a dashboard refresh). A viewer's fresh runs only when the board\nallows it. On a board whose `freshness.viewerManualRefresh`\nattribute is off, a caller who cannot edit the board gets the\ncached rows: the JSON answer carries `force_refused`, and a CSV\nanswer the `X-Force-Refused` header. To be exempt, a key needs\n`dashboards:write` (or a blanket `mcp` / `mcp:write` grant, which\ncan already edit the board through MCP), and its user needs edit\nrights on the board.\n"
          },
          {
            "name": "timeZone",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "IANA zone for the day boundaries of a date-range variable's preset\n(default UTC).\n\nThe board's variables are set with `v.<name>` parameters, exactly\nas a board link carries them: `v.product=p1`; a multi-select\nrepeats the key (`v.region=us&v.region=eu`, or `v.region=` for\nnone); a date range is `v.period=2026-01-01..2026-03-31` or\n`v.period=preset:last_30_days`. A variable left out takes the\nboard's default, and a choice that no longer fits falls back to it.\n"
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json"
              ]
            },
            "description": "Omit for CSV"
          }
        ],
        "responses": {
          "200": {
            "description": "The tile's rows",
            "headers": {
              "X-Force-Refused": {
                "description": "CSV only. The code `REFRESH_NOT_ALLOWED` when `fresh` was asked for and the board did not allow it, so these are the cached rows",
                "schema": {
                  "type": "string",
                  "enum": [
                    "REFRESH_NOT_ALLOWED"
                  ]
                }
              }
            },
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "dashboard_id": {
                          "type": "integer"
                        },
                        "tile_id": {
                          "type": "integer"
                        },
                        "row_count": {
                          "type": "integer"
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "view": {
                          "type": "object",
                          "description": "Present when startDate/endDate were given — the window the rows were loaded for.",
                          "properties": {
                            "start_date": {
                              "type": "string",
                              "format": "date",
                              "nullable": true
                            },
                            "end_date": {
                              "type": "string",
                              "format": "date",
                              "nullable": true
                            },
                            "rows_cut": {
                              "type": "boolean",
                              "description": "The rows were cut to the window on the tile's time column"
                            }
                          }
                        },
                        "force_refused": {
                          "type": "object",
                          "description": "Present when `fresh` was asked for and the board did not allow it, so these are the cached rows.",
                          "properties": {
                            "code": {
                              "type": "string",
                              "enum": [
                                "REFRESH_NOT_ALLOWED"
                              ]
                            },
                            "message": {
                              "type": "string"
                            }
                          }
                        },
                        "loaded_at": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "The tile refresh hit the billing gate"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`dashboards:read` missing), ACCESS_DENIED, or POLICY_BLOCKED — a data rule refused the rows leaving"
          },
          "404": {
            "description": "Dashboard not reachable, or the tile is not on it"
          }
        }
      }
    },
    "/workspace": {
      "get": {
        "x-required-scope": "agents:read",
        "x-auth": "key",
        "summary": "List or download agent workspace files",
        "description": "The agent workspace's exit door for API keys — a key-authed mirror of\nthe in-app Files bar. `?scope=` (repeatable, up to 4) names the\nconversation or job whose workspace to read; add `&name=` to download\none file as an attachment, and `&preview=1` for the same bytes\ninline. Each scope is expanded to the team-run scopes registered\nunder it, so a mission's files are reachable by the conversation id\nthe caller actually holds.\n\n`scope` is taken from the query string unvalidated ON PURPOSE: the\nstore key is built from the AUTHENTICATED identity's tenant and user,\nso a caller naming somebody else's conversation id lands in their own\nempty namespace.\n\nScope `agents:read`, and KEYS ONLY — internal callers are refused:\na download is a user walking away with data, and an internal call\ncarries no user to be accountable for it. A key is the opposite — a\nuser-delegated credential — so a download through it gets the same\ngovernance scan and usage row as the browser session.\n\n`preview=1` differs only in labelling: inline, and text/plain\nwhatever the extension says — agent-written .html served inline under\nits real mime would be a stored-XSS vector in our own origin.\n\nWorkspaces live in a cache-backed store; when that store is down the\nanswer is an honest 503, not a 500.\n",
        "operationId": "readWorkspace",
        "tags": [
          "Agents"
        ],
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Conversation id or job id (repeatable, up to 4)"
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Download this file instead of listing"
          },
          {
            "name": "preview",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "Serve the file inline as text/plain"
          }
        ],
        "responses": {
          "200": {
            "description": "File list (no `name`), or the file bytes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "files": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "scope": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "fileCount": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string",
                  "description": "File bytes (download or preview)"
                }
              }
            }
          },
          "400": {
            "description": "No scope given"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE (`agents:read` missing), FORBIDDEN (internal caller), or POLICY_BLOCKED — a data rule refused the file leaving"
          },
          "404": {
            "description": "No workspace file with that name"
          },
          "503": {
            "description": "The workspace store is not available on this server"
          }
        }
      }
    },
    "/shares/{type}/{id}": {
      "get": {
        "x-required-scope": [
          "dashboards:read",
          "workflows:read",
          "notebooks:read",
          "agents:read",
          "integrations:read"
        ],
        "x-auth": "key",
        "x-scope-by-type": {
          "dashboard": "dashboards:read",
          "workflow": "workflows:read",
          "notebook": "notebooks:read",
          "agent": "agents:read",
          "skill": "agents:read",
          "connection": "integrations:read"
        },
        "tags": [
          "Sharing"
        ],
        "summary": "Read who a resource is shared with",
        "description": "Who a dashboard, workflow, notebook, agent (an agent team is an agent) or skill is shared with. Someone who may change its sharing — the owner or an administrator; for a skill, its owner while their role may share skills, or a skill manager — gets the company `audience`, the `audienceOptions`, the `levels` a grant can carry and every target. Anyone else who can see the resource gets only their own access (`myGrant`). A cross-company grant whose owner's company has left the organization is kept and reported with `live: false` and an `inactiveReason`; it is live again if the company returns. Scope: the read scope of the resource's family — `dashboards:read`, `workflows:read`, `notebooks:read`, `agents:read` for agents and skills, or `integrations:read` for a connection (levels `use` and `manage`; audience `company` or `restricted`).",
        "parameters": [
          {
            "name": "type",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "dashboard",
                "workflow",
                "notebook",
                "agent",
                "skill",
                "connection"
              ]
            },
            "description": "The resource type; an agent team is an agent; `connection` (a company connection, `integrations:read`) is readable here and changed only in the web app"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The resource's sharing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Share"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_TYPE — the type is not one of the six; INVALID_INPUT — the id is not a positive integer"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — the key lacks the read scope of this resource's family"
          },
          "404": {
            "description": "NOT_FOUND — no such resource in the key owner's company (or, for an organization administrator, their organization), or one they cannot see; USER_NOT_FOUND — the key's user could not be resolved"
          }
        }
      },
      "put": {
        "x-required-scope": [
          "dashboards:write",
          "workflows:write",
          "notebooks:write",
          "agents:write"
        ],
        "x-auth": "key",
        "x-scope-by-type": {
          "dashboard": "dashboards:write",
          "workflow": "workflows:write",
          "notebook": "notebooks:write",
          "agent": "agents:write",
          "skill": "agents:write"
        },
        "x-scope-note": "Who may use a connection is changed in Settings → Integrations, never with an API key.",
        "tags": [
          "Sharing"
        ],
        "summary": "Change who a resource is shared with",
        "description": "Sets the company audience, `organizationWide` (everyone in every company of the organization can open it at the view level; never a connection) and/or the list of targets. `targets` REPLACES the whole list: send every target to keep, `[]` to remove them all, or leave it out to keep the list unchanged. A target is a person (`user`), a `role` (a company role, or an organization-level role wherever its holders sit), or everyone at a company of the organization (`company`, id = that company's id — the owner's own or another), at level `view` (the default) or `edit`. What the key owner may share with is decided by the sharing keys of their role in the owning company (`share_in_company`, `share_whole_company`, `share_in_other_companies`, `share_whole_other_companies`, `share_org_roles`, `share_organization`; `share_grant_edit` to hand out edit) — the directory endpoint answers `allowed`. An edit grant acts as view for someone whose role may not edit that kind of resource; across companies a grantee edits only while a role of theirs reaches the owning company. Only the owner, an administrator of the owning company, or someone whose roles alone already give full access (dashboards, workflows and notebooks) can change sharing (skills: the owner while their role may share skills, or a skill manager); a grant never confers delete or re-share. Sharing an agent team also adds its targets to the member agents the caller may share (`skippedTeamMembers` lists the rest). Connections are not shared through this endpoint. A change to a dashboard's sharing is announced once on that board's event stream as `details`; sharing is not part of any `content_hash`, and an agent's `modified` does not move. Scope: the write scope of the resource's family — `dashboards:write`, `workflows:write`, `notebooks:write`, or `agents:write` for agents and skills.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WriteOrigin"
          },
          {
            "name": "type",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "dashboard",
                "workflow",
                "notebook",
                "agent",
                "skill"
              ]
            },
            "description": "The resource type; an agent team is an agent"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "audience": {
                    "type": "string",
                    "description": "The company audience, one of the resource's `audienceOptions` — dashboard and agent: none | company; workflow: company (the default) | restricted; notebook: none | view | edit; skill: private | view | edit"
                  },
                  "organizationWide": {
                    "type": "boolean",
                    "description": "true: everyone in every company of the organization can open it (view); false: no longer. Leave it out to keep it as it is. Never a connection."
                  },
                  "targets": {
                    "type": "array",
                    "maxItems": 500,
                    "description": "The COMPLETE list of targets; it replaces the current one",
                    "items": {
                      "type": "object",
                      "required": [
                        "kind",
                        "id"
                      ],
                      "properties": {
                        "kind": {
                          "type": "string",
                          "enum": [
                            "user",
                            "role",
                            "company"
                          ]
                        },
                        "id": {
                          "type": "integer",
                          "description": "User id, role id, or (for company) a company id of the organization"
                        },
                        "level": {
                          "type": "string",
                          "enum": [
                            "view",
                            "edit"
                          ],
                          "description": "Default view; edit needs the share_grant_edit key"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated sharing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Share"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_TYPE — the type is not one of the five; INVALID_BODY — the body was not a JSON object; INVALID_INPUT — nothing to change, or targets is not an array"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — the key lacks the write scope of this resource's family; FORBIDDEN — the key's user is not the owner or an administrator, or their role may not share with other companies, or the type is `connection` (who may use or manage a connection is changed only in the web app)"
          },
          "404": {
            "description": "NOT_FOUND — no such resource in the key owner's company (or, for an organization administrator, their organization); USER_NOT_FOUND — the key's user could not be resolved"
          },
          "422": {
            "description": "INVALID_SHARE — an unknown audience, level, person or role; a company outside the organization; `organizationWide` on a connection; a deactivated person; more than 500 targets"
          }
        }
      }
    },
    "/shares/{type}/{id}/directory": {
      "get": {
        "x-required-scope": [
          "dashboards:read",
          "workflows:read",
          "notebooks:read",
          "agents:read",
          "integrations:read"
        ],
        "x-auth": "key",
        "x-scope-by-type": {
          "dashboard": "dashboards:read",
          "workflow": "workflows:read",
          "notebook": "notebooks:read",
          "agent": "agents:read",
          "skill": "agents:read",
          "connection": "integrations:read"
        },
        "tags": [
          "Sharing"
        ],
        "summary": "List who a resource can be shared with",
        "description": "As far as the key owner's role allows (`allowed`, decided by its sharing keys in the owning company): the `people` and `roles` of the owner's company; `companies` — every other company of the organization with its people and roles; `wholeCompanies` — other companies that may be named whole; `organizationRoles` — organization-level roles. Never anyone outside the organization. Only for someone who may change the resource's sharing. Scope: the read scope of the resource's family (`agents:read` for agents and skills).",
        "parameters": [
          {
            "name": "type",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "dashboard",
                "workflow",
                "notebook",
                "agent",
                "skill",
                "connection"
              ]
            },
            "description": "The resource type; an agent team is an agent; `connection` (a company connection, `integrations:read`) is readable here and changed only in the web app"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The share directory",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "ownerCompany": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "integer"
                            },
                            "name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          }
                        },
                        "people": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/ShareCandidate"
                          }
                        },
                        "roles": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/ShareCandidate"
                          }
                        },
                        "companies": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "integer"
                              },
                              "name": {
                                "type": "string"
                              },
                              "roles": {
                                "type": "array",
                                "items": {
                                  "$ref": "#/components/schemas/ShareCandidate"
                                }
                              },
                              "people": {
                                "type": "array",
                                "items": {
                                  "$ref": "#/components/schemas/ShareCandidate"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_TYPE — the type is not one of the six; INVALID_INPUT — the id is not a positive integer"
          },
          "403": {
            "description": "INSUFFICIENT_SCOPE — the key lacks the read scope of this resource's family; FORBIDDEN — the key's user may not change this resource's sharing"
          },
          "404": {
            "description": "NOT_FOUND — no such resource in the key owner's company (or, for an organization administrator, their organization); USER_NOT_FOUND — the key's user could not be resolved"
          }
        }
      }
    }
  }
}
