{
  "openapi": "3.1.1",
  "info": {
    "title": "Tessule API",
    "version": "2.0.0",
    "description": "REST API for Tessule, a platform for building systems of record. A workspace holds tables with exactly the fields your process needs; define your own tables, fields, and relationships, then create, query, and visualize records through the same API the application itself uses."
  },
  "servers": [
    {
      "url": "https://api.tessule.com/api",
      "description": "This deployment"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "oauth2": {
        "type": "oauth2",
        "description": "OAuth 2.0 with PKCE for external integrations (AI assistants over MCP, partner integrations). Each scope is a workspace action; the token can do what both its scopes and the signing-in member's own role allow.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "/api/oauth/authorize",
            "tokenUrl": "/api/oauth/token",
            "scopes": {
              "records:read": "Data: See records, within their record visibility.",
              "records:create": "Data: Create records, one at a time or by importing a file.",
              "records:update": "Data: Edit records, within their record visibility.",
              "records:delete": "Data: Delete records, within their record visibility.",
              "records:importProvenance": "Data: Set imported records' original created and updated times, authors and owners from the file instead of the import's own.",
              "records:backfillHistory": "Data: Write records' past stage moves as history dated when they happened, on a production workspace too.",
              "tables:read": "Schema: See the tables and their fields.",
              "tables:manage": "Schema: Create, change and delete tables and SQL views. Deleting a table removes its records.",
              "fields:manage": "Schema: Add, change and remove fields, constraints and stage rules.",
              "query:execute": "Analytics: Run read-only SQL queries against workspace data.",
              "savedQueries:read": "Analytics: See saved queries.",
              "savedQueries:manage": "Analytics: Create, edit and delete saved queries.",
              "charts:read": "Analytics: See charts.",
              "charts:manage": "Analytics: Create, edit and delete charts.",
              "dashboards:read": "Analytics: See dashboards.",
              "dashboards:manage": "Analytics: Create, edit and delete dashboards, including by applying a dashboard plan.",
              "store:read": "Data: Read items in the workspace key/value store.",
              "store:manage": "Data: Add, change and delete items in the workspace key/value store.",
              "derivedViews:read": "Analytics: See derived fields and table summaries, and make personal ones.",
              "derivedViews:manage": "Analytics: Create and remove shared derived fields and summaries, and promote one to a stored field.",
              "attachments:read": "Data: Download files attached to records.",
              "attachments:manage": "Data: Upload and remove files attached to records.",
              "audit:read": "Administration: Read the workspace's audit trail and each record's change history.",
              "comments:read": "Data: Read the comments on records they can see.",
              "comments:create": "Data: Post comments, and edit or delete their own.",
              "comments:moderate": "Data: Delete other people's comments (never edit them).",
              "workspace:members:read": "Administration: See the workspace's members.",
              "workspace:members:manage": "Administration: Add and remove members and change their base role.",
              "groups:read": "Administration: See groups and who is in them.",
              "groups:manage": "Administration: Create, change and delete groups.",
              "tokens:manage": "Administration: Create and revoke their own API tokens.",
              "agents:manage": "Administration: Create, change and delete their own agents, and attach to them roles they hold themselves.",
              "integrationAccounts:manage": "Administration: Create integrations for machines, attach roles to them, and issue and revoke their tokens.",
              "schema:apply": "Schema: Apply a whole schema plan at once, for example from an AI assistant.",
              "flows:read": "Processes: See flows and their run history.",
              "flows:create": "Processes: Create flows. A flow can send email and call external services.",
              "flows:update": "Processes: Edit, publish, enable and disable flows.",
              "flows:delete": "Processes: Delete flows and their run history.",
              "flows:execute": "Processes: Test-run flows, run one on a record and cancel runs. Runs have real effects.",
              "intakes:manage": "Schema: Create, edit, publish and delete intakes, which turn external documents into records.",
              "secrets:manage": "Administration: Add, replace and delete workspace secrets. A saved secret can never be read back.",
              "webhooks:manage": "Administration: Subscribe URLs to record events and see their deliveries. Each subscription sends what its creator can read.",
              "exports:manage": "Administration: Send every record and field of chosen tables to a data warehouse on a schedule, whoever can see them in the app.",
              "integrations:read": "Administration: See which marketing-platform connections exist (never their credentials).",
              "integrations:manage": "Administration: Connect, change and remove marketing platforms, and send audiences to them.",
              "mirrors:manage": "Administration: Detach a mirrored table so Tessule owns its records. Detaching cannot be undone.",
              "hostedSites:manage": "Administration: Create, deploy, roll back and delete the workspace's hosted sites, code that runs as every member who opens it.",
              "pages:read": "Analytics: Open published pages shared with them.",
              "pages:publish": "Analytics: Publish pages and change their own.",
              "pages:manage": "Analytics: Change, roll back and delete anyone's published pages.",
              "approvals:request": "Processes: Ask for a change that an approval rule holds back.",
              "approvals:decide": "Processes: Approve or decline changes and flow steps held for their decision.",
              "approvals:manage": "Processes: Create, edit and delete approval rules.",
              "limits:manage": "Administration: See limits usage and set per-resource quotas, within the organization's own limits.",
              "notifications:read": "Data: Use the notification centre. Each notification still goes only to the people it is for.",
              "permissions:manage": "Administration: Create, edit and assign roles, set field permissions, and manage automation rules.",
              "customization:read": "Analytics: Load saved views, record layouts, the home page, navigation and branding, and keep personal ones.",
              "customization:manage": "Administration: Change branding, the home page, navigation and record layouts, and share saved views with the workspace or a group."
            }
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request was refused before or during handling. Either it did not match this specification (`error` is `Validation failed` and `details` maps each offending field to what is wrong with it), or the operation's own checks rejected it and `error` says why.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "No usable credential: the bearer token is missing, malformed, expired, revoked, or belongs to a session that has since ended. Obtain a new token (sign in again, refresh the session, or mint a new API token) and retry.",
        "headers": {
          "WWW-Authenticate": {
            "description": "The RFC 6750 bearer challenge. `Bearer realm=\"api\"` when the request carried no credential; `Bearer realm=\"api\", error=\"invalid_token\"` when it carried one that was refused. MCP endpoints add `resource_metadata=\"…\"` (RFC 9728) so a client can discover the authorization server.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The caller is authenticated but not allowed to do this. Typically the principal lacks the required action in this workspace (`code` is `PERMISSION_DENIED` where the check names the action), is not a member of the workspace, or the account is in a state that blocks access — awaiting early access (`EARLY_ACCESS_PENDING`), required to complete MFA (`MFA_REQUIRED`), or required to change its password. Retrying without a change of permissions will not succeed. A hosted site's own pages calling `/_api` get two further refusals here: `SITE_ROUTE_NOT_EXPOSED` when the operation exists but is not one a site may call (credentials, secrets, flow authoring, site management, membership, and everything outside the workspace API), and no code when the request did not come from the site's own pages (no `Sec-Fetch-Site: same-origin`, and no `Origin` equal to the site's).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "NotFound": {
        "description": "Nothing the caller may see lives at this path: the resource does not exist, has been deleted, or belongs to a workspace the caller cannot access. Existence is not disclosed across tenancy boundaries, so this is also what a caller sees where another API might return 403.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "A rate limit or quota refused the request: the brakes on authentication endpoints, a per-workspace daily quota on an expensive read, or a ceiling on concurrent jobs. When `Retry-After` is present, wait that many seconds and retry; a concurrency ceiling carries none, so retry once an earlier job has finished. Prefer batching over polling. One exception to the body shape: the deployment's edge throttle (API Gateway) answers its own 429 with `{\"message\": \"Too Many Requests\"}` and no `Retry-After`.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying; present when the limiter knows when its window ends.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "InternalError": {
        "description": "The server failed unexpectedly while handling the request. Nothing about the request is implied; a read may be retried, a write should be checked before it is retried. `instance` identifies the serving instance and helps support find the log line.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "OAuthBadRequest": {
        "description": "The OAuth 2.0 request was invalid. The body is the RFC 6749 §5.2 error shape: `error` is the protocol error code (`invalid_request`, `invalid_grant`, `invalid_client`, `unsupported_grant_type`, `invalid_scope`, `invalid_client_metadata`, `invalid_redirect_uri`) and `error_description` explains it.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OAuthErrorResponse"
            }
          }
        }
      },
      "OAuthUnauthorized": {
        "description": "Client authentication failed at the OAuth 2.0 endpoint (RFC 6749 §5.2 `invalid_client`): the client credentials are wrong or the client is unknown.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OAuthErrorResponse"
            }
          }
        }
      },
      "OAuthTooManyRequests": {
        "description": "A ceiling on the OAuth 2.0 token endpoint refused the request: too many token requests from one client, or a connected app or a partner install that has issued its ceiling of tokens for now. No token was issued. The body is the RFC 6749 §5.2 error shape with `error` `temporarily_unavailable`, so a standard OAuth client library reads it like the endpoint's other refusals; wait the `Retry-After` seconds and repeat the same request. As on every operation, the deployment's edge throttle (API Gateway) answers its own 429 with `{\"message\": \"Too Many Requests\"}` and no `Retry-After`.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before repeating the request.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OAuthErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "description": "The body of every error status for which an operation declares no more specific schema — what the API writes on 4xx and 5xx refusals. `error` is always present and safe to show to a user. Some refusals add `code`, a stable machine-readable reason a client may branch on; request-validation failures add `details`; server faults add `instance`. A refusal may carry further context fields beside these — an operation that expects a client to read one documents it on that response.",
        "required": [
          "error"
        ],
        "additionalProperties": true,
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable explanation of the refusal, written for the person using the client. Not stable: branch on `code` or the HTTP status, never on this text.",
            "example": "Insufficient permissions"
          },
          "code": {
            "type": "string",
            "description": "Stable machine-readable reason, present when a client is expected to react to this refusal in a specific way (`PERMISSION_DENIED`, `VIEW_READ_ONLY`, `EARLY_ACCESS_PENDING`, `MFA_REQUIRED`, …). The operation's response documents the codes it can carry.",
            "example": "PERMISSION_DENIED"
          },
          "details": {
            "type": "object",
            "description": "On a 400 whose `error` is `Validation failed`: each key is the offending request field (a JSON-pointer-like path such as `fieldConfig/options/2/label` for nested bodies; a record write keys by the field name in `data`, or by the comma-joined field list of a composite constraint) and the value says what is wrong with it.",
            "additionalProperties": {
              "type": "string"
            },
            "example": {
              "name": "Required property 'name' is missing in the request body"
            }
          },
          "instance": {
            "type": "string",
            "description": "Identifier of the server instance that produced a 5xx (or an unmatched-route 404). Quote it when reporting a fault; it lets support find the corresponding log line."
          }
        }
      },
      "OAuthErrorResponse": {
        "type": "object",
        "description": "Error body of the OAuth 2.0 token and client-registration endpoints, in the shape RFC 6749 §5.2 (and RFC 7591 §3.2.2 for registration) prescribes, so standard OAuth client libraries can read it unchanged.",
        "required": [
          "error"
        ],
        "additionalProperties": true,
        "properties": {
          "error": {
            "type": "string",
            "description": "The protocol error code — `invalid_request`, `invalid_client`, `invalid_grant`, `unauthorized_client`, `unsupported_grant_type`, `invalid_scope`, `temporarily_unavailable` (a 503 or a 429: retry the same request after `Retry-After` seconds), or for registration `invalid_client_metadata` / `invalid_redirect_uri`. Unlike `ErrorResponse.error`, this is a stable identifier, not a sentence.",
            "example": "invalid_grant"
          },
          "error_description": {
            "type": "string",
            "description": "Human-readable detail about what was wrong.",
            "example": "The authorization code has expired."
          },
          "reason": {
            "type": "string",
            "description": "Why a token exchange was refused, so an SDK can tell 'fetch a fresh id_token' from 'ask your administrator'. Present only on refusals of the token-exchange grant; read `error` for everything else. Open vocabulary: a client tolerates a value it does not know and treats it like an absent one.",
            "x-known-values": "KnownOAuthErrorReason",
            "example": "subject_token_expired"
          }
        }
      },
      "KnownOAuthErrorReason": {
        "type": "string",
        "description": "Reasons `POST /oauth/token` gives for refusing a token exchange. With `invalid_client`: `client_unknown` (no connected app has this `client_id`), `client_disabled` (the app or its SSO connection is switched off, or the connection cannot be verified) and `grant_not_allowed` (the app is not enabled for the token-exchange grant). With `invalid_grant`: `subject_token_invalid` (signature, issuer, audience, algorithm or lifetime failed), `subject_token_expired` (the token verified but has under 60 seconds of life left; fetch a fresh one from the identity provider and try once more), `subject_not_linked` (no link for this subject and the email in the token cannot be trusted; the person signs in to Tessule through SSO once), `subject_not_a_member` (the email is trusted but no member of the organization matches) and `workspace_not_allowed` (the workspace is not one the app may address, or the person is not a member of it).",
        "enum": [
          "client_unknown",
          "client_disabled",
          "grant_not_allowed",
          "subject_token_invalid",
          "subject_token_expired",
          "subject_not_linked",
          "subject_not_a_member",
          "workspace_not_allowed"
        ]
      },
      "ConnectedAppSummary": {
        "type": "object",
        "description": "A connected app named on an audit row: the organization-owned OAuth client whose token made the request.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The connected app's client id."
          },
          "name": {
            "type": "string",
            "description": "The connected app's display name at the time of the request."
          }
        }
      },
      "WorkspaceRole": {
        "type": "string",
        "description": "Baseline workspace member role. Display/labelling on reads; on writes it sets the member's base grants. Additive custom roles layer on top — authorization always resolves from the DB-backed permission snapshot, never from this value alone.",
        "enum": [
          "admin",
          "member",
          "reader"
        ]
      },
      "OrganizationRole": {
        "type": "string",
        "description": "Organization role — management/billing plane only; never grants workspace data access (that always requires a workspace membership). `billing` is the finance role: member-level org visibility plus the billing surface (usage, billing profile, plans, payment methods, invoices) and nothing else on the control plane.",
        "enum": [
          "owner",
          "admin",
          "billing",
          "member"
        ]
      },
      "User": {
        "description": "The signed-in user as carried on `AuthResponse` and `MeResponse`: identity, display name and the workspace the session is bound to.",
        "type": "object",
        "required": [
          "id",
          "email",
          "name",
          "workspaceId",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$",
            "description": "12-character hex ID"
          },
          "email": {
            "description": "The user's sign-in email address; unique across the platform.",
            "type": "string",
            "format": "email"
          },
          "name": {
            "description": "The user's display name, as shown to other members.",
            "type": "string"
          },
          "workspaceId": {
            "type": "string",
            "minLength": 0,
            "maxLength": 12,
            "pattern": "^([0-9a-f]{12})?$",
            "description": "12-character hex ID of the user's workspace. Empty string when the session is workspace-less — the user has no workspace membership, whether they hold an organization role (e.g. billing) or no memberships at all (a bare user with only pending invitations). The access token itself carries no workspaceId claim in that case."
          },
          "emailVerified": {
            "type": "boolean",
            "description": "Whether the user's email address has been verified. Optional for back-compat; /auth/me always populates it.\n"
          },
          "createdAt": {
            "description": "When the user account was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the user's profile last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FieldType": {
        "description": "The kind of value a field holds, which decides its storage, validation, the `FieldConfig` keys that apply (see `x-field-types`) and how it renders. Groups: text (`text`, `textarea`, `richtext`), numeric (`integer`, `number`, `currency`, `percent`, `rating`), `boolean`, temporal (`date`, `datetime`, `time`, `duration`, `recurrence`), contact (`email`, `phone`, `url`), choice (`picklist`, `multipicklist`), `reference` to another table's records, `polymorphicReference` to a record in one of several tables, `multiReference` to several records of one table, compound (`address`, `geolocation`, `openingHours`), `attachment`, and the read-only computed kinds `formula` (same-row expression), `lookup` and `rollup` (virtual, across a reference) and `autonumber` (server-assigned document number: unique and increasing, not gapless).",
        "type": "string",
        "enum": [
          "text",
          "textarea",
          "richtext",
          "integer",
          "number",
          "currency",
          "percent",
          "rating",
          "boolean",
          "date",
          "datetime",
          "time",
          "duration",
          "recurrence",
          "email",
          "phone",
          "url",
          "picklist",
          "multipicklist",
          "reference",
          "polymorphicReference",
          "multiReference",
          "address",
          "geolocation",
          "openingHours",
          "region",
          "attachment",
          "formula",
          "lookup",
          "rollup",
          "autonumber"
        ]
      },
      "PicklistOption": {
        "type": "object",
        "description": "One value in a picklist/multipicklist vocabulary.\n\n**Array order is canonical.** The order of `options` is the display order everywhere the vocabulary is rendered — pickers, and (for a lifecycle field) funnel/board column order. List lifecycle options in the order the process moves through them. Reordering is a free edit: the set of values is unchanged, so no rows are re-validated.",
        "required": [
          "value",
          "label"
        ],
        "properties": {
          "value": {
            "description": "The stored value, written into records and compared in filters and transitions. Stable: renaming the option changes `label`, not this.",
            "type": "string"
          },
          "label": {
            "description": "What pickers, boards and reports show for the value. Free to change without touching any record.",
            "type": "string"
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "description": "Hex color for UI badges"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 280,
            "description": "What this value MEANS, in a sentence or two, for the people and AI agents choosing or reading it: \"Budget confirmed and a decision-maker identified.\" Optional; absent or null when none was written. Prose only — it is never evaluated. On a stage field the enforced entry rules are the machine's `stageRequirements`, and where the two disagree the rules are what holds; saving a stage machine warns when a description names a field of the table that the stage does not require. Kept short because it is shown to AI agents wherever the option list is."
          },
          "isDefault": {
            "type": "boolean",
            "description": "Display metadata marking the option a picker pre-selects; the field's real default is `defaultValue`. Optional on write — an omitted flag reads as `false`. Always present on read: the server stores every option with both flags filled in, so the same bare `{value, label, category}` shape a schema plan accepts is accepted by the field endpoints too."
          },
          "isActive": {
            "type": "boolean",
            "description": "Optional on write — an omitted flag reads as `true`; always present on read. Soft-disable without breaking existing data. Rows already holding an inactive value keep it and keep validating — re-submitting the record unchanged is accepted. What is refused is *changing* a row INTO an inactive value (creates, and updates that alter the value). Deleting an option outright is the destructive form and is still refused while any row holds the value."
          },
          "category": {
            "type": "string",
            "x-known-values": "KnownStageCategory",
            "description": "Lifecycle meaning of this value — whether it is still in flight or an end state. Absent (the default) reads as `open`. Behaviour keys off the category, never off specific values, so several values can share one (`completed` and `cancelled` are both end states). This is display/reporting semantics: it never blocks a write, and a terminal value is not frozen. Open vocabulary — clients must tolerate values not listed in KnownStageCategory and treat an unrecognised one as `open`. Writes are validated against the known set."
          },
          "clock": {
            "type": "string",
            "x-known-values": "KnownStageClock",
            "description": "Whether time spent in this value COUNTS. `running` (the default — omit it) burns the stage clock; `paused` does not: \"awaiting parts\" or \"awaiting customer access\" is someone else's delay, and `<stageField>.activeSeconds` — the time a record has spent in running values, derived from the transition log — leaves it out. Time in a terminal value never counts, whatever this says. Purely metadata the dwell derivation reads: it blocks no write, restamps nothing, and the pause itself is auditable from the record's stage history. Open vocabulary — clients must tolerate values not listed in KnownStageClock and treat an unrecognised one as `running`. Writes are validated against the known set."
          }
        }
      },
      "Attachment": {
        "description": "Metadata of one file stored against an attachment field of a record, as saved by `POST /tables/{tableId}/items/{itemId}/fields/{fieldId}/attachments/confirm` after the upload to the presigned URL succeeded. The file itself lives in object storage under `s3Key`; this object is what the field value holds, and so it is also the `attachment` field's value contract (see the field value contracts beside FieldConfig).",
        "type": "object",
        "required": [
          "s3Key",
          "filename",
          "mimeType",
          "size",
          "uploadedAt"
        ],
        "additionalProperties": false,
        "x-field-type": "attachment",
        "x-examples": [
          {
            "s3Key": "ws/f30cbbeaffe9/a1b2c3d4e5f6/menu.pdf",
            "filename": "menu.pdf",
            "mimeType": "application/pdf",
            "size": 48213,
            "uploadedAt": "2026-03-15T14:30:00Z"
          }
        ],
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "S3 object key for the file"
          },
          "filename": {
            "type": "string",
            "description": "Original filename"
          },
          "mimeType": {
            "type": "string",
            "description": "MIME type of the file"
          },
          "size": {
            "type": "integer",
            "minimum": 0,
            "description": "File size in bytes"
          },
          "uploadedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the file was uploaded"
          }
        }
      },
      "ChartType": {
        "type": "string",
        "enum": [
          "bar",
          "line",
          "area",
          "pie",
          "funnel",
          "cumulative_flow",
          "stage_funnel",
          "stage_flow",
          "bullet",
          "control_chart",
          "aging_wip",
          "waterfall",
          "mekko",
          "combo"
        ],
        "description": "Saved chart visualization type. `funnel` renders name/value rows as conversion stages (largest first — it assumes monotone progress, so prefer a bar for reopenable processes); `cumulative_flow` renders the cartesian config as STACKED areas, a band per series over time — the process report that shows where work piles up (GATED_PROCESSES_DESIGN §6c); `mekko` (a marimekko, or mosaic chart) is the composition chart — one column per `xAxis` row, as WIDE as the row's total across the `yAxes` series and stacked to 100% by each series' share of it, so segment size and segment mix read on one tile (a market by segment and tier, revenue by region and product); `combo` draws the cartesian config with each `yAxes` series as a bar or a line by its `mark`, and a series marked `axis: right` on a second value axis — market size as bars with growth rate as a line. A `bar` (and a combo's bars) can stack per `ChartConfig.stack`.\n\nThe process family (STAGE_FUNNEL_VISUALS.md): `stage_funnel` is the ordered step funnel — rows are stages in PROCESS order (the query's row order, never re-sorted), `dataKey` the count reaching each, and the chart derives step conversion, cumulative conversion and drop-off, with `elapsedKey` (seconds) shown as the time spent before moving on; `stage_flow` draws stage-to-stage transitions as a flow diagram from `sourceKey`/`targetKey`/`dataKey` rows, backward moves (rework) listed beside the diagram; `bullet` is the actual-versus-target row per category (`nameKey`/`dataKey` plus `benchmarks`); `control_chart` is the cycle-time scatter — one dot per finished record (`xAxis` = when it finished, one `yAxes` series = its cycle time), with a rolling mean and p50/p85/p95 lines the chart derives; `aging_wip` draws the open records as dots per stage column by their age (`nameKey` = stage, `dataKey` = age in seconds, `labelKey` = the record's label); `waterfall` is the period bridge — opening balance, signed steps, closing balance (`nameKey`/`dataKey`, rows flagged by `totalKey` drawn as running totals). Every cartesian type, the step funnel, the bullet, the control chart and the aging chart accept `benchmarks`."
      },
      "IssueType": {
        "description": "What kind of report a feedback submission is: `feedback` (general comment), `bug` (something is broken), `feature_request` (something missing), `support` (help needed). Sent in `POST /feedback` and carried on the resulting `Issue`.",
        "type": "string",
        "enum": [
          "feedback",
          "bug",
          "feature_request",
          "support"
        ]
      },
      "IssueStatus": {
        "description": "Where an issue report stands in triage. `open` — untriaged; `in_review` — someone is looking at it; `on_roadmap` — accepted and queued for development; `complete` — the fix has shipped. `resolved` and `closed` are legacy end states kept for rows that already carry them.",
        "type": "string",
        "enum": [
          "open",
          "in_review",
          "resolved",
          "closed",
          "on_roadmap",
          "complete"
        ]
      },
      "IssueSource": {
        "description": "Which surface an issue was filed from: `web` the in-app feedback widget, `mcp` an AI agent over the MCP server, `api` a direct REST call. Recorded by the server from the request, not chosen by the client.",
        "type": "string",
        "enum": [
          "web",
          "mcp",
          "api"
        ]
      },
      "IssueCommentAuthorType": {
        "description": "Who wrote a comment on a support issue: `user` a workspace member (possibly through an AI agent, see `authorAgent`), `operator` a platform operator answering from the admin console, `assistant` an automated reply produced by the platform.",
        "type": "string",
        "enum": [
          "user",
          "operator",
          "assistant"
        ]
      },
      "IssueComment": {
        "description": "One comment on an issue (feedback or bug report), as listed under `Issue.comments`: who wrote it, from a user or an AI agent, and when.",
        "type": "object",
        "required": [
          "id",
          "authorType",
          "authorName",
          "body",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "12-character hex ID"
          },
          "authorType": {
            "$ref": "#/components/schemas/IssueCommentAuthorType"
          },
          "authorName": {
            "type": "string",
            "description": "Display name snapshotted when the comment was written"
          },
          "authorAgent": {
            "type": [
              "string",
              "null"
            ],
            "description": "Self-reported AI agent that wrote the comment, when it arrived over MCP (e.g. \"Claude Code\"). Caller-supplied — a hint, not identity.\n"
          },
          "body": {
            "description": "The comment text as written, plain text.",
            "type": "string"
          },
          "createdAt": {
            "description": "When the comment was posted, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "IssueReporterAgent": {
        "description": "Self-identification an AI agent sends with a submission or comment on `POST /feedback` and `POST /feedback/{feedbackId}/comments`. Purely self-reported, so it is stored as triage context alongside the server-observed OAuth client, never as identity.",
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "The AI agent's own name, e.g. \"Claude Code\" or \"Claude (claude.ai)\""
          },
          "version": {
            "type": "string",
            "maxLength": 60,
            "description": "Agent or client version, when the agent knows it"
          }
        }
      },
      "IssueAttachment": {
        "description": "A file attached to an issue report, as listed on `Issue.attachments`. Metadata only; the bytes are fetched separately.",
        "type": "object",
        "required": [
          "id",
          "filename",
          "mimeType",
          "size",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "12-character hex ID"
          },
          "filename": {
            "type": "string",
            "description": "Original filename"
          },
          "mimeType": {
            "type": "string",
            "description": "MIME type of the file"
          },
          "size": {
            "type": "integer",
            "description": "File size in bytes"
          },
          "createdAt": {
            "description": "When the file was attached, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Issue": {
        "description": "A feedback or problem report filed with the platform by a user (or an AI agent acting for them), with its attachments and reply thread. Returned by every `/feedback` endpoint; list responses omit `comments` and carry only the counts.",
        "type": "object",
        "required": [
          "id",
          "type",
          "status",
          "message",
          "attachments",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "12-character hex ID"
          },
          "type": {
            "$ref": "#/components/schemas/IssueType"
          },
          "status": {
            "$ref": "#/components/schemas/IssueStatus"
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "Short headline; null for widget submissions, which carry only a message"
          },
          "message": {
            "description": "The report's body as the submitter wrote it. For widget submissions this is the whole report, there being no `title`.",
            "type": "string"
          },
          "workspaceId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Workspace the user was in when submitting (snapshot, not a foreign key)"
          },
          "context": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true,
            "description": "Client and server context captured at submission time (page, user agent, viewport, ...)"
          },
          "source": {
            "$ref": "#/components/schemas/IssueSource"
          },
          "reporterAgent": {
            "type": [
              "string",
              "null"
            ],
            "description": "Self-reported AI agent that filed the issue, when it came from one"
          },
          "reporterAgentVersion": {
            "description": "Version string the filing AI agent reported for itself, beside `reporterAgent`. Null when no agent named itself.",
            "type": [
              "string",
              "null"
            ]
          },
          "attachments": {
            "description": "Screenshots or files uploaded with the report, in submission order. Empty when none were attached.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IssueAttachment"
            }
          },
          "comments": {
            "type": "array",
            "description": "The visible thread, oldest first. Populated on the single-issue endpoint; omitted from list responses, which carry only the counts.\n",
            "items": {
              "$ref": "#/components/schemas/IssueComment"
            }
          },
          "commentCount": {
            "type": "integer",
            "description": "Number of visible comments on the thread"
          },
          "unreadCount": {
            "type": "integer",
            "description": "Replies from the platform the submitter has not seen — comments not authored by them since they last opened the thread. Always 0 once the read endpoint has been called with nothing new since.\n"
          },
          "lastActivityAt": {
            "type": "string",
            "format": "date-time",
            "description": "Submission time, or the newest comment's time once the thread has moved"
          },
          "createdAt": {
            "description": "When the report was submitted, ISO-8601 UTC. `lastActivityAt` moves with the thread; this does not.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FeedbackUnreadCount": {
        "type": "object",
        "description": "Aggregate unread state across all of the caller's feedback threads — just enough for a subtle \"you have a reply\" indicator, without pulling the full listing.",
        "required": [
          "unreadReplies"
        ],
        "properties": {
          "unreadReplies": {
            "type": "integer",
            "description": "Total replies from the platform, across every thread the caller submitted, that the caller has not read yet. 0 once every thread has been opened since its latest reply."
          }
        }
      },
      "PresignedUpload": {
        "description": "Where to put the bytes of a file the client is about to upload: either a single presigned PUT URL or, for large files, a multipart upload with one URL per part. Returned by the attachment and feedback upload endpoints; the `s3Key` is what the client later hands back to reference the file.",
        "type": "object",
        "required": [
          "s3Key"
        ],
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "S3 key where the file will be stored"
          },
          "uploadUrl": {
            "type": "string",
            "description": "Present for small files — PUT the whole file to this URL"
          },
          "uploadId": {
            "type": "string",
            "description": "Present for large files — S3 multipart upload ID"
          },
          "partSize": {
            "type": "integer",
            "description": "Multipart only — size in bytes of each part (except the last)"
          },
          "partUrls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Multipart only — presigned URL per part, in order (part N = index N-1)"
          }
        }
      },
      "TextFieldValue": {
        "description": "A `text` field's value — a single line of text. 255 characters unless the field's `maxLength` says otherwise.",
        "type": "string",
        "maxLength": 255,
        "x-field-type": "text",
        "x-examples": [
          "Acme Ltd"
        ]
      },
      "TextareaFieldValue": {
        "description": "A `textarea` field's value — multi-line plain text.",
        "type": "string",
        "maxLength": 32000,
        "x-field-type": "textarea",
        "x-examples": [
          "First line\nSecond line"
        ]
      },
      "RichtextFieldValue": {
        "description": "A `richtext` field's value — an HTML fragment.",
        "type": "string",
        "maxLength": 131072,
        "x-field-type": "richtext",
        "x-examples": [
          "<p>Hello <strong>world</strong></p>"
        ]
      },
      "IntegerFieldValue": {
        "description": "An `integer` field's value — a whole number.",
        "type": "integer",
        "x-field-type": "integer",
        "x-examples": [
          42,
          -7
        ]
      },
      "RatingFieldValue": {
        "description": "A `rating` field's value — whole stars from 1 to the field's `ratingMax` (5 unless set). There is no zero: an unrated record holds null.",
        "type": "integer",
        "minimum": 1,
        "maximum": 5,
        "x-field-type": "rating",
        "x-examples": [
          4
        ]
      },
      "NumberFieldValue": {
        "description": "A `number` field's value — any finite number.",
        "type": "number",
        "x-field-type": "number",
        "x-examples": [
          3.25
        ]
      },
      "CurrencyFieldValue": {
        "description": "A `currency` field's value — an amount and the ISO 4217 code it is in. The field's `currencyCode` is the code a new value defaults to, not a restriction.",
        "type": "object",
        "required": [
          "amount",
          "currency"
        ],
        "additionalProperties": false,
        "properties": {
          "amount": {
            "type": "number",
            "description": "The amount, in major units (12.5 is twelve and a half euros)."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "The ISO 4217 code of the amount's currency."
          }
        },
        "x-field-type": "currency",
        "x-examples": [
          {
            "amount": 12.5,
            "currency": "EUR"
          }
        ]
      },
      "PercentFieldValue": {
        "description": "A `percent` field's value — a whole-number percentage: 30 means 30%, not 0.3. Between 0 and 100 unless the field's `minimum`/`maximum` say otherwise.",
        "type": "number",
        "minimum": 0,
        "maximum": 100,
        "x-field-type": "percent",
        "x-examples": [
          30
        ]
      },
      "BooleanFieldValue": {
        "description": "A `boolean` field's value.",
        "type": "boolean",
        "x-field-type": "boolean",
        "x-examples": [
          true,
          false
        ]
      },
      "DateFieldValue": {
        "description": "A `date` field's value — a calendar date, `YYYY-MM-DD`.",
        "type": "string",
        "format": "date",
        "x-field-type": "date",
        "x-examples": [
          "2026-03-15"
        ]
      },
      "DatetimeFieldValue": {
        "description": "A `datetime` field's value — an instant, ISO 8601 with an offset.",
        "type": "string",
        "format": "date-time",
        "x-field-type": "datetime",
        "x-examples": [
          "2026-03-15T14:30:00Z"
        ]
      },
      "TimeFieldValue": {
        "description": "A `time` field's value — a time of day, `HH:MM` or `HH:MM:SS`, 24-hour.",
        "type": "string",
        "pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$",
        "x-field-type": "time",
        "x-examples": [
          "09:30",
          "17:45:10"
        ]
      },
      "DurationFieldValue": {
        "description": "A `duration` field's value — an elapsed length of time in whole seconds (5400 is an hour and a half). Not negative unless the field's `minDuration` allows it.",
        "type": "integer",
        "minimum": 0,
        "x-field-type": "duration",
        "x-examples": [
          5400
        ]
      },
      "EmailFieldValue": {
        "description": "An `email` field's value — one address.",
        "type": "string",
        "format": "email",
        "maxLength": 254,
        "x-field-type": "email",
        "x-examples": [
          "ana@example.com"
        ]
      },
      "PhoneFieldValue": {
        "description": "A `phone` field's value — a phone number as written; the field's `phoneFormat` may require a leading `+`.",
        "type": "string",
        "maxLength": 20,
        "x-field-type": "phone",
        "x-examples": [
          "+351 222 001 258"
        ]
      },
      "UrlFieldValue": {
        "description": "A `url` field's value — an absolute URI.",
        "type": "string",
        "format": "uri",
        "maxLength": 2048,
        "x-field-type": "url",
        "x-examples": [
          "https://example.com/menu"
        ]
      },
      "PicklistFieldValue": {
        "description": "A `picklist` field's value — the `value` of one of the field's options.",
        "type": "string",
        "x-field-type": "picklist",
        "x-examples": [
          "gold"
        ],
        "x-example-config": {
          "options": [
            {
              "value": "gold",
              "label": "Gold"
            },
            {
              "value": "silver",
              "label": "Silver"
            }
          ]
        }
      },
      "MultipicklistFieldValue": {
        "description": "A `multipicklist` field's value — the `value`s of the chosen options, each at most once.",
        "type": "array",
        "uniqueItems": true,
        "items": {
          "type": "string"
        },
        "x-field-type": "multipicklist",
        "x-examples": [
          [
            "gold",
            "silver"
          ]
        ],
        "x-example-config": {
          "options": [
            {
              "value": "gold",
              "label": "Gold"
            },
            {
              "value": "silver",
              "label": "Silver"
            }
          ]
        }
      },
      "ReferenceFieldValue": {
        "description": "A `reference` field's value when it points at records or groups — the target's 12-character id.",
        "type": "string",
        "pattern": "^[0-9a-f]{12}$",
        "x-field-type": "reference",
        "x-examples": [
          "a1b2c3d4e5f6"
        ]
      },
      "UserReferenceFieldValue": {
        "description": "A `reference` field's value when it points at users — the user's 12-character id, lowercase letters and digits (ids from before the identity cutover are hex, which this also admits).",
        "type": "string",
        "pattern": "^[a-z0-9]{12}$",
        "x-field-type": "reference",
        "x-referenced-entity": "user",
        "x-examples": [
          "k3x9q2mzp7w1"
        ]
      },
      "PolymorphicReferenceFieldValue": {
        "description": "A `polymorphicReference` field's value: which of the field's target tables holds the record, and the record's id. `tableId` must be one of the field's `referencedTableIds` and the record must exist there outside the recycle bin; a write naming any other table or a missing record is refused.",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "tableId",
          "recordId"
        ],
        "properties": {
          "tableId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "Which of the field's target tables holds the record."
          },
          "recordId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The referenced record's id within that table."
          }
        },
        "x-field-type": "polymorphicReference",
        "x-examples": [
          {
            "tableId": "a1b2c3d4e5f6",
            "recordId": "0f1e2d3c4b5a"
          }
        ]
      },
      "MultiReferenceFieldValue": {
        "description": "A `multiReference` field's value — the ids of the records this record is linked to in the field's target table (`referencedTableId`), each at most once, oldest link first. Every id must be a record of that table; a binned record stays in the set (its label is marked deleted) until it is purged, when the link goes with it. An empty array is \"no links\"; a required field refuses it. Writing the field replaces the whole set; omitting it from a patch leaves the links alone.",
        "type": "array",
        "items": {
          "type": "string",
          "pattern": "^[0-9a-f]{12}$",
          "description": "The id of one linked record in the target table."
        },
        "uniqueItems": true,
        "x-field-type": "multiReference",
        "x-examples": [
          [
            "a1b2c3d4e5f6",
            "0f1e2d3c4b5a"
          ],
          []
        ]
      },
      "AddressFieldValue": {
        "description": "An `address` field's value — a postal address in parts, every part optional unless the field's `requiredFields` names it.",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "street": {
            "type": "string",
            "maxLength": 255,
            "description": "The street line — number and street name."
          },
          "street2": {
            "type": "string",
            "maxLength": 255,
            "description": "A second street line — flat, floor or building."
          },
          "city": {
            "type": "string",
            "maxLength": 100,
            "description": "The city or town."
          },
          "state": {
            "type": "string",
            "maxLength": 100,
            "description": "The state, county or region."
          },
          "postalCode": {
            "type": "string",
            "maxLength": 20,
            "description": "The postal or ZIP code."
          },
          "country": {
            "type": "string",
            "maxLength": 100,
            "description": "The country, as written (a name or an ISO code)."
          }
        },
        "x-field-type": "address",
        "x-examples": [
          {
            "street": "Rua de Cedofeita 210",
            "street2": "2º Esq",
            "city": "Porto",
            "state": "Porto",
            "postalCode": "4050-174",
            "country": "PT"
          }
        ]
      },
      "GeolocationFieldValue": {
        "description": "A `geolocation` field's value — a point in WGS 84 decimal degrees.",
        "type": "object",
        "required": [
          "latitude",
          "longitude"
        ],
        "additionalProperties": false,
        "properties": {
          "latitude": {
            "type": "number",
            "minimum": -90,
            "maximum": 90,
            "description": "Degrees north of the equator (negative is south)."
          },
          "longitude": {
            "type": "number",
            "minimum": -180,
            "maximum": 180,
            "description": "Degrees east of Greenwich (negative is west)."
          }
        },
        "x-field-type": "geolocation",
        "x-examples": [
          {
            "latitude": 41.1505,
            "longitude": -8.619
          }
        ]
      },
      "RegionFieldValue": {
        "description": "A `region` field's value: a rectangle on a surface, such as a scanned page, a photo or a floor plan. Each part is a fraction of the surface's width or height, with the origin at the top left, so the value holds at any rendering size. It does not say which surface; a sibling field (a page number, an attachment) says that. The rectangle lies wholly inside the surface (`x-regionWithinSurface`): `left + width` and `top + height` are at most 1. `x-counterexamples` lists a value the rule refuses.",
        "type": "object",
        "required": [
          "left",
          "top",
          "width",
          "height"
        ],
        "additionalProperties": false,
        "properties": {
          "left": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "The rectangle's left edge, as a fraction of the surface's width from its left edge."
          },
          "top": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "The rectangle's top edge, as a fraction of the surface's height from its top edge."
          },
          "width": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "The rectangle's width, as a fraction of the surface's width."
          },
          "height": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "The rectangle's height, as a fraction of the surface's height."
          }
        },
        "x-field-type": "region",
        "x-regionWithinSurface": true,
        "x-examples": [
          {
            "left": 0.62,
            "top": 0.81,
            "width": 0.18,
            "height": 0.03
          }
        ],
        "x-counterexamples": [
          {
            "rule": "x-regionWithinSurface",
            "why": "The rectangle runs past the surface's right edge (left + width is more than 1).",
            "value": {
              "left": 0.9,
              "top": 0.1,
              "width": 0.2,
              "height": 0.05
            }
          },
          {
            "rule": "x-regionWithinSurface",
            "why": "The rectangle runs past the surface's bottom edge (top + height is more than 1).",
            "value": {
              "left": 0.1,
              "top": 0.95,
              "width": 0.2,
              "height": 0.1
            }
          }
        ]
      },
      "OpeningHoursDay": {
        "description": "A day an opening-hours specification can name. `PublicHolidays` is a day like the others: which dates it means comes from the calendar's `holidayRegion`.",
        "type": "string",
        "enum": [
          "Monday",
          "Tuesday",
          "Wednesday",
          "Thursday",
          "Friday",
          "Saturday",
          "Sunday",
          "PublicHolidays"
        ]
      },
      "OpeningHoursDayList": {
        "description": "Several days one specification applies to, each named once.",
        "type": "array",
        "minItems": 1,
        "maxItems": 8,
        "uniqueItems": true,
        "items": {
          "$ref": "#/components/schemas/OpeningHoursDay"
        }
      },
      "OpeningHoursDayOfWeek": {
        "description": "schema.org's `dayOfWeek` — one day or a list of them.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/OpeningHoursDay"
          },
          {
            "$ref": "#/components/schemas/OpeningHoursDayList"
          }
        ]
      },
      "OpeningHoursWeeklyEntry": {
        "description": "A weekly specification — the days it names and when it opens and closes on them. `closes` at or before `opens` runs past midnight; `opens` and `closes` both \"00:00\" is closed all day.",
        "type": "object",
        "required": [
          "dayOfWeek",
          "opens",
          "closes"
        ],
        "additionalProperties": false,
        "properties": {
          "@type": {
            "type": "string",
            "description": "schema.org's type tag (`OpeningHoursSpecification`), kept when pasted from JSON-LD."
          },
          "dayOfWeek": {
            "$ref": "#/components/schemas/OpeningHoursDayOfWeek"
          },
          "opens": {
            "type": "string",
            "pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$",
            "description": "When the window opens, `HH:MM` or `HH:MM:SS`."
          },
          "closes": {
            "type": "string",
            "pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$",
            "description": "When the window closes, `HH:MM` or `HH:MM:SS`."
          }
        }
      },
      "OpeningHoursDatedEntry": {
        "description": "A dated specification — replaces the weekly ones from `validFrom` to `validThrough` (the one day when absent). Closed is `opens` and `closes` both \"00:00\".",
        "type": "object",
        "required": [
          "validFrom",
          "opens",
          "closes"
        ],
        "additionalProperties": false,
        "properties": {
          "@type": {
            "type": "string",
            "description": "schema.org's type tag (`OpeningHoursSpecification`), kept when pasted from JSON-LD."
          },
          "validFrom": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "format": "date",
            "description": "The first date it applies, `YYYY-MM-DD`."
          },
          "validThrough": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "format": "date",
            "description": "The last date it applies, `YYYY-MM-DD`; absent means `validFrom` alone."
          },
          "dayOfWeek": {
            "$ref": "#/components/schemas/OpeningHoursDayOfWeek"
          },
          "opens": {
            "type": "string",
            "pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$",
            "description": "When the window opens on those dates."
          },
          "closes": {
            "type": "string",
            "pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$",
            "description": "When the window closes on those dates."
          }
        }
      },
      "OpeningHoursFieldValue": {
        "description": "An `openingHours` field's value — schema.org's OpeningHoursSpecification, as a website's JSON-LD publishes it, plus the zone the times are in and the region whose public holidays `PublicHolidays` means. A day named nowhere is closed. `x-openingHoursSpecification` marks the rules JSON Schema cannot say, which the server and the client both check: each day's windows listed in order without overlap and none empty, only a day's last window running past midnight and not overlapped by the next day's first, no day both closed and open, and a dated exception's range in order. `x-counterexamples` lists a value each rule refuses.",
        "type": "object",
        "additionalProperties": false,
        "x-openingHoursSpecification": true,
        "properties": {
          "timezone": {
            "type": "string",
            "pattern": "^[A-Za-z_]+(?:/[A-Za-z0-9_+\\-]+)*$",
            "maxLength": 64,
            "format": "iana-timezone",
            "description": "The IANA zone the times are in (`Europe/Lisbon`); absent reads as UTC."
          },
          "holidayRegion": {
            "type": "string",
            "pattern": "^[A-Z]{2}(-[A-Z0-9]{1,3})?$",
            "format": "holiday-region",
            "description": "The ISO 3166 country, optionally with a subdivision (`PT`, `GB-ENG`, `US-NY`), whose public holidays `PublicHolidays` means. Only the code is stored."
          },
          "openingHoursSpecification": {
            "type": "array",
            "maxItems": 48,
            "description": "The weekly pattern.",
            "items": {
              "$ref": "#/components/schemas/OpeningHoursWeeklyEntry"
            }
          },
          "specialOpeningHoursSpecification": {
            "type": "array",
            "maxItems": 366,
            "description": "Dated exceptions to the weekly pattern.",
            "items": {
              "$ref": "#/components/schemas/OpeningHoursDatedEntry"
            }
          }
        },
        "x-field-type": "openingHours",
        "x-examples": [
          {
            "timezone": "Europe/Lisbon",
            "holidayRegion": "PT",
            "openingHoursSpecification": [
              {
                "@type": "OpeningHoursSpecification",
                "dayOfWeek": [
                  "Tuesday",
                  "Wednesday"
                ],
                "opens": "12:00",
                "closes": "15:00"
              },
              {
                "dayOfWeek": [
                  "Tuesday",
                  "Wednesday"
                ],
                "opens": "19:00",
                "closes": "23:00"
              },
              {
                "dayOfWeek": "Saturday",
                "opens": "19:00",
                "closes": "01:00"
              },
              {
                "dayOfWeek": [
                  "Sunday",
                  "PublicHolidays"
                ],
                "opens": "00:00",
                "closes": "00:00"
              }
            ],
            "specialOpeningHoursSpecification": [
              {
                "@type": "OpeningHoursSpecification",
                "validFrom": "2026-12-24",
                "validThrough": "2026-12-24",
                "dayOfWeek": "Thursday",
                "opens": "12:00",
                "closes": "15:00"
              }
            ]
          }
        ],
        "x-counterexamples": [
          {
            "rule": "x-openingHoursSpecification",
            "why": "A window that opens and closes at the same time (other than 00:00-00:00, closed) is empty.",
            "value": {
              "openingHoursSpecification": [
                {
                  "dayOfWeek": "Monday",
                  "opens": "09:00",
                  "closes": "09:00"
                }
              ]
            }
          },
          {
            "rule": "x-openingHoursSpecification",
            "why": "Monday's second window opens before its first closes.",
            "value": {
              "openingHoursSpecification": [
                {
                  "dayOfWeek": "Monday",
                  "opens": "09:00",
                  "closes": "12:00"
                },
                {
                  "dayOfWeek": "Monday",
                  "opens": "11:00",
                  "closes": "14:00"
                }
              ]
            }
          },
          {
            "rule": "x-openingHoursSpecification",
            "why": "Friday's window that runs past midnight is not the day's last.",
            "value": {
              "openingHoursSpecification": [
                {
                  "dayOfWeek": "Friday",
                  "opens": "20:00",
                  "closes": "01:00"
                },
                {
                  "dayOfWeek": "Friday",
                  "opens": "21:00",
                  "closes": "23:00"
                }
              ]
            }
          },
          {
            "rule": "x-openingHoursSpecification",
            "why": "Sunday opens at 01:00, while Saturday's late window is still open until 03:00.",
            "value": {
              "openingHoursSpecification": [
                {
                  "dayOfWeek": "Saturday",
                  "opens": "19:00",
                  "closes": "03:00"
                },
                {
                  "dayOfWeek": "Sunday",
                  "opens": "01:00",
                  "closes": "04:00"
                }
              ]
            }
          },
          {
            "rule": "x-openingHoursSpecification",
            "why": "Sunday is marked closed all day and also given an open window.",
            "value": {
              "openingHoursSpecification": [
                {
                  "dayOfWeek": "Sunday",
                  "opens": "00:00",
                  "closes": "00:00"
                },
                {
                  "dayOfWeek": "Sunday",
                  "opens": "10:00",
                  "closes": "14:00"
                }
              ]
            }
          },
          {
            "rule": "x-openingHoursSpecification",
            "why": "The dated exception ends before it starts.",
            "value": {
              "specialOpeningHoursSpecification": [
                {
                  "validFrom": "2026-12-26",
                  "validThrough": "2026-12-24",
                  "opens": "10:00",
                  "closes": "14:00"
                }
              ]
            }
          },
          {
            "rule": "x-openingHoursSpecification",
            "why": "Two dated exceptions on Christmas Eve overlap.",
            "value": {
              "specialOpeningHoursSpecification": [
                {
                  "validFrom": "2026-12-24",
                  "opens": "09:00",
                  "closes": "12:00"
                },
                {
                  "validFrom": "2026-12-24",
                  "opens": "11:00",
                  "closes": "13:00"
                }
              ]
            }
          },
          {
            "rule": "format:iana-timezone",
            "why": "The zone name is well formed but no such zone exists.",
            "value": {
              "timezone": "Europe/Lonodn"
            }
          },
          {
            "rule": "format:holiday-region",
            "why": "The region code is well formed but names no country with public holidays.",
            "value": {
              "holidayRegion": "ZZ"
            }
          }
        ]
      },
      "RecurrenceException": {
        "description": "One occurrence of a series changed on its own: cancelled, or moved to another start, without touching the rest of the series. It names the occurrence by the start the series scheduled for it, written like the value's `start` (a date for an all-day series, a date and time for a timed one).",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "date"
        ],
        "properties": {
          "date": {
            "type": "string",
            "maxLength": 19,
            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T([01]\\d|2[0-3]):[0-5]\\d(:[0-5]\\d)?)?$",
            "description": "The scheduled start of the occurrence this changes, in the series' own zone and form; it must be an occurrence the rule produces."
          },
          "cancelled": {
            "type": "boolean",
            "description": "True when the occurrence does not happen. Exactly one of `cancelled` and `start` is given."
          },
          "start": {
            "type": "string",
            "maxLength": 19,
            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T([01]\\d|2[0-3]):[0-5]\\d(:[0-5]\\d)?)?$",
            "description": "Where the occurrence happens instead, as a wall-clock moment in the series' zone and in the series' form."
          },
          "duration": {
            "type": "integer",
            "minimum": 0,
            "maximum": 31622400,
            "description": "How long the moved occurrence lasts, in whole seconds, when it differs from the series' `duration`; only with `start`."
          }
        }
      },
      "RecurrenceFieldValue": {
        "description": "A `recurrence` field's value — a series as one fact: an RFC 5545 recurrence rule, the first occurrence it starts from, the zone its wall-clock times live in, how long each occurrence lasts, and the occurrences cancelled or moved on their own. The kind of series follows the form of `start`: a date (`2026-10-20`) makes an all-day series whose occurrences are days; a date and time (`2026-10-20T09:00`) a timed series, every occurrence at that wall-clock time in `timezone`, so a 09:00 shift stays at 09:00 across a clock change. The platform expands a series into occurrences over a window — `GET /tables/{tableId}/fields/{fieldId}/occurrences`, and the calendar view — rather than storing them. `x-recurrence` marks the rules JSON Schema cannot say, which the server and the client both check: the rule parses in the grammar the field admits (`FREQ` of `DAILY`, `WEEKLY`, `MONTHLY` or `YEARLY`; `INTERVAL`; one of `COUNT` and `UNTIL`; `BYDAY` with an ordinal only for monthly and yearly rules; `BYMONTHDAY`; `BYMONTH`; `BYSETPOS`; `WKST`), the start is a real date, an all-day series lasts whole days, and every exception is in the series' form, names an occurrence the rule produces, is named once, and either cancels or moves it. `x-counterexamples` lists a value each rule refuses.",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "start",
          "rule"
        ],
        "x-recurrence": true,
        "properties": {
          "start": {
            "type": "string",
            "maxLength": 19,
            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T([01]\\d|2[0-3]):[0-5]\\d(:[0-5]\\d)?)?$",
            "description": "The first occurrence's start, as a wall-clock moment in `timezone`: a date for an all-day series, a date and time (`2026-10-20T09:00`) for a timed one. Every occurrence keeps this time of day."
          },
          "timezone": {
            "type": "string",
            "pattern": "^[A-Za-z_]+(?:/[A-Za-z0-9_+\\-]+)*$",
            "maxLength": 64,
            "format": "iana-timezone",
            "description": "The IANA zone the times are in (`Europe/Lisbon`); absent reads as UTC."
          },
          "rule": {
            "type": "string",
            "maxLength": 512,
            "pattern": "^[A-Z]+=[^;=]+(;[A-Z]+=[^;=]+)*$",
            "description": "The RFC 5545 recurrence rule, without the `RRULE:` prefix: `FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,TH;COUNT=10`. `UNTIL` is inclusive and is a date (`20271231`, through that day in the series' zone), a wall-clock moment (`20271231T235959`) or an instant (`20271231T235959Z`)."
          },
          "duration": {
            "type": "integer",
            "minimum": 0,
            "maximum": 31622400,
            "description": "How long each occurrence lasts, in whole seconds; absent is an instant (timed) or one day (all-day). An all-day series counts whole days, so the value is a multiple of 86400."
          },
          "exceptions": {
            "type": "array",
            "maxItems": 366,
            "description": "The occurrences cancelled or moved on their own; the series stays as it is.",
            "items": {
              "$ref": "#/components/schemas/RecurrenceException"
            }
          }
        },
        "x-field-type": "recurrence",
        "x-examples": [
          {
            "start": "2026-10-20T09:00",
            "timezone": "Europe/Lisbon",
            "rule": "FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,TH;UNTIL=20271231",
            "duration": 5400,
            "exceptions": [
              {
                "date": "2026-11-03T09:00",
                "cancelled": true
              },
              {
                "date": "2026-11-05T09:00",
                "start": "2026-11-06T14:00",
                "duration": 3600
              }
            ]
          },
          {
            "start": "2026-10-01",
            "rule": "FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1;COUNT=12"
          }
        ],
        "x-counterexamples": [
          {
            "rule": "x-recurrence",
            "why": "The rule's frequency is not one the field admits.",
            "value": {
              "start": "2026-10-20",
              "rule": "FREQ=HOURLY"
            }
          },
          {
            "rule": "x-recurrence",
            "why": "The start is well formed but is not a calendar date.",
            "value": {
              "start": "2026-02-30",
              "rule": "FREQ=DAILY"
            }
          },
          {
            "rule": "x-recurrence",
            "why": "The series is timed, but the exception names its occurrence by a bare date.",
            "value": {
              "start": "2026-10-20T09:00",
              "rule": "FREQ=WEEKLY",
              "exceptions": [
                {
                  "date": "2026-10-27",
                  "cancelled": true
                }
              ]
            }
          },
          {
            "rule": "x-recurrence",
            "why": "An all-day series lasts whole days, not an hour.",
            "value": {
              "start": "2026-10-20",
              "rule": "FREQ=WEEKLY",
              "duration": 3600
            }
          },
          {
            "rule": "x-recurrence",
            "why": "The exception neither cancels the occurrence nor moves it.",
            "value": {
              "start": "2026-10-20",
              "rule": "FREQ=WEEKLY",
              "exceptions": [
                {
                  "date": "2026-10-27"
                }
              ]
            }
          },
          {
            "rule": "x-recurrence",
            "why": "The exception both cancels the occurrence and moves it.",
            "value": {
              "start": "2026-10-20",
              "rule": "FREQ=WEEKLY",
              "exceptions": [
                {
                  "date": "2026-10-27",
                  "cancelled": true,
                  "start": "2026-10-28"
                }
              ]
            }
          },
          {
            "rule": "x-recurrence",
            "why": "A duration is given for an occurrence that is cancelled, not moved.",
            "value": {
              "start": "2026-10-20",
              "rule": "FREQ=WEEKLY",
              "exceptions": [
                {
                  "date": "2026-10-27",
                  "cancelled": true,
                  "duration": 86400
                }
              ]
            }
          },
          {
            "rule": "x-recurrence",
            "why": "Two exceptions name the same occurrence.",
            "value": {
              "start": "2026-10-20",
              "rule": "FREQ=WEEKLY",
              "exceptions": [
                {
                  "date": "2026-10-27",
                  "cancelled": true
                },
                {
                  "date": "2026-10-27",
                  "start": "2026-10-28"
                }
              ]
            }
          },
          {
            "rule": "x-recurrence",
            "why": "The exception names a Wednesday, and the series falls on Tuesdays.",
            "value": {
              "start": "2026-10-20",
              "rule": "FREQ=WEEKLY",
              "exceptions": [
                {
                  "date": "2026-10-28",
                  "cancelled": true
                }
              ]
            }
          },
          {
            "rule": "format:iana-timezone",
            "why": "The zone name is well formed but no such zone exists.",
            "value": {
              "start": "2026-10-20",
              "rule": "FREQ=DAILY",
              "timezone": "Europe/Lonodn"
            }
          }
        ]
      },
      "FieldConfig": {
        "type": "object",
        "description": "User-friendly configuration for field validation and behavior.\nThe structure depends on the fieldType. The backend translates\nthis to JSON Schema for storage and validation.\n\nEvery property carries an `x-field-types` annotation naming the\nfield types the key applies to (`\"*\"` = every type). This is the\nMACHINE-READABLE source of truth for per-type field capabilities:\nthe fieldConfigCatalog module derives the per-type constraint\nreference surfaced to AI schema authors (MCP authoring guide and\nthe in-app schema assistant) from these annotations, and a drift\nguard cross-checks them against the backend's actual\nFieldConfig → JSON Schema translation. A key set on a field type\noutside its `x-field-types` list is ignored by the backend.\n\nEvery property also carries `x-refines`: per field type, the JSON\npointer of the one keyword it sets in that type's value contract\n(the `*FieldValue` components) — a limit the field's owner chooses,\nreplacing the contract's default — or `false` when it never changes\nwhat a value may be. These limits are all a field's config can\nchange: it never reshapes the value. Tests derive boundary values\nfrom these pointers and require the server and the client\nvalidators to agree on them.\n",
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Help text stored with the field",
            "x-field-types": [
              "*"
            ],
            "x-refines": false
          },
          "minLength": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Minimum text length",
            "x-field-types": [
              "text",
              "textarea"
            ],
            "x-refines": {
              "text": "/minLength",
              "textarea": "/minLength"
            }
          },
          "maxLength": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Maximum text length",
            "x-field-types": [
              "text",
              "textarea",
              "richtext"
            ],
            "x-refines": {
              "text": "/maxLength",
              "textarea": "/maxLength",
              "richtext": "/maxLength"
            }
          },
          "pattern": {
            "type": [
              "string",
              "null"
            ],
            "description": "Regex pattern the value must match, e.g. \"^[A-Z]{2}-\\\\d{4}$\"",
            "x-field-types": [
              "text"
            ],
            "x-refines": {
              "text": "/pattern"
            }
          },
          "scannable": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "True when the field holds a code printed on a physical thing as a barcode or QR code (an asset tag, a SKU, a serial number). The app's editor offers to fill the field from the camera, and scanning a code from the app's Scan page finds the records whose scannable field equals it exactly. Changes nothing about what a value may be; making the field unique is a separate choice.",
            "x-field-types": [
              "text"
            ],
            "x-refines": false
          },
          "minimum": {
            "type": [
              "number",
              "null"
            ],
            "description": "Smallest allowed value (inclusive), e.g. 0",
            "x-field-types": [
              "integer",
              "number",
              "currency",
              "percent"
            ],
            "x-refines": {
              "integer": "/minimum",
              "number": "/minimum",
              "currency": "/properties/amount/minimum",
              "percent": "/minimum"
            }
          },
          "maximum": {
            "type": [
              "number",
              "null"
            ],
            "description": "Largest allowed value (inclusive), e.g. 5",
            "x-field-types": [
              "integer",
              "number",
              "currency",
              "percent"
            ],
            "x-refines": {
              "integer": "/maximum",
              "number": "/maximum",
              "currency": "/properties/amount/maximum",
              "percent": "/maximum"
            }
          },
          "multipleOf": {
            "type": [
              "number",
              "null"
            ],
            "description": "e.g., 0.01 for 2 decimal places, 0.5 for half steps",
            "x-field-types": [
              "number"
            ],
            "x-refines": {
              "number": "/multipleOf"
            }
          },
          "precision": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Decimal places for percent fields",
            "x-field-types": [
              "percent"
            ],
            "x-refines": {
              "percent": "/multipleOf"
            }
          },
          "currencyCode": {
            "type": [
              "string",
              "null"
            ],
            "description": "ISO 4217 currency code (USD, EUR, GBP)",
            "x-field-types": [
              "currency"
            ],
            "x-refines": false
          },
          "ratingMax": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 10,
            "description": "Number of stars the field offers (the largest value it accepts). Defaults to 5.",
            "x-field-types": [
              "rating"
            ],
            "x-refines": {
              "rating": "/maximum"
            }
          },
          "trueLabel": {
            "type": [
              "string",
              "null"
            ],
            "description": "e.g., \"Yes\", \"Active\"",
            "x-field-types": [
              "boolean"
            ],
            "x-refines": false
          },
          "falseLabel": {
            "type": [
              "string",
              "null"
            ],
            "description": "e.g., \"No\", \"Inactive\"",
            "x-field-types": [
              "boolean"
            ],
            "x-refines": false
          },
          "minDate": {
            "type": [
              "string",
              "null"
            ],
            "description": "Earliest allowed date (ISO date string)",
            "x-field-types": [
              "date"
            ],
            "x-refines": {
              "date": "/x-minDate"
            }
          },
          "maxDate": {
            "type": [
              "string",
              "null"
            ],
            "description": "Latest allowed date (ISO date string)",
            "x-field-types": [
              "date"
            ],
            "x-refines": {
              "date": "/x-maxDate"
            }
          },
          "minDatetime": {
            "type": [
              "string",
              "null"
            ],
            "description": "Earliest allowed timestamp (ISO datetime string)",
            "x-field-types": [
              "datetime"
            ],
            "x-refines": {
              "datetime": "/x-minDatetime"
            }
          },
          "maxDatetime": {
            "type": [
              "string",
              "null"
            ],
            "description": "Latest allowed timestamp (ISO datetime string)",
            "x-field-types": [
              "datetime"
            ],
            "x-refines": {
              "datetime": "/x-maxDatetime"
            }
          },
          "minTime": {
            "type": [
              "string",
              "null"
            ],
            "description": "Earliest allowed time of day, HH:MM format",
            "x-field-types": [
              "time"
            ],
            "x-refines": {
              "time": "/x-minTime"
            }
          },
          "maxTime": {
            "type": [
              "string",
              "null"
            ],
            "description": "Latest allowed time of day, HH:MM format",
            "x-field-types": [
              "time"
            ],
            "x-refines": {
              "time": "/x-maxTime"
            }
          },
          "minDuration": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Smallest allowed duration, in seconds (inclusive)",
            "x-field-types": [
              "duration"
            ],
            "x-refines": {
              "duration": "/minimum"
            }
          },
          "maxDuration": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Largest allowed duration, in seconds (inclusive)",
            "x-field-types": [
              "duration"
            ],
            "x-refines": {
              "duration": "/maximum"
            }
          },
          "durationUnit": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "seconds",
              "minutes",
              "hours",
              "days",
              null
            ],
            "description": "Unit the editor's input box works in, and the unit a bare number is read as on import. Display only — the stored value is always seconds. Defaults to `hours`.",
            "x-field-types": [
              "duration"
            ],
            "x-refines": false
          },
          "durationFormat": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "humanized",
              "clock",
              "decimal",
              null
            ],
            "description": "How the value renders. `humanized` → \"4h 30m\"; `clock` → \"04:30\"; `decimal` → \"4.5\" in `durationUnit`. Defaults to `humanized`.",
            "x-field-types": [
              "duration"
            ],
            "x-refines": false
          },
          "phoneFormat": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "international",
              "national",
              "any",
              null
            ],
            "description": "Required phone number format",
            "x-field-types": [
              "phone"
            ],
            "x-refines": {
              "phone": "/x-phoneFormat"
            }
          },
          "defaultCountry": {
            "type": [
              "string",
              "null"
            ],
            "description": "ISO 3166-1 alpha-2 country code",
            "x-field-types": [
              "phone",
              "address"
            ],
            "x-refines": false
          },
          "allowedProtocols": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "e.g., [\"http\", \"https\"]",
            "x-field-types": [
              "url"
            ],
            "x-refines": {
              "url": "/x-allowedProtocols"
            }
          },
          "options": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/PicklistOption"
            },
            "description": "The selectable options, in canonical display order",
            "x-field-types": [
              "picklist",
              "multipicklist"
            ],
            "x-refines": {
              "picklist": "/enum",
              "multipicklist": "/items/enum"
            }
          },
          "minSelections": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Minimum number of selected options",
            "x-field-types": [
              "multipicklist"
            ],
            "x-refines": {
              "multipicklist": "/minItems"
            }
          },
          "maxSelections": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Maximum number of selected options",
            "x-field-types": [
              "multipicklist"
            ],
            "x-refines": {
              "multipicklist": "/maxItems"
            }
          },
          "displayField": {
            "type": [
              "string",
              "null"
            ],
            "description": "Which field to show as the reference label",
            "x-field-types": [
              "reference",
              "multiReference"
            ],
            "x-refines": false
          },
          "allowedMimeTypes": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Allowed MIME types, e.g., [\"image/*\", \"application/pdf\"]",
            "x-field-types": [
              "attachment"
            ],
            "x-refines": false
          },
          "maxFileSizeMB": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Maximum file size in MB, default 10",
            "x-field-types": [
              "attachment"
            ],
            "x-refines": false
          },
          "maxFiles": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Maximum number of files for multi-attachment, default 1",
            "x-field-types": [
              "attachment"
            ],
            "x-refines": false
          },
          "requiredFields": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string",
              "enum": [
                "street",
                "street2",
                "city",
                "state",
                "postalCode",
                "country"
              ]
            },
            "description": "Address parts that must be filled in",
            "x-field-types": [
              "address"
            ],
            "x-refines": {
              "address": "/required"
            }
          },
          "formula": {
            "type": [
              "object",
              "null"
            ],
            "description": "Definition of a computed field: a small expression over sibling\nfields (arithmetic, comparisons, if/coalesce, text functions,\ndays_between/add_days for dates, hours_between/minutes_between/\nseconds_between and add_hours/add_minutes for datetime/time),\ncompiled server-side into a stored generated column. Formula fields\nare read-only on the write path.\n",
            "required": [
              "expression",
              "resultType"
            ],
            "x-field-types": [
              "formula"
            ],
            "x-refines": false,
            "properties": {
              "expression": {
                "type": "string",
                "description": "e.g. \"days_between(check_out, check_in)\""
              },
              "resultType": {
                "description": "Declared type of the computed value: `integer`, `number`, `text`, `boolean`, `date`, `datetime` or `time`. Must agree with what `expression` evaluates to — a mismatch is rejected at save time — and decides how the value is stored, aggregated and rendered.",
                "type": "string",
                "enum": [
                  "integer",
                  "number",
                  "text",
                  "boolean",
                  "date",
                  "datetime",
                  "time"
                ]
              }
            }
          },
          "autonumber": {
            "type": [
              "object",
              "null"
            ],
            "description": "Configuration for a system-assigned document number, backed by a\nper-field database sequence. Read-only on the write path — the\nvalue is assigned by the sequence, never by the client. Numbers\nare unique and increase in order of assignment. A write that is\nrefused after its number was taken leaves a gap, so the sequence\nis not gapless.\n",
            "x-field-types": [
              "autonumber"
            ],
            "x-refines": false,
            "properties": {
              "format": {
                "type": "string",
                "description": "Display format applied on read. A run of zeros ({0000}) is the\nzero-padded number; {YYYY}/{YY}/{MM} come from the record's\ncreation date; other characters are literal. Default \"{0000}\"\n(e.g. \"INV-{0000}\" → \"INV-0042\").\n"
              },
              "start": {
                "type": "integer",
                "minimum": 1,
                "description": "First number the sequence issues (default 1)."
              }
            }
          },
          "lookup": {
            "type": [
              "object",
              "null"
            ],
            "description": "Projects a field across a forward reference: the value of\n`sourceField` on the row this table's `via` reference points at.\nComputed at read time — no stored column, always current,\nread-only on the write path. The source may be a scalar field, a\nreference (the lookup lands the id it holds, shown as a link to\nthat record) or a multipicklist (the lookup lands its array of\noptions, filterable with `contains` / `containsAny`).\n",
            "required": [
              "via",
              "sourceField"
            ],
            "x-field-types": [
              "lookup"
            ],
            "x-refines": false,
            "properties": {
              "via": {
                "type": "string",
                "description": "A reference field on this table (entity 'table')"
              },
              "sourceField": {
                "type": "string",
                "description": "Field name on the referenced table to project: a scalar field (text-family, numbers, boolean, date/datetime/time, picklist), a formula, a reference, a multipicklist, or that table's own lookup or rollup field (a chain: a session's athlete as the lookup of its week's athlete lookup). A chain is at most 3 cross-row hops deep, counting this one; a deeper chain or a cycle is refused with `COMPUTED_FIELD_CHAIN_FORBIDDEN`."
              },
              "resultType": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "integer",
                  "number",
                  "text",
                  "boolean",
                  "date",
                  "datetime",
                  "time",
                  "reference",
                  "multipicklist",
                  null
                ],
                "readOnly": true,
                "description": "The value type the lookup lands, derived by the server from the source field when the field is created: `reference` for a reference source (a record id), `multipicklist` for a multipicklist source (an array of option values). Present on reads; ignored on writes."
              },
              "resultReference": {
                "$ref": "#/components/schemas/LookupResultReference"
              }
            }
          },
          "rollup": {
            "type": [
              "object",
              "null"
            ],
            "description": "Aggregates over rows of `sourceTable` whose `via` reference\npoints at this row — e.g. total open deal value on an account,\nor a trip's start date as MIN over its flights. Computed at read\ntime — no stored column, always current, read-only on the write\npath. `filter` is an optional boolean expression (the formula\ngrammar) over the source table's fields.\n\nA **match rollup** names no `via`: it aggregates the source rows\nwhose `match` fields equal fields of this row and, with `range`,\nwhose value falls in a window this row defines — a training\nweek's actual km as the SUM of the athlete's activities dated in\n[week_start, week_end). Give exactly one of `via`, or `match`\nand/or `range`.\n",
            "required": [
              "sourceTable",
              "aggregate"
            ],
            "x-field-types": [
              "rollup"
            ],
            "x-refines": false,
            "properties": {
              "sourceTable": {
                "type": "string",
                "description": "The referencing (child) table's name"
              },
              "via": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Reference field on the source table pointing at this table. Omit it for a match rollup, which correlates through `match` and `range` instead."
              },
              "match": {
                "type": [
                  "array",
                  "null"
                ],
                "maxItems": 3,
                "description": "A match rollup's equality pairs (at most 3): a source row is aggregated only when every pair's `source` field equals this row's `target` field. Omit with `via`.",
                "items": {
                  "$ref": "#/components/schemas/RollupMatchPair"
                }
              },
              "range": {
                "$ref": "#/components/schemas/RollupRange"
              },
              "aggregate": {
                "description": "How the matching source rows are combined: `count` (number of rows; needs no `sourceField`), `sum` and `avg` (numeric source fields: integer, number, currency, percent, duration, rating), `min` and `max` (those numeric types plus date, datetime and time), `union` (a multipicklist source: every option selected on any matching row, each once, sorted — e.g. a menu's allergens across its dishes). Text fields cannot be rolled up.",
                "type": "string",
                "enum": [
                  "count",
                  "sum",
                  "min",
                  "max",
                  "avg",
                  "union"
                ]
              },
              "sourceField": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Field on the source table to aggregate (omit for count): a stored field, a formula field, one of the source table's lookup or rollup fields, or one of its workspace-shared read-time computed columns, whose expression (lookups and rollups included) is evaluated per source row inside the aggregate. Over a rollup this is a chain — a plan's total km as the `sum` of its weeks' planned km, itself a `sum` over sessions — at most 3 cross-row hops deep, counting this one. `sum`, `min`, `max` and `union` compose; `avg` over a rollup (or a computed column reading one) is refused, since an average of averages is not the average: roll up a `sum` and a `count` and divide them in a computed column. To count grandchildren, `sum` the children's `count` rollup; `count` takes no `sourceField`."
              },
              "filter": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Optional boolean expression over source-table fields, e.g. \"status = 'open'\""
              },
              "resultType": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "integer",
                  "number",
                  "text",
                  "boolean",
                  "date",
                  "datetime",
                  "time",
                  "multipicklist",
                  null
                ],
                "readOnly": true,
                "description": "The value type the aggregate lands (count → integer, sum/avg → number, min/max → the source field's type, union → multipicklist), derived by the server when the field is created. Present on reads; ignored on writes."
              }
            }
          }
        }
      },
      "DataTable": {
        "description": "A table of the workspace — the user-defined record type that records (`TableItem`) belong to — or a data-level SQL view (`kind: view`). Returned by the table endpoints, by view creation, and carried in `TableEventPayload`.",
        "type": "object",
        "required": [
          "id",
          "name",
          "displayName",
          "userId",
          "isActive",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "12-character hex ID"
          },
          "name": {
            "description": "The table's physical identifier, used in the records API, queries and SQL. Fixed at creation and never renamed; a deleted table keeps its name reserved. Rename the human label via `displayName`.",
            "type": "string"
          },
          "displayName": {
            "description": "The human-readable label shown in the UI and navigation. Freely editable; changing it does not affect `name` or any API path.",
            "type": "string"
          },
          "description": {
            "description": "Free-text description of what the table holds, shown to people in the UI. Null when none was given; AI-facing guidance goes in `aiHint`.",
            "type": [
              "string",
              "null"
            ]
          },
          "aiHint": {
            "type": [
              "string",
              "null"
            ],
            "description": "Hint for AI agents about this table's purpose and relationships"
          },
          "userId": {
            "description": "Id of the user who created the table. Informational; ownership of the table's records is per record (`TableItem.ownedBy`).",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$"
          },
          "isActive": {
            "description": "False once the table has been soft-deleted: it disappears from the default list and rejects writes, but its records and name are retained. Provisioned built-ins are disabled this way rather than deleted.",
            "type": "boolean"
          },
          "kind": {
            "type": "string",
            "enum": [
              "table",
              "view"
            ],
            "default": "table",
            "description": "'table' = a physical record table; 'view' = a data-level SQL view (read-only, backed by a validated SELECT). Views appear in the tables surface but reject every mutation."
          },
          "viewSql": {
            "type": [
              "string",
              "null"
            ],
            "description": "kind='view' only — the SELECT the view is backed by"
          },
          "defaultRecordVisibility": {
            "$ref": "#/components/schemas/RecordVisibility"
          },
          "rowScopeField": {
            "type": [
              "string",
              "null"
            ],
            "description": "Inherited row scope: the name of one of this table's reference fields, or null. When set, a record here is permitted to a person for an operation exactly when the record that field points at is permitted to them for the same operation, and creating a record (or pointing one at another parent) needs update on that parent. The table is then governed on every operation; a record whose field is empty is an administrator's only."
          },
          "governedVerbs": {
            "type": "array",
            "description": "The record operations some role's row rule governs on this table (or every operation, on a `restricted` table or one with a `rowScopeField`): there, the baseline Member and Reader roles grant nothing and a person reaches a record only through a rule on one of their roles or a share. Empty for an open table. Present on the table reads; a view, a write response and an event carry no answer.",
            "items": {
              "$ref": "#/components/schemas/RecordVerb"
            }
          },
          "commentsEnabled": {
            "type": "boolean",
            "default": false,
            "description": "Whether records in this table carry a discussion thread. Off by default: a comment box on a lookup or junction table is clutter, so an admin opts the tables in where conversation actually belongs. Enforced server-side — the comments endpoints 404 while this is false — rather than merely hidden by the UI. Turning it off makes existing comments unreachable; it never deletes them."
          },
          "isSearchable": {
            "type": "boolean",
            "default": true,
            "description": "Whether this table participates in global search. On by default — a record you cannot find is a record you do not have. Turning it off drops the table's search index entirely, which is the point: an admin with a 10M-row event log needs a way to keep it out of the index rather than merely out of the results."
          },
          "systemKey": {
            "type": [
              "string",
              "null"
            ],
            "x-known-values": "KnownSystemTableKey",
            "description": "The table's base type, when it was created with one (`CreateDataTableRequest.baseType`; today only 'activities' — the open-enum KnownSystemTableKey lists the vocabulary). A base-typed table carries a core of provisioned fields the platform relies on, and that core is locked: those fields cannot be deleted, retyped, or have required/unique/visibility flipped, and their seed picklist options cannot be removed or value-renamed. Extending the table — new fields, new picklist options, label and description edits, deleting the whole table — stays fully open; that is the point of provisioning a REAL table rather than a system one. A workspace may hold several tables of one base type. Absent/null on ordinary user tables. Open contract: clients must tolerate keys they do not know (treat an unknown key as \"locked built-in\"), since new built-ins arrive without a spec bump. Distinct from user/group reference targets (referencedEntityType), which are not tables in this list at all."
          },
          "mirror": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MirrorSummary"
              },
              {
                "type": "null"
              }
            ],
            "description": "The table's live mirror, when its records come from an external source (for example a Salesforce object) and are kept current by a sync. While present, records cannot be created, deleted or restored, and the fields listed as mirrored (`TableField.isMirrored`) cannot be changed, by anyone but the sync; other fields stay editable. Null on an ordinary table and on a detached one. Present on `GET /tables` and `GET /tables/{tableId}`; other responses may omit it."
          },
          "displayLabel": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TableDisplayLabel"
              },
              {
                "type": "null"
              }
            ],
            "description": "The table's display label — what a row of this table is called wherever it is shown out of context: reference pickers and cells (unless the referencing field sets its own `referencedFieldId`), record headers, board cards, calendar and map titles, search hits. Either a stored field (`TableField.labelField`) or a read-time computed column (`DerivedField.labelField`); absent when the table has neither, in which case clients fall back to a field named name/displayName/title, then the record id. The value is read from the record's `data` under `name` — computed labels are part of every record read, so the same lookup works for both kinds."
          },
          "rowCount": {
            "type": "integer",
            "description": "Approximate number of records in the table, from the workspace's usage counters — maintained on every write and periodically reconciled, so it can briefly lag the true count. For showing a table's size without reading its records (the app's data overview); use POST /tables/{tableId}/aggregate for an exact count. Absent for views (their row count is computed per query) and for tables whose counter has not been established yet — show no count rather than zero."
          },
          "createdAt": {
            "description": "When the table was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the table's own metadata (label, description, flags) last changed, ISO-8601 UTC. Record writes do not move it.",
            "type": "string",
            "format": "date-time"
          },
          "fields": {
            "description": "The table's fields in display order, each with its type and config. Present on single-table reads and table events; list responses may omit it, and `PUT /tables/{tableId}` omits it unless asked with `include=fields`.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TableField"
            }
          }
        }
      },
      "TableDisplayLabel": {
        "type": "object",
        "description": "Which column carries a table's display label, and where it lives. `field` is a stored schema field (`fieldId`); `computed` is a read-time computed column (`derivedFieldId`) — a formula over the row's own fields and its lookups, evaluated on every read and never stored, so the summary it renders can never disagree with the fields it summarises. `name` is the key under which the value appears in a record's `data` for either kind.",
        "required": [
          "kind",
          "name",
          "displayName"
        ],
        "properties": {
          "kind": {
            "description": "`field` the label is a stored schema field (see `fieldId`); `computed` it is a read-time computed column (see `derivedFieldId`).",
            "type": "string",
            "enum": [
              "field",
              "computed"
            ]
          },
          "name": {
            "type": "string",
            "description": "Column name — the key in a record's `data`."
          },
          "displayName": {
            "description": "Human-readable name of the label column, for headers and pickers.",
            "type": "string"
          },
          "fieldId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "The `TableField.id`, when kind is `field`."
          },
          "derivedFieldId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "The `DerivedField.id`, when kind is `computed`."
          }
        }
      },
      "TableField": {
        "description": "A field (column) of a table: its names, type, constraints, visibility, default and configuration, plus the reference target when it points at another table, users or groups. Returned by the field endpoints and listed under `DataTable.fields`; the `FieldEventPayload` WebSocket frame carries it when a field changes.",
        "type": "object",
        "required": [
          "id",
          "tableId",
          "fieldName",
          "displayName",
          "fieldType",
          "isRequired",
          "isUnique",
          "displayOrder"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "12-character hex ID"
          },
          "tableId": {
            "description": "Stable identifier of the table this field belongs to; does not change when the table is renamed.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "fieldName": {
            "description": "Stable internal name of the field: the key under which its value appears in record `data`, and the name used in filters, queries and formulas.",
            "type": "string"
          },
          "displayName": {
            "description": "Human-readable label shown as the column header and form label; can change without affecting `fieldName`.",
            "type": "string"
          },
          "fieldType": {
            "$ref": "#/components/schemas/FieldType"
          },
          "isRequired": {
            "description": "True when every record must hold a value (or the field has a `defaultValue`); creates without one are refused.",
            "type": "boolean"
          },
          "isUnique": {
            "description": "True when no two live records may hold the same value; enforced on write.",
            "type": "boolean"
          },
          "labelField": {
            "type": "boolean",
            "default": false,
            "description": "True when this field is the table's display label — the value references to this table show in pickers, grid cells, record headers and search hits, unless a referencing field configures its own `referencedFieldId`. At most one field per table (a stored field here, or a computed column via `DerivedField.labelField`) carries it. Being the label says nothing about uniqueness: the table's identity for references is its reference key — a unique label field, or a composite unique constraint marked `referenceKey` (see TableConstraintConfig)."
          },
          "isMirrored": {
            "type": "boolean",
            "description": "True when the field's values come from the table's external source (`DataTable.mirror`): only the sync changes them, and the field cannot be deleted, retyped or re-flagged until the table is detached. False on a local field, which people edit as usual. Present on `GET /tables`, `GET /tables/{tableId}` and `GET /tables/{tableId}/fields`; other responses may omit it."
          },
          "isSystemManaged": {
            "type": "boolean",
            "default": false,
            "description": "True on the provisioned core fields of a systemKey table (see DataTable.systemKey): the field cannot be deleted or retyped, its isRequired/isUnique flags cannot be flipped, and the seed picklist options cannot be removed or value-renamed — built-in views and composers depend on that vocabulary. Its label, description, picklist ADDITIONS, and visibility remain editable: masking a built-in field for some roles works exactly like any other field (flip it private, grant it back per role)."
          },
          "isSearchable": {
            "type": "boolean",
            "default": true,
            "description": "Whether this field's text contributes to the table's global-search document. On by default; only ever consulted for the field types that are searchable at all (text, textarea, richtext, email, phone, url, picklist, autonumber). Turning it off on a free-text field full of pasted email threads removes it from the index — and so from the ranking — without hiding the field itself."
          },
          "visibility": {
            "$ref": "#/components/schemas/FieldVisibility"
          },
          "defaultValue": {
            "type": [
              "string",
              "null"
            ],
            "description": "Applied to records created without this field. A literal in the field's own value format, or a dynamic token resolved when the record is created (DYNAMIC_DEFAULTS in @taskexchange/api-spec): `today` on a `date` field and `now` on a `datetime` field (rendered into the column DEFAULT), or `currentUser` on a reference to workspace users (stamped with the creating user by every write path, since the database cannot know the actor)."
          },
          "fieldConfig": {
            "$ref": "#/components/schemas/FieldConfig",
            "description": "User-friendly field configuration"
          },
          "validationSchema": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {},
            "description": "Full JSON Schema (for power users/debugging)"
          },
          "filterable": {
            "type": "boolean",
            "description": "Present on the FIELD LIST for a lookup or rollup: whether THIS caller may filter and sort the records list by it. A lookup or rollup is filterable for a caller exactly when they could read its source unrestricted — workspace-wide read scope on the source table and no field restriction on the looked-up field — because only then can the value reveal nothing about rows they cannot read. Decided server-side per caller (the client cannot know its own scope on the source), so a picker offers precisely what the list accepts; a `false` here is refused by the list exactly as an unknown name. Absent on other field types, and on single-field responses."
          },
          "stageConfig": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/StageConfig"
              },
              {
                "type": "null"
              }
            ],
            "description": "Present on the FIELD LIST when this field is stage-designated, so a client that already loaded the table's fields knows its lifecycle rules without a request per field. Read-only here — write through `/tables/{tableId}/fields/{fieldId}/stage-config`. Absent on single-field responses."
          },
          "referencedTableId": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "For a `reference` field pointing at a user table (when referencedEntityType is 'table'), the table its values point at; for a `multiReference` field, the one table its linked records belong to."
          },
          "referencedEntityType": {
            "type": "string",
            "enum": [
              "table",
              "user",
              "group"
            ],
            "default": "table",
            "description": "What type of entity this reference field points to"
          },
          "referencedFieldId": {
            "description": "For a `reference` or `multiReference` field, the field of the referenced table whose value is shown as the label in pickers and cells, overriding that table's display label. Null to use the referenced table's own label.",
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "referencedTableIds": {
            "description": "For a `polymorphicReference` field, the tables a value may point into, in display order. Each is an active user table (not a view) with a reference key, and the owning table is never one. Absent for every other type. On a patch, a target may be added at any time; removing one is refused with `POLY_TARGET_IN_USE` while any row, live or binned, still points into it.",
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            },
            "minItems": 2,
            "maxItems": 10
          },
          "cascadeBehavior": {
            "description": "For a reference to a table, what happens to this field's records when the record they point at is purged from the recycle bin: `restrict` refuses the purge while any live record still points at it, `cascade` sends the pointing records to the bin with it and purges them with it, `set_null` clears the reference at purge. `restrict` for every other field. A `multiReference` field has no cascade behaviour of its own: a link always goes with either record when it is purged.",
            "type": "string",
            "enum": [
              "restrict",
              "cascade",
              "set_null"
            ]
          },
          "displayOrder": {
            "description": "Position in the table's default field order, the order `GET /tables/{tableId}/fields` returns; saved views may override it.",
            "type": "integer"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Human-readable description of this field"
          },
          "aiHint": {
            "type": [
              "string",
              "null"
            ],
            "description": "Hint for AI agents about this field's meaning and usage"
          },
          "createdAt": {
            "description": "When the field was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the field's definition last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TableConstraintType": {
        "description": "Kind of a table constraint. `composite_unique`: no two rows share the same values across the listed fields (optionally only among rows matching a condition). `no_overlap`: rows with equal scope values may not have overlapping start/end ranges. `check`: a boolean formula over the row's own fields must hold. `same_parent`: two reference fields must point at rows sharing the same parent. `capacity`: at most N rows (or a summed weight of N) may overlap in time per resource.",
        "type": "string",
        "enum": [
          "composite_unique",
          "no_overlap",
          "check",
          "same_parent",
          "capacity"
        ]
      },
      "TableConstraintConfig": {
        "type": "object",
        "description": "Type-specific constraint configuration. Field references are sanitized\nfield names on the same table.\n- composite_unique: `fields` (2-5 names) must be jointly unique. An\n  optional `condition` — a boolean formula-grammar expression over this\n  table's fields, e.g. \"is_favourite = true\" — limits the rule to the\n  rows that satisfy it (a partial unique index: \"at most one favourite\n  per rater\" is `fields: [rater]`, `condition: \"is_favourite = true\"`).\n  With a condition a single field is allowed. In responses\n  `conditionFields` lists the fields the condition references\n  (server-derived). `caseInsensitive: true` compares the text-family\n  fields ignoring case (the index is over `lower(field)` for those;\n  any other listed field — a reference, a number — compares exactly),\n  and needs at least one text-family field to fold.\n- no_overlap: rows with equal `scope` values cannot have overlapping\n  [start, end) (or [start, end] when bounds is '[]') ranges; `start`\n  and `end` must both be date or both be datetime fields. An optional\n  `condition` (the same grammar as composite_unique's) limits the rule\n  to the rows that satisfy it — a partial exclusion constraint, so\n  `\"status != 'cancelled'\"` lets a cancelled booking release its\n  dates while keeping them.\n- check: every row must satisfy `expression`, a boolean formula-grammar\n  comparison over this table's own fields (e.g. \"check_out > check_in\");\n  compiled server-side from a restricted AST, never raw SQL. Rows with a\n  NULL operand pass (SQL three-valued logic). In responses `fields`\n  lists the field names the expression references (server-derived).\n- same_parent: the rows the two `references` point at must agree on\n  `parentField` — a signup's `itinerary_item` and `attendee` must\n  belong to the same `trip`. Both references must be table references\n  on this table, and `parentField` must be a reference field on each\n  referenced table pointing at one and the same table — or on one of\n  them, when the other reference points straight at that parent table:\n  a reservation's `table` must belong to the reservation's `venue`\n  (`references: [venue, table]`, `parentField: venue`, where\n  `tables.venue` points at `venues`). Enforced by a row trigger on\n  this table's writes; a NULL reference, or a referenced row whose\n  parent is NULL, passes. In responses `referenceTables` and\n  `parentTable` name the tables involved, and `directReference` names\n  the reference that points straight at the parent (server-derived).\n  The record form uses the rule too: a picker for the other reference\n  offers only the rows under the chosen parent, and picking one fills\n  an empty direct reference with its parent.\n- capacity: rows with equal `scope` values may overlap in time, but the\n  summed load of the rows overlapping any instant may not exceed the\n  limit. `start` and `end` are both date or both datetime fields, and\n  `bounds` is as for no_overlap. The limit is either fixed (`capacity`,\n  a number above 0) or read from the resource the row points at\n  (`capacityReference`, one of the `scope` reference fields, plus\n  `capacityField`, a number field on the referenced table). Set exactly\n  one form. Each row counts `weight` (a number field on this table)\n  toward the load, or 1 when there is no weight. An optional\n  `condition` (the same grammar as no_overlap's) limits the rule to the\n  rows it selects. In responses `capacityTable` names the table\n  `capacityReference` points at (server-derived).\n",
        "properties": {
          "type": {
            "description": "The kind of constraint this config describes — the same value as the constraint's `constraintType`. Always present in responses; in a request it may stand in for the top-level `constraintType`.",
            "allOf": [
              {
                "$ref": "#/components/schemas/TableConstraintType"
              }
            ]
          },
          "fields": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "composite_unique — the constrained fields; check (response only) — fields the expression references"
          },
          "condition": {
            "type": [
              "string",
              "null"
            ],
            "description": "composite_unique / no_overlap / capacity — optional boolean formula-grammar expression selecting the rows the rule applies to (compiled server-side, never raw SQL). Rows where the condition is false or NULL are exempt: they neither collide, hold a slot, nor add load toward a capacity limit."
          },
          "conditionFields": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "composite_unique / no_overlap / capacity with a condition (response only) — fields the condition references"
          },
          "caseInsensitive": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "composite_unique only — compare ignoring case, so \"Acme\" and \"ACME\" collide. Folds the text-family fields (text, textarea, richtext, email, phone, url, picklist); any other listed field (a parent reference, a number) compares exactly, so (parent, name) keys work. At least one text-family field is required."
          },
          "expression": {
            "type": [
              "string",
              "null"
            ],
            "description": "check only — boolean formula-grammar expression over this table's fields"
          },
          "scope": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "no_overlap / capacity — equality scope field names (may be empty)"
          },
          "start": {
            "type": [
              "string",
              "null"
            ],
            "description": "no_overlap / capacity — the field holding the start of the range"
          },
          "end": {
            "type": [
              "string",
              "null"
            ],
            "description": "no_overlap / capacity — the field holding the end of the range"
          },
          "bounds": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "[)",
              "[]",
              null
            ],
            "x-enum-varnames": [
              "EndExclusive",
              "EndInclusive"
            ],
            "description": "no_overlap / capacity — whether the end date is exclusive (default) or inclusive"
          },
          "references": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "same_parent only — exactly two reference field names on this table"
          },
          "parentField": {
            "type": [
              "string",
              "null"
            ],
            "description": "same_parent only — the reference field on each referenced table that names the shared parent (on one of them when the other reference points straight at the parent table)"
          },
          "referenceTables": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "same_parent (response only) — the tables the two references point at, in order"
          },
          "parentTable": {
            "type": [
              "string",
              "null"
            ],
            "description": "same_parent (response only) — the table parentField points at on both"
          },
          "directReference": {
            "type": [
              "string",
              "null"
            ],
            "description": "same_parent (response only) — the one of `references` that points straight at `parentTable` and so is its own parent; absent when both references carry `parentField`. A client scoping a picker reads it: the other reference's options are the rows whose `parentField` holds this reference's value."
          },
          "capacity": {
            "type": [
              "number",
              "null"
            ],
            "description": "capacity only — the fixed limit: the most load (rows, or summed weight) that may overlap in time per resource. A number above 0. Set this or `capacityReference` with `capacityField`, never both."
          },
          "capacityReference": {
            "type": [
              "string",
              "null"
            ],
            "description": "capacity only — the name of a scope field that is a table reference; the limit is read from `capacityField` on the row it points at. A resource with no limit set is unconstrained."
          },
          "capacityField": {
            "type": [
              "string",
              "null"
            ],
            "description": "capacity only — the number field on the table `capacityReference` points at that holds each resource's limit"
          },
          "capacityTable": {
            "type": [
              "string",
              "null"
            ],
            "description": "capacity (response only) — the table `capacityReference` points at; derived by the server and ignored in requests"
          },
          "weight": {
            "type": [
              "string",
              "null"
            ],
            "description": "capacity only — optional number field on this table saying how much of the limit a row uses (a party size, a seat count). A row with no weight value counts as 1."
          },
          "referenceKey": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "composite_unique only — nominates this constraint as the table's REFERENCE KEY: the identity other tables' reference fields rely on to tell rows apart. A table's identity is either its unique label field or exactly one constraint marked here, never both; with a reference key nominated, the table's display label is free to be a non-unique base fact or a read-time computed column. A conditional unique (one with `condition`) cannot be a reference key — identity must hold for every row."
          }
        }
      },
      "DerivedFormulaConfig": {
        "type": "object",
        "description": "Same-row expression (Excel-familiar syntax), compiled read-time. Because it is evaluated as records are read, it may reference the table's lookups, rollups and other computed columns (they are inlined), not only stored columns — e.g. `actual_total = accommodation_cost + activity_cost + transport_cost` over three rollups, and `variance = budget - actual_total` over that. Such chains nest at most four computed formulas deep.",
        "required": [
          "expression",
          "resultType"
        ],
        "properties": {
          "expression": {
            "type": "string",
            "description": "e.g. \"=IF([Amount] > 0, 'pos', 'neg')\" or \"amount - cost\""
          },
          "resultType": {
            "description": "The type the expression's result is coerced to when records are read, which also decides how the computed value renders and filters: `integer`, `number`, `text`, `boolean`, `date`, `datetime` or `time`.",
            "type": "string",
            "enum": [
              "integer",
              "number",
              "text",
              "boolean",
              "date",
              "datetime",
              "time"
            ]
          }
        }
      },
      "FormulaValidationRequest": {
        "type": "object",
        "description": "A formula expression to type-check against a table's fields, without creating anything. Used for live validation while authoring.",
        "required": [
          "expression"
        ],
        "properties": {
          "expression": {
            "type": "string",
            "description": "The Excel-familiar formula expression to validate."
          },
          "resultType": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "integer",
              "number",
              "text",
              "boolean",
              "date",
              "datetime",
              "time",
              null
            ],
            "description": "Optional declared result type. When provided, the formula is also checked to produce it. When omitted, the natural result type is inferred and returned as `resultType`."
          },
          "target": {
            "type": "string",
            "enum": [
              "field",
              "derivedField"
            ],
            "default": "field",
            "description": "What the formula is being authored as, which decides what it may reference. `field` (default): a schema formula field, stored as a generated column — it may read the table's stored columns only. `derivedField`: a computed column (derived field), evaluated when records are read — it may also read the table's lookups, rollups and other computed columns, which are inlined into it."
          },
          "ownerScope": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "workspace",
              "group",
              "user",
              null
            ],
            "description": "For `target: derivedField`, the scope the computed column will be created with. Decides which other computed columns it may read (workspace-shared ones always; group/personal ones only with the same owner), so validation matches what creation will accept. Omitted: every computed column the caller can see is offered."
          },
          "ownerGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "With `ownerScope: group`, the owning group."
          }
        }
      },
      "FormulaValidationError": {
        "description": "One problem the formula validator found: a stable code, a message to show, and where possible a fix hint and the character offset of the fault. Item of `FormulaValidationResult.errors`.",
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable FormulaError code (e.g. FORMULA_TYPE_MISMATCH)."
          },
          "message": {
            "description": "Human-readable explanation of the problem, ready to show beside the formula.",
            "type": "string"
          },
          "suggestion": {
            "type": [
              "string",
              "null"
            ],
            "description": "A teaching hint on how to fix the formula, when available."
          },
          "position": {
            "type": [
              "integer",
              "null"
            ],
            "description": "0-based character offset of the problem, when known."
          }
        }
      },
      "FormulaValidationResult": {
        "description": "Response of `POST /tables/{tableId}/formula/validate`: whether a formula expression type-checks against the table's fields, with its result type and references when it does, or the error when it does not.",
        "type": "object",
        "required": [
          "valid"
        ],
        "properties": {
          "valid": {
            "description": "True when the expression parses and type-checks against the table's fields and the declared result type, if any. When false, `error` says why.",
            "type": "boolean"
          },
          "resultType": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "integer",
              "number",
              "text",
              "boolean",
              "date",
              "datetime",
              "time",
              null
            ],
            "description": "The formula's result type when valid — the inferred type, or the declared type when one was supplied and it checked out."
          },
          "referencedFields": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Sibling field names the formula references, when valid."
          },
          "error": {
            "description": "The first problem found, with its position in the expression and a hint, when `valid` is false. Null when valid.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/FormulaValidationError"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "LookupResultReference": {
        "type": "object",
        "required": [
          "sourceTableId",
          "sourceFieldId",
          "referencedEntityType"
        ],
        "readOnly": true,
        "description": "Where a reference-typed lookup's id comes from: the reference field it projects (on the table the lookup's `via` points at) and that field's own target, so a client can show the id as a link with its label. Labels resolve through that source field's reference-options operation, under the reader's own access to the referenced table. Present on a lookup's config only when `resultType` is `reference`; written by the server, ignored on writes. A computed column's lookup carries the same object in its `definition.resultReference`.",
        "properties": {
          "sourceTableId": {
            "type": "string",
            "description": "The table holding the projected reference field — pass it with `sourceFieldId` to that field's reference-options operation to resolve labels."
          },
          "sourceFieldId": {
            "type": "string",
            "description": "The id of the projected reference field."
          },
          "referencedEntityType": {
            "type": "string",
            "enum": [
              "table",
              "user",
              "group"
            ],
            "description": "What the projected id names — a record, a workspace member, or a group."
          },
          "referencedTableId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The table the projected id's record lives in, for linking to it; null when `referencedEntityType` is `user` or `group`."
          }
        }
      },
      "DerivedLookupConfig": {
        "type": "object",
        "description": "Projects a field across a forward reference on this table. The source may be a scalar field, a reference or a multipicklist, as for a lookup field.",
        "required": [
          "via",
          "sourceField"
        ],
        "properties": {
          "via": {
            "type": "string",
            "description": "A reference field on this table (entity 'table')"
          },
          "sourceField": {
            "type": "string",
            "description": "Field name on the referenced table to project — a stored field, or that table's own lookup or rollup field (a chain of at most 3 cross-row hops, counting this one)."
          }
        }
      },
      "RollupMatchPair": {
        "type": "object",
        "description": "One equality a match rollup correlates on: the source row's `source` field equals this row's `target` field. Rows whose `target` is empty match nothing.",
        "required": [
          "source",
          "target"
        ],
        "properties": {
          "source": {
            "type": "string",
            "description": "A stored field on the source table (a reference, text, number, date, datetime or boolean field)."
          },
          "target": {
            "type": "string",
            "description": "A field on this table of the same kind: a stored field, or one of this table's lookup fields — e.g. a week's `athlete`, looked up from its plan, matched against an activity's `athlete` reference. A lookup target counts toward the 3-hop chain limit."
          }
        }
      },
      "RollupRange": {
        "type": [
          "object",
          "null"
        ],
        "description": "A match rollup's window: a source row is aggregated only when its `sourceField` falls between this row's `start` and `end`, compared by `bounds`. Rows whose start or end is empty match nothing. The three fields are all dates, or all numbers (integer or number).",
        "required": [
          "sourceField",
          "start",
          "end"
        ],
        "properties": {
          "sourceField": {
            "type": "string",
            "description": "The source-table field whose value must fall in the window (e.g. an activity's date)."
          },
          "start": {
            "type": "string",
            "description": "The field on this table where the window starts (e.g. `week_start`)."
          },
          "end": {
            "type": "string",
            "description": "The field on this table where the window ends (e.g. `week_end`)."
          },
          "bounds": {
            "type": "string",
            "enum": [
              "[)",
              "[]",
              "(]",
              "()"
            ],
            "x-enum-varnames": [
              "StartInclusiveEndExclusive",
              "BothInclusive",
              "StartExclusiveEndInclusive",
              "BothExclusive"
            ],
            "description": "Which ends are included: `[` / `]` include that end, `(` / `)` exclude it. Default `[)` — start included, end excluded, so consecutive windows never share a row."
          }
        }
      },
      "DerivedRollupConfig": {
        "type": "object",
        "description": "Aggregates rows of a source table: those whose `via` reference points at this row, or for a match rollup those whose `match` fields equal this row's and whose value falls in its `range`. Give exactly one of `via`, or `match` and/or `range`.",
        "required": [
          "sourceTable",
          "aggregate"
        ],
        "properties": {
          "sourceTable": {
            "type": "string",
            "description": "The referencing (child) table's name"
          },
          "via": {
            "type": [
              "string",
              "null"
            ],
            "description": "Reference field on the source table pointing at this table; omit for a match rollup."
          },
          "match": {
            "type": [
              "array",
              "null"
            ],
            "maxItems": 3,
            "description": "A match rollup's equality pairs (at most 3); see the rollup field's `match`.",
            "items": {
              "$ref": "#/components/schemas/RollupMatchPair"
            }
          },
          "range": {
            "$ref": "#/components/schemas/RollupRange"
          },
          "aggregate": {
            "description": "How the matching child rows are combined: `count` the rows (needs no `sourceField`), `sum`, `min`, `max` or `avg` of `sourceField` across them, or `union` of a multipicklist `sourceField` (every option any of them selected, each once, sorted).",
            "type": "string",
            "enum": [
              "count",
              "sum",
              "min",
              "max",
              "avg",
              "union"
            ]
          },
          "sourceField": {
            "type": [
              "string",
              "null"
            ],
            "description": "Field on the source table to aggregate (omit for count): a stored field, a formula field, one of the source table's lookup or rollup fields, or one of its workspace-shared read-time computed columns, evaluated per source row inside the aggregate. The chain rules of a rollup field apply: at most 3 cross-row hops, no `avg` over a rollup, and grandchildren are counted by a `sum` of the children's `count` rollup."
          },
          "filter": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional boolean expression over the source table's fields"
          }
        }
      },
      "DerivedField": {
        "type": "object",
        "description": "A read-only computed column in the derived-views layer (separate from the table schema). Owned at workspace / group / user scope; virtual (read-time) by default.",
        "required": [
          "id",
          "tableId",
          "name",
          "displayName",
          "kind",
          "resultType",
          "ownerScope",
          "materialization",
          "displayOrder"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable identifier of the derived field; use it in the derived-field endpoints and as `DerivedField.id` references elsewhere in the spec."
          },
          "tableId": {
            "type": "string",
            "description": "The table whose records the computed column is evaluated on."
          },
          "name": {
            "type": "string",
            "description": "Column name (snake_case) under which the computed value appears in record `data`, queries and formulas. Unique among the table's fields and derived fields."
          },
          "displayName": {
            "type": "string",
            "description": "Human-readable label shown as the column header."
          },
          "kind": {
            "description": "How the value is derived: `formula` evaluates an expression over the record's own fields; `lookup` pulls a field from the record a reference points at; `rollup` aggregates records of another table that reference this one.",
            "type": "string",
            "enum": [
              "formula",
              "lookup",
              "rollup"
            ]
          },
          "resultType": {
            "type": "string",
            "description": "Read-time coercion type (formula/computed result type)"
          },
          "ownerScope": {
            "description": "Who sees the column: `workspace` for everyone, `group` for members of `ownerGroupId`, `user` for the owner alone (a personal column).",
            "type": "string",
            "enum": [
              "workspace",
              "group",
              "user"
            ]
          },
          "ownerUserId": {
            "description": "The owning user when `ownerScope` is `user`; null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "ownerGroupId": {
            "description": "The owning group when `ownerScope` is `group`; null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "materialization": {
            "description": "`virtual` is computed at read time and is what the server creates today; `stored` is reserved for persisted values.",
            "type": "string",
            "enum": [
              "virtual",
              "stored"
            ]
          },
          "labelField": {
            "type": "boolean",
            "default": false,
            "description": "True when this computed column is the table's display label (see TableField.labelField for what that means). Only a workspace-scoped, virtual `formula` with a text result can be one, so every reader sees the same label and nothing is stored."
          },
          "displayOrder": {
            "description": "Position among the table's derived fields; the list endpoint returns them in ascending order. Defaults to 0.",
            "type": "integer"
          },
          "createdBy": {
            "description": "User id of whoever created the derived field.",
            "type": "string"
          },
          "createdAt": {
            "description": "When the derived field was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "definition": {
            "type": "object",
            "description": "The resolved, sanitized derivation config. Shape depends on kind (formula {expression,resultType}; lookup {via,sourceField}; rollup {sourceTableId,via,aggregate,sourceField?,filter?}).",
            "additionalProperties": true
          }
        }
      },
      "DerivedFieldCreate": {
        "description": "Request body of `POST /tables/{tableId}/derived-fields`: define a read-only computed column beside the table. Supply the config object that matches `kind` (`formula`, `lookup` or `rollup`) and leave the other two out.",
        "type": "object",
        "required": [
          "name",
          "displayName",
          "kind"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Column name (sanitized to snake_case). Must not collide with a field or another derived field on the table."
          },
          "displayName": {
            "description": "Human-readable label shown as the column header, independent of the snake_case `name`.",
            "type": "string"
          },
          "kind": {
            "description": "What computes the column: `formula` evaluates an expression over the row's own fields, `lookup` copies a field from the record a reference field points at, `rollup` aggregates over related records. Decides which config object (`formula`, `lookup` or `rollup`) is read.",
            "type": "string",
            "enum": [
              "formula",
              "lookup",
              "rollup"
            ]
          },
          "ownerScope": {
            "type": "string",
            "enum": [
              "workspace",
              "group",
              "user"
            ],
            "default": "workspace",
            "description": "'user' (a personal view) is creatable with derivedViews:read; 'workspace'/'group' require derivedViews:manage."
          },
          "ownerGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Required when ownerScope=group; a group in this workspace the caller belongs to."
          },
          "displayOrder": {
            "description": "Sort position among the table's derived fields; lower comes first. Defaults to 0.",
            "type": "integer",
            "default": 0
          },
          "labelField": {
            "type": "boolean",
            "default": false,
            "description": "Make this computed column the table's display label, replacing any previous label (stored or computed). Requires kind `formula`, ownerScope `workspace` and resultType `text`. The label's source columns (the fields the expression reads, and the label fields of the tables its lookups reach) are what search and pickers match on — the label itself is computed on read and never indexed."
          },
          "formula": {
            "description": "Expression settings, read only when `kind` is `formula`; omit or null otherwise.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/DerivedFormulaConfig"
              },
              {
                "type": "null"
              }
            ]
          },
          "lookup": {
            "description": "Reference-field and source-field settings, read only when `kind` is `lookup`; omit or null otherwise.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/DerivedLookupConfig"
              },
              {
                "type": "null"
              }
            ]
          },
          "rollup": {
            "description": "Aggregation settings, read only when `kind` is `rollup`; omit or null otherwise.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/DerivedRollupConfig"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "SummaryCell": {
        "type": "object",
        "description": "One column's cell in a summary row. A quick-pick aggregate (kind=aggregate: fn over field; count needs no field) or an Excel-familiar aggregate expression (kind=expression: e.g. \"SUMIF([status] = 'open', [amount])\"). A formula, lookup or rollup field is aggregated by the type it evaluates to (a number formula or a sum rollup totals like a number field; a text formula cannot be summed), and a rollup whose source field the reader cannot see is left out of their totals.",
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "description": "`aggregate` — a quick-pick function (`fn`) over one `field`; `expression` — an Excel-style aggregate expression in `expr`.",
            "type": "string",
            "enum": [
              "aggregate",
              "expression"
            ]
          },
          "fn": {
            "description": "The aggregate for `kind: aggregate`: `sum`, `avg`, `min`, `max` over a field's values; `count` counts rows and needs no field; `empty` and `filled` count rows where the field is blank or set. Null for an expression cell.",
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "sum",
              "count",
              "avg",
              "min",
              "max",
              "empty",
              "filled",
              null
            ]
          },
          "field": {
            "description": "Name of the field aggregated by `fn`. Null for `count` and for an expression cell.",
            "type": [
              "string",
              "null"
            ]
          },
          "expr": {
            "description": "The aggregate expression for `kind: expression`, with fields in square brackets, e.g. `SUMIF([status] = 'open', [amount])`. Null for an aggregate cell.",
            "type": [
              "string",
              "null"
            ]
          },
          "resultType": {
            "description": "Scalar type an expression cell evaluates to, chosen by its author so the result is coerced and formatted correctly (an `integer` count, a `number` total, a `date`). Null or absent on an aggregate cell, whose type follows from `fn` and `field`.",
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "integer",
              "number",
              "text",
              "boolean",
              "date",
              "datetime",
              "time",
              null
            ]
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40,
            "description": "Caption shown beside the value in the totals row, so a reader can tell a sum from an average without opening the cell. Optional for an aggregate cell, which is captioned by its function (Sum, Average, Count…) when this is absent; an expression cell should carry one, because the expression itself is not a readable caption."
          }
        }
      },
      "TableSummary": {
        "type": "object",
        "description": "A pinned summary/totals row over a table (derived-views layer).",
        "required": [
          "id",
          "tableId",
          "label",
          "cells",
          "ownerScope",
          "displayOrder"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Identifier of the summary row, used in the `/summaries/{summaryId}` endpoints."
          },
          "tableId": {
            "type": "string",
            "description": "The table this totals row sits under. Fixed at creation."
          },
          "label": {
            "type": "string",
            "description": "Caption shown at the start of the totals row (\"Total\", \"Open pipeline\") so readers can tell several summaries apart."
          },
          "cells": {
            "description": "Which column shows what, keyed by field name: each value says how that column is aggregated. Columns with no entry are left blank in the row.",
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/SummaryCell"
            }
          },
          "ownerScope": {
            "description": "Who sees the row: `workspace` — everyone who can read the table; `group` — members of `ownerGroupId`; `user` — only `ownerUserId`. Creating a `workspace` or `group` summary requires `derivedViews:manage`; a `user` one does not. Immutable after creation.",
            "type": "string",
            "enum": [
              "workspace",
              "group",
              "user"
            ]
          },
          "ownerUserId": {
            "type": [
              "string",
              "null"
            ],
            "description": "User id of the owner for a `user`-scoped summary — the only person who sees it. Null for the other scopes."
          },
          "ownerGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Group id for a `group`-scoped summary — the group whose members see it. Null for the other scopes."
          },
          "displayOrder": {
            "type": "integer",
            "description": "Position among the table's visible summary rows, ascending; 0 when not given on creation. Ties keep insertion order."
          },
          "createdBy": {
            "type": "string",
            "description": "User id of the person who created the summary."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the summary was created, ISO-8601 UTC."
          }
        }
      },
      "TableSummaryCreate": {
        "description": "Request body of `POST /tables/{tableId}/summaries`: a new pinned totals row over a table — its caption, the aggregate per column, who it is shared with and where it sits among the table's summaries.",
        "type": "object",
        "required": [
          "label"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "Caption of the summary row, shown in its leading cell (for example `Open pipeline`)."
          },
          "cells": {
            "description": "Which aggregate to show under which column, keyed by the column's `fieldName`. Columns without an entry stay blank in this row.",
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/SummaryCell"
            }
          },
          "ownerScope": {
            "type": "string",
            "enum": [
              "workspace",
              "group",
              "user"
            ],
            "default": "workspace",
            "description": "'user' creatable with derivedViews:read; 'workspace'/'group' need derivedViews:manage."
          },
          "ownerGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Required when ownerScope=group; a group in this workspace the caller belongs to."
          },
          "displayOrder": {
            "description": "Position of this row among the table's summary rows, ascending; defaults to 0, ties keep insertion order.",
            "type": "integer",
            "default": 0
          }
        }
      },
      "TableSummaryUpdate": {
        "type": "object",
        "description": "Update a summary row's label and/or cells in place. ownerScope and its owner are immutable here (re-scope by deleting and recreating).",
        "required": [
          "label"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "New caption for the summary row. Required even when only `cells` or `displayOrder` change."
          },
          "cells": {
            "description": "The replacement set of cells, keyed by column `fieldName`; the previous cells are discarded. Omit to keep the current cells.",
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/SummaryCell"
            }
          },
          "displayOrder": {
            "description": "New position among the table's summary rows, ascending. Unchanged when omitted.",
            "type": "integer"
          }
        }
      },
      "SummaryValues": {
        "type": "object",
        "description": "Computed values for one summary row, keyed by field name.",
        "required": [
          "summaryId",
          "label",
          "values"
        ],
        "properties": {
          "summaryId": {
            "type": "string",
            "description": "Id of the `TableSummary` these values belong to."
          },
          "label": {
            "type": "string",
            "description": "The summary row's label, repeated so a client can render without a second lookup."
          },
          "values": {
            "description": "Field name → the aggregated value of that summary cell, computed over the records the caller can read with their field visibility applied.",
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "MetadataTable": {
        "description": "A metadata table declared on a host table: rows each about one field of one host record. Metadata describes fields that exist; it never stands in for a missing field.",
        "type": "object",
        "required": [
          "name",
          "label",
          "hostTableId",
          "tableId",
          "cardinality",
          "coverage",
          "coveredFields",
          "appendOnly",
          "summaryField",
          "fields",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The API name, unique on the host. The backing table is named `_meta_<host>_<name>`."
          },
          "label": {
            "type": "string",
            "description": "What the app shows for this metadata, e.g. \"Detections\"."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the metadata records, for people and AI clients reading the schema."
          },
          "hostTableId": {
            "type": "string",
            "description": "The table the metadata is about."
          },
          "tableId": {
            "type": "string",
            "description": "The backing table's id. Its fields are changed through the ordinary field endpoints; its rows are read and written through the host record's metadata, never directly."
          },
          "cardinality": {
            "type": "string",
            "enum": [
              "one"
            ],
            "description": "How many rows one record may have about one field. Only `one` exists today."
          },
          "coverage": {
            "type": "string",
            "enum": [
              "allowlist",
              "allStoredFields"
            ],
            "description": "Which host fields a row may be about: the fields in `coveredFields`, or every stored (non-computed) field of the host, including fields added later."
          },
          "coveredFields": {
            "type": "array",
            "description": "With `allowlist` coverage, the covered host fields; empty with `allStoredFields`. A field dropped from the allowlist stays listed, `outOfCoverage`, while rows about it remain.",
            "items": {
              "$ref": "#/components/schemas/MetadataCoveredField"
            }
          },
          "appendOnly": {
            "type": "boolean",
            "description": "True when a row cannot be changed once written (deleting needs its own grant)."
          },
          "summaryField": {
            "type": [
              "string",
              "null"
            ],
            "description": "The metadata field the app shows beside each covered field; null when the table has none."
          },
          "fields": {
            "type": "array",
            "description": "The backing table's fields, the system columns `_record` and `_field` first.",
            "items": {
              "$ref": "#/components/schemas/TableField"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the metadata table was declared."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the declaration last changed."
          }
        }
      },
      "MetadataCoveredField": {
        "description": "One host field a metadata table covers.",
        "type": "object",
        "required": [
          "fieldId",
          "fieldName",
          "outOfCoverage"
        ],
        "properties": {
          "fieldId": {
            "type": "string",
            "description": "The host field's id."
          },
          "fieldName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The host field's name; null when the field has been deleted (its metadata stays until it is purged)."
          },
          "outOfCoverage": {
            "type": "boolean",
            "description": "True when the field was dropped from the allowlist; its rows stay readable but no new ones are written."
          }
        }
      },
      "MetadataTableCreateRequest": {
        "description": "A metadata table to declare on the host in the path.",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "label",
          "covers",
          "fields"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 63,
            "description": "The API name, lowercase letters, digits and underscores, e.g. `detections`."
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "What the app shows, e.g. \"Detections\"."
          },
          "description": {
            "type": "string",
            "description": "What the metadata records."
          },
          "covers": {
            "description": "The host field names a row may be about, or the string `allStoredFields` for every stored (non-computed) field, including ones added later.",
            "oneOf": [
              {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              },
              {
                "type": "string",
                "enum": [
                  "allStoredFields"
                ]
              }
            ]
          },
          "appendOnly": {
            "type": "boolean",
            "description": "Defaults to true, which refuses any change to a row once written."
          },
          "summaryField": {
            "type": "string",
            "description": "The metadata field the app shows beside each covered field; defaults to the first."
          },
          "fields": {
            "type": "array",
            "minItems": 1,
            "description": "What each row records, as schema-plan field specs (`name`, `displayName`, `type`, `config`, …; any field type, `region` included). Deliberately untyped, as plan documents are, so a malformed field comes back as a teaching issue. Only simple types are allowed: text, textarea, integer, number, currency, percent, rating, boolean, date, datetime, time, duration, email, phone, url, picklist, multipicklist, region and geolocation.",
            "items": {}
          }
        }
      },
      "MetadataTableUpdateRequest": {
        "description": "The parts of a metadata table's declaration to change; omitted parts stay as they are.",
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "The new label."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "The new description; null clears it."
          },
          "appendOnly": {
            "type": "boolean",
            "description": "Whether rows are refused changes once written."
          },
          "summaryField": {
            "type": [
              "string",
              "null"
            ],
            "description": "The metadata field to show beside each covered field; null resets to the first."
          },
          "covers": {
            "description": "The new coverage: host field names, or `allStoredFields`. Fields dropped from an allowlist keep their rows, marked out of coverage.",
            "oneOf": [
              {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              },
              {
                "type": "string",
                "enum": [
                  "allStoredFields"
                ]
              }
            ]
          }
        }
      },
      "MetadataTableRefusal": {
        "description": "A metadata declaration the schema-plan validator refused, with its teaching issues.",
        "type": "object",
        "required": [
          "error",
          "code",
          "issues"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "A one-line summary."
          },
          "code": {
            "type": "string",
            "description": "Always `METADATA_DECLARATION_REFUSED`."
          },
          "issues": {
            "type": "array",
            "description": "What is wrong, each with where it is and how to fix it.",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          }
        }
      },
      "TableConstraint": {
        "description": "A constraint declared on one table: a rule the data must satisfy on every write, whoever or whatever writes. `constraintType` names the rule and `config` carries its parameters. Returned by the `/tables/{tableId}/constraints` endpoints.",
        "type": "object",
        "required": [
          "id",
          "tableId",
          "name",
          "constraintType",
          "config",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Server-assigned identifier of the constraint; 12 hex characters. What the update and delete endpoints take.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "tableId": {
            "description": "The table the constraint is declared on and enforced for; stable across renames.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "name": {
            "description": "Human-readable label for the constraint, shown wherever the table's constraints are listed.",
            "type": "string"
          },
          "constraintType": {
            "$ref": "#/components/schemas/TableConstraintType"
          },
          "config": {
            "$ref": "#/components/schemas/TableConstraintConfig"
          },
          "createdAt": {
            "description": "When the constraint was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the constraint's name or config last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateTableConstraintRequest": {
        "description": "Request body of `POST /tables/{tableId}/constraints`: a table-level constraint (composite-unique, no-overlap, check, same-parent or capacity) enforced by the database. Refused with 400 when existing rows already violate it (code `CONSTRAINT_EXISTING_DATA_VIOLATION`, with `details` keyed by the rule's field list and listing the rows). A composite unique with `referenceKey: true` becomes the table's one reference key: the constraint that held it before keeps its index and loses the nomination.",
        "type": "object",
        "required": [
          "config"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Optional constraint name (derived from the fields when omitted)"
          },
          "constraintType": {
            "description": "The kind of constraint. Optional when `config.type` names it; given beside a different `config.type`, the request is refused (400, code `CONSTRAINT_TYPE_MISMATCH`) naming both. One or the other is required (`CONSTRAINT_TYPE_REQUIRED`).",
            "allOf": [
              {
                "$ref": "#/components/schemas/TableConstraintType"
              }
            ]
          },
          "config": {
            "$ref": "#/components/schemas/TableConstraintConfig"
          }
        }
      },
      "UpdateTableConstraintRequest": {
        "type": "object",
        "description": "Full replacement of an existing constraint's definition. The physical constraint is dropped and re-added under the SAME constraint id inside one transaction, so an edit that existing data would violate leaves the old rule enforcing. Saving a composite unique with `referenceKey: true` makes it the table's one reference key, clearing the nomination from the constraint that held it.",
        "required": [
          "config"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Optional constraint name (derived from the fields when omitted)"
          },
          "constraintType": {
            "description": "The kind of constraint. Optional when `config.type` names it; given beside a different `config.type`, the request is refused (400, code `CONSTRAINT_TYPE_MISMATCH`) naming both. One or the other is required (`CONSTRAINT_TYPE_REQUIRED`).",
            "allOf": [
              {
                "$ref": "#/components/schemas/TableConstraintType"
              }
            ]
          },
          "config": {
            "$ref": "#/components/schemas/TableConstraintConfig"
          }
        }
      },
      "CapacityOccupancy": {
        "description": "How full each resource of a capacity constraint is over a window: per scope group, the load against the limit as maximal intervals of constant load. Returned by `GET /tables/{tableId}/constraints/{constraintId}/occupancy`. Counts only the rows the caller may read, so when `partial` is true a load is a lower bound.",
        "type": "object",
        "required": [
          "constraintId",
          "from",
          "to",
          "partial",
          "truncated",
          "groups"
        ],
        "properties": {
          "constraintId": {
            "description": "The capacity constraint read, as the request named it.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "from": {
            "description": "The start of the window, normalized to the constraint's range type: a `YYYY-MM-DD` day for a date range, an ISO 8601 UTC instant for a datetime range.",
            "type": "string"
          },
          "to": {
            "description": "The end of the window, exclusive, in the same form as `from`.",
            "type": "string"
          },
          "partial": {
            "description": "True when the caller's row scope on the constrained table is restricted, so rows they cannot read are left out and every load is \"at least\". Show it to the reader.",
            "type": "boolean"
          },
          "truncated": {
            "description": "True when more groups than the response's 100 had rows in the window; the groups returned are the fullest. Pass `resource` to read a particular one.",
            "type": "boolean"
          },
          "groups": {
            "description": "One entry per scope group with rows in the window, fullest (highest `peak`) first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CapacityOccupancyGroup"
            }
          }
        }
      },
      "CapacityOccupancyGroup": {
        "description": "One scope group of a capacity constraint (one resource, or one combination of scope values) and its load over the window.",
        "type": "object",
        "required": [
          "scope",
          "limit",
          "limitHidden",
          "peak",
          "segments"
        ],
        "properties": {
          "scope": {
            "description": "The group's value of each scope field, keyed by field name: for a reference, the id of the record it points at. Empty for a constraint with no scope.",
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ],
              "description": "The scope field's value, as text."
            }
          },
          "limit": {
            "description": "The group's limit: the constraint's fixed capacity, or the resource row's limit field. Null when the resource sets no limit (the group is unconstrained) or when `limitHidden` is true.",
            "type": [
              "number",
              "null"
            ]
          },
          "limitHidden": {
            "description": "True when the limit is withheld because the caller may not read it on the resource table (the resource row is outside their row scope there, or the limit field is hidden from them). Draw the load without a limit or colouring.",
            "type": "boolean"
          },
          "peak": {
            "description": "The highest load at any instant of the window, by the rule the constraint enforces.",
            "type": "number"
          },
          "segments": {
            "description": "The load over the window as maximal intervals of constant non-zero load, in time order. Instants with no load are absent.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CapacityOccupancySegment"
            }
          }
        }
      },
      "CapacityOccupancySegment": {
        "description": "An interval of the window over which a group's load is constant.",
        "type": "object",
        "required": [
          "start",
          "end",
          "load"
        ],
        "properties": {
          "start": {
            "description": "Where the interval starts (inclusive), in the same form as the window's `from`.",
            "type": "string"
          },
          "end": {
            "description": "Where the interval ends (exclusive), in the same form. For a date range, the day after the last day the load holds.",
            "type": "string"
          },
          "load": {
            "description": "The summed weight of the readable rows active throughout the interval.",
            "type": "number"
          }
        }
      },
      "AutomationRuleType": {
        "description": "Which cross-row derivation an automation rule performs. `materialize_range_children` keeps one target row per date in the source row's [start, end] span; `interval_lookup` keeps a target reference pointed at the source row whose interval covers the target's date. Sent in `CreateAutomationRuleRequest` and echoed on `AutomationRule`; the matching settings live in `AutomationRuleConfig`.",
        "type": "string",
        "enum": [
          "materialize_range_children",
          "interval_lookup"
        ]
      },
      "AutomationRuleConfig": {
        "type": "object",
        "description": "Type-specific rule configuration. Field references are sanitized\nfield names on the source/target tables.\n- materialize_range_children: one target row per date in the source\n  row's [start, end] span (`start`, `end`, `endInclusive`,\n  `childRefField`, `childDateField`).\n- interval_lookup: keep `targetRefField` pointed at the source row\n  whose [intervalStart, intervalEnd) range contains\n  `targetDateField`, matched on `scopePairs`. The range is two date\n  fields or two numeric fields (integer, number, currency) and the\n  matched value is of the same kind; `rankField` decides between\n  overlapping ranges.\n",
        "properties": {
          "start": {
            "description": "`materialize_range_children` only: name of the date field on the source (parent) table holding the first day of the span.",
            "type": [
              "string",
              "null"
            ]
          },
          "end": {
            "description": "`materialize_range_children` only: name of the date field on the source (parent) table holding the last day of the span.",
            "type": [
              "string",
              "null"
            ]
          },
          "endInclusive": {
            "description": "`materialize_range_children` only: whether the `end` date itself gets a child row (true) or the span stops the day before it (false).",
            "type": [
              "boolean",
              "null"
            ]
          },
          "childRefField": {
            "description": "`materialize_range_children` only: name of the reference field on the target (child) table that points back at the source record; together with `childDateField` it must be covered by a composite-unique constraint.",
            "type": [
              "string",
              "null"
            ]
          },
          "childDateField": {
            "description": "`materialize_range_children` only: name of the date field on the target (child) table that receives each generated date.",
            "type": [
              "string",
              "null"
            ]
          },
          "intervalStart": {
            "description": "`interval_lookup` only: name of the field on the source table where the matched interval begins (always inclusive) — a date, or a number (integer, number, currency: the low edge of a band) of the same kind as `intervalEnd`.",
            "type": [
              "string",
              "null"
            ]
          },
          "intervalEnd": {
            "description": "`interval_lookup` only: name of the field on the source table where the matched interval ends, of the same kind as `intervalStart`; whether the end value itself counts is set by `bounds`.",
            "type": [
              "string",
              "null"
            ]
          },
          "bounds": {
            "description": "`interval_lookup` only: how the interval's end is treated. `[)` excludes the `intervalEnd` value (a stay checking out on the 5th does not cover the 5th; a revenue band to 1,000,000 does not hold 1,000,000, the next band does); `[]` includes it.",
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "[)",
              "[]",
              null
            ],
            "x-enum-varnames": [
              "EndExclusive",
              "EndInclusive"
            ]
          },
          "scopePairs": {
            "description": "`interval_lookup` only: equality joins that narrow which source rows a target row may match, e.g. the day's trip must equal the stay's trip. All pairs must match.",
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object",
              "required": [
                "source",
                "target"
              ],
              "properties": {
                "source": {
                  "description": "Name of the field on the source table whose value must equal the target field's.",
                  "type": "string"
                },
                "target": {
                  "description": "Name of the field on the target table compared with `source`.",
                  "type": "string"
                }
              }
            }
          },
          "targetDateField": {
            "description": "`interval_lookup` only: name of the field on the target table whose value must fall inside the source row's interval — a date for a date range, a number (integer, number, currency) for a numeric range. The name is the one from the date-only days; it names the matched value whatever its kind.",
            "type": [
              "string",
              "null"
            ]
          },
          "targetRefField": {
            "description": "`interval_lookup` only: name of the reference field on the target table that the rule keeps pointed at the matching source row (cleared when nothing matches).",
            "type": [
              "string",
              "null"
            ]
          },
          "rankField": {
            "description": "`interval_lookup` only, optional: name of an integer or number field on the source table that decides between overlapping intervals — the lowest rank wins, rows without one last. Without it the interval that starts latest wins; the source row id settles what is left, so the answer never depends on scan order.",
            "type": [
              "string",
              "null"
            ]
          },
          "matchKind": {
            "description": "`interval_lookup` only, set by the server from the field types: `date` when the interval is two date fields, `number` when it is two numeric fields. Absent on a rule stored before numeric intervals existed, which is a date rule.",
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "date",
              "number",
              null
            ]
          }
        }
      },
      "AutomationRule": {
        "description": "An automation rule — a declarative cross-table derivation that keeps rows in the target table in step with rows in the source table (not a flow; it has no steps). Returned by `GET`/`POST /tables/{tableId}/automations`.",
        "type": "object",
        "required": [
          "id",
          "name",
          "sourceTableId",
          "targetTableId",
          "ruleType",
          "config",
          "isActive",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Server-assigned identifier of the rule; 12 hex characters. What the rule's own endpoints take.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "name": {
            "description": "Human-readable label for the rule. Derived from the configured fields when the creating request gave none.",
            "type": "string"
          },
          "sourceTableId": {
            "description": "The table whose records drive the derivation — the `tableId` the rule was created under. Stable across table renames.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "targetTableId": {
            "description": "The table the rule writes into: derived child rows for `materialize_range_children`, the maintained reference for `interval_lookup`.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "ruleType": {
            "$ref": "#/components/schemas/AutomationRuleType"
          },
          "config": {
            "$ref": "#/components/schemas/AutomationRuleConfig"
          },
          "isActive": {
            "description": "Whether the engine evaluates the rule. Only active rules run on source-row changes and reconciles; an inactive rule is kept but does nothing.",
            "type": "boolean"
          },
          "lastError": {
            "description": "Message of the most recent failure the engine recorded for this rule, truncated to 500 characters. Null when no failure has been recorded.",
            "type": [
              "string",
              "null"
            ]
          },
          "lastErrorAt": {
            "description": "When `lastError` was recorded, ISO-8601 UTC. Null whenever `lastError` is null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "description": "When the rule was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the rule's definition or status last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateAutomationRuleRequest": {
        "description": "Request body of `POST /tables/{tableId}/automations`: declare an automation rule whose source is the table in the path and whose target is `targetTableId`. The engine reconciles the rule once on creation.",
        "type": "object",
        "required": [
          "ruleType",
          "targetTableId",
          "config"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Optional rule name (derived from the fields when omitted)"
          },
          "ruleType": {
            "$ref": "#/components/schemas/AutomationRuleType"
          },
          "targetTableId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "The table the rule writes to (the path tableId is the source)"
          },
          "config": {
            "$ref": "#/components/schemas/AutomationRuleConfig"
          }
        }
      },
      "AutomationReconcileResult": {
        "description": "Response of `POST /tables/{tableId}/automations/{ruleId}/reconcile`: how far one bounded reconcile pass of an automation rule got. Call the endpoint again while `complete` is false.",
        "type": "object",
        "required": [
          "parentsProcessed",
          "complete"
        ],
        "properties": {
          "parentsProcessed": {
            "type": "integer",
            "description": "Source rows (materialize) or target rows (lookup) examined this pass"
          },
          "complete": {
            "type": "boolean",
            "description": "False when the pass hit its bound — call again to continue"
          }
        }
      },
      "CreateViewRequest": {
        "description": "Request body of `POST /views`: the name, display metadata and the single SELECT statement that defines a new data-level SQL view.",
        "type": "object",
        "required": [
          "name",
          "displayName",
          "sql"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "View name (sanitized like table names)"
          },
          "displayName": {
            "description": "Human-readable name shown in the tables surface, independent of the sanitized SQL `name` and freely changeable.",
            "type": "string"
          },
          "description": {
            "description": "Optional text explaining what the view shows; null or omitted for none. Shown alongside the view like a table's description.",
            "type": [
              "string",
              "null"
            ]
          },
          "sql": {
            "type": "string",
            "description": "A single SELECT over workspace tables (bare names only). Validated like /query SQL and by the database itself."
          }
        }
      },
      "UpdateViewRequest": {
        "description": "Partial update of a SQL view's display metadata or definition; only the fields present change. Request body of `PUT /views/{viewId}`.",
        "type": "object",
        "properties": {
          "displayName": {
            "description": "New human-readable name of the view; omit to keep the current one.",
            "type": "string"
          },
          "description": {
            "description": "New description of what the view shows; null clears it, omit to keep the current one.",
            "type": [
              "string",
              "null"
            ]
          },
          "sql": {
            "type": "string",
            "description": "New definition — the view's fields are re-derived from it"
          }
        }
      },
      "SqlView": {
        "description": "A data-level SQL view with its definition: what `GET /views` lists and `GET /views/{viewId}` returns. The view is also a `DataTable` of `kind: view` on the tables surface, where its derived columns are read; this is the shape to read (and diff, or copy) the SELECT behind them before replacing it with `PUT /views/{viewId}`.",
        "type": "object",
        "required": [
          "id",
          "name",
          "displayName",
          "description",
          "sql",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "The view's id: the `{viewId}` of its own endpoints and the `{tableId}` of the table endpoints that read its columns and rows."
          },
          "name": {
            "type": "string",
            "description": "The view's SQL name — the relation to select from in `POST /query`, and the `name` the tables surface reports for it. Fixed at creation."
          },
          "displayName": {
            "type": "string",
            "description": "The human-readable label shown in the tables surface; freely changeable."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the view shows, as its author described it; null when none was given."
          },
          "sql": {
            "type": "string",
            "description": "The single SELECT the view is backed by, as stored — the definition to read before replacing it. Its columns are the view's fields."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the view was created."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the view's definition or display metadata last changed."
          }
        }
      },
      "TableItem": {
        "description": "A record — one row of a table (still `item` on the wire). Returned by the record list and create endpoints and embedded in record events, detail views, child groups and the recycle bin.",
        "type": "object",
        "required": [
          "id",
          "tableId",
          "data",
          "createdBy",
          "updatedBy",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "12-character hex ID"
          },
          "tableId": {
            "description": "The table the record belongs to.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "data": {
            "description": "The record's field values keyed by field name; value shapes follow each field's type. Values of fields the caller may not read are stripped, and computed label columns are included.",
            "type": "object",
            "additionalProperties": {}
          },
          "stageEnteredAt": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/StageEnteredAt"
            },
            "description": "Present only when the list was requested with `?stageEnteredAt=true` and the table designates stage fields the caller can read. Keyed by the stage field's fieldName; a field whose current value is empty has no entry."
          },
          "createdBy": {
            "description": "Id of the user who created the record, or of the principal (token owner) a token or flow acted as.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$"
          },
          "ownedBy": {
            "type": [
              "string",
              "null"
            ],
            "description": "User who owns the record (drives record-level access scopes)"
          },
          "updatedBy": {
            "description": "Id of the user whose write last changed the record; equals `createdBy` until the first update.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$"
          },
          "createdAt": {
            "description": "When the record was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the record's data last changed, ISO-8601 UTC. A write that changed nothing does not move it (see `TableItemUpdateResponse.changed`).",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RecordOccurrence": {
        "description": "One occurrence of a record's series (`recurrence` field, #787), as the occurrences operation expands it: when it starts and ends, and the slot in the series it came from. A timed series' moments are UTC instants; an all-day series' are `YYYY-MM-DD` days.",
        "type": "object",
        "required": [
          "recordId",
          "start",
          "end",
          "scheduledStart",
          "scheduledAt",
          "allDay"
        ],
        "properties": {
          "recordId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "The record whose series this occurrence belongs to; its row is in the response's `records`."
          },
          "start": {
            "type": "string",
            "maxLength": 32,
            "description": "When the occurrence starts — an instant (`2026-10-20T08:00:00.000Z`) or a day (`2026-10-20`)."
          },
          "end": {
            "type": "string",
            "maxLength": 32,
            "description": "When it ends, exclusive, in the same form; equals `start` for an occurrence with no duration."
          },
          "scheduledStart": {
            "type": "string",
            "maxLength": 32,
            "description": "Where the series scheduled it, in `start`'s form; differs from `start` when an exception moved it."
          },
          "scheduledAt": {
            "type": "string",
            "maxLength": 19,
            "description": "The slot's identity — the scheduled wall-clock start in the value's own form — which is what an exception's `date` names to cancel or move this occurrence."
          },
          "allDay": {
            "type": "boolean",
            "description": "True for an all-day series, whose `start` and `end` are days rather than instants."
          }
        }
      },
      "RecordOccurrencesResponse": {
        "description": "The occurrences of a table's records over a window, with the records they belong to, as a calendar draws them.",
        "type": "object",
        "required": [
          "occurrences",
          "records",
          "truncated"
        ],
        "properties": {
          "occurrences": {
            "type": "array",
            "description": "Every occurrence overlapping the window, in start order, across the records expanded.",
            "items": {
              "$ref": "#/components/schemas/RecordOccurrence"
            }
          },
          "records": {
            "type": "array",
            "description": "Each record that has at least one occurrence in the list, once, through the caller's visible columns — so a client can title and colour what it draws without a second read.",
            "items": {
              "$ref": "#/components/schemas/TableItem"
            }
          },
          "truncated": {
            "type": "boolean",
            "description": "True when the window holds more than was returned: more records matched the filter than `limit` allowed, or the occurrences exceeded the response's cap. Narrow the window or the filter to see the rest."
          }
        }
      },
      "DeletedTableItem": {
        "description": "A record in the recycle bin (#84): the row as it stood, plus its bin state. `deletedBatch` groups rows one delete operation took together (the target and its cascade children); restore brings back the batch.",
        "allOf": [
          {
            "$ref": "#/components/schemas/TableItem"
          },
          {
            "type": "object",
            "required": [
              "deletedAt"
            ],
            "properties": {
              "deletedAt": {
                "description": "When the record was moved to the recycle bin, ISO-8601 UTC. Retention is counted from this instant.",
                "type": "string",
                "format": "date-time"
              },
              "deletedBy": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "User who moved the record to the bin"
              },
              "deletedBatch": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Opaque id shared by every row of one delete operation"
              }
            }
          }
        ]
      },
      "RestoreDeletedItemResponse": {
        "description": "Response of `POST /tables/{tableId}/deleted-items/{itemId}/restore`: the restored record and how many rows the restore brought back in total, including cascaded ones.",
        "type": "object",
        "required": [
          "item",
          "restored"
        ],
        "properties": {
          "item": {
            "$ref": "#/components/schemas/TableItem"
          },
          "restored": {
            "type": "integer",
            "description": "Total rows the restore brought back across all tables — the record itself plus its cascade batch."
          }
        }
      },
      "RestoreConflictError": {
        "description": "The 409 body of `POST /tables/{tableId}/deleted-items/{itemId}/restore` when a restored value would collide with a live record's unique value. Nothing was restored.",
        "type": "object",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable message naming the colliding rule/field"
          },
          "code": {
            "description": "Machine-readable code for client branching; always `RESTORE_CONFLICT`.",
            "type": "string",
            "enum": [
              "RESTORE_CONFLICT"
            ]
          }
        }
      },
      "RecordFilterMatch": {
        "type": "string",
        "description": "How a filter's parts combine: `all` conjoins them (AND), `any` disjoins them (OR). Defaults to `all`. Whichever is chosen, the whole filter is still AND-ed onto the caller's own row scope — `any` widens the filter, never the caller's visibility.",
        "enum": [
          "all",
          "any"
        ],
        "default": "all"
      },
      "RecordFilterOperator": {
        "type": "string",
        "description": "The comparison one condition applies. Which operators a field accepts is decided by that field's type, and an unsupported pairing is a 400 rather than a coercion:\n\n  * `eq` / `neq` — every filterable type.\n  * `gt` / `gte` / `lt` / `lte` — numeric (integer, number, currency,\n    percent, autonumber), date, datetime, time, and the `createdAt` /\n    `updatedAt` system columns. Never text, boolean, reference, or a\n    compound type.\n  * `contains` / `startsWith` — text-like fields (text, textarea,\n    richtext, email, phone, url, picklist) only, matched\n    case- and accent-insensitively (\"clerigos\" finds \"Clérigos\").\n    `contains` additionally applies to `multipicklist`, where it\n    means \"this option is selected\".\n  * `in` / `notIn` — text-like fields, and every reference kind,\n    with a `value` that is an ARRAY (1–50 entries): \"is any of\" /\n    \"is none of\", the one-condition spelling of\n    `stage = won OR stage = lost`. On `id`, on the `createdBy` /\n    `updatedBy` / `ownedBy` system columns and on a `reference`\n    field the entries are record (or user) ids — \"any of these\n    records\" in one condition, the batch read; on a\n    `polymorphicReference` each entry is the `{ tableId, recordId }`\n    pair `eq` takes, across any of the field's target tables; on a\n    `multiReference` `in` is \"linked to any of these\" (what\n    `containsAny` asks) and `notIn` \"linked to none of them\".\n    `notIn` keeps rows with no value, as `neq` does. `containsAny`\n    is the `multipicklist` counterpart — any of the listed options\n    is selected.\n\n`eq` / `neq` and the ordering operators additionally accept `valueField` in place of `value`, comparing the column against another column of the same row rather than against a literal.\n  * `isEmpty` / `isNotEmpty` — every filterable type. These take no\n    `value`; supplying one is a 400.\n  * `beforeNow` / `afterNow` — date and datetime fields (including a\n    `stageEntry` field and a formula landing a date/datetime) and the\n    `createdAt` / `updatedAt` system columns. These take no `value`.\n  * `withinNext` / `withinLast` / `olderThan` — the same fields, with a\n    `RelativeDateValue` (`{ \"quantity\": 7, \"unit\": \"days\" }`).\n    `withinNext` is the half-open window `(now, now + span]`,\n    `withinLast` is `[now - span, now]`, and `olderThan` is everything\n    strictly before `now - span`.\n\n**The relative operators are evaluated against the clock at READ time, on every read.** That is the whole point of them: a saved view of \"breached\" or \"raised in the last 7 days\" moves with time instead of freezing the boundary it was authored at, so the boundary is never baked into the stored view document.\nThey are anchored to an INSTANT (`now()`), never to a calendar day, which is what makes them timezone-free: \"within the next 2 hours\" means the same thing to every reader of a shared view, wherever they are.\n\n  * `inPeriod` — the same fields, with a `CalendarPeriodValue`\n    (`{ \"unit\": \"week\", \"offset\": -1 }` is \"last week\"). The one\n    CALENDAR-anchored operator: \"today\", \"this month\", \"next\n    quarter\", \"last year\". A calendar boundary cannot be placed\n    without a time zone, so it is placed in the WORKSPACE's\n    (`WorkspaceSettings.timezone`, UTC until set) — never the\n    reader's browser, so a shared view of \"due today\" selects the\n    same rows for every reader. Weeks start on Monday.\n  * `targetIs` / `targetIsNot` — `polymorphicReference` fields only;\n    the `value` is one of the field's target table ids, and the\n    condition is whether the record points into that table. `eq` /\n    `neq` on such a field take the whole `{ tableId, recordId }` value.\n  * `relation` — ROW RULES ONLY (`RowRule.filter`); a query filter or\n    a saved view refuses it. `field` names a reference or\n    multi-reference field to another table of the workspace and\n    `value` is one condition on that table (`field`, `op`, `value`,\n    in this same grammar minus `relation`): \"the job's account's\n    owner is the current user\" without copying the owner onto the\n    job. The related record need not be readable by the principal;\n    the hop is a fact about this record. A second hop, a hop to the\n    rule's own table, a hop that another table's rule hops back\n    across, and a hop through a field the grammar cannot compare\n    are refused when the rule is saved.",
        "enum": [
          "eq",
          "neq",
          "gt",
          "gte",
          "lt",
          "lte",
          "contains",
          "startsWith",
          "in",
          "notIn",
          "containsAny",
          "isEmpty",
          "isNotEmpty",
          "beforeNow",
          "afterNow",
          "withinNext",
          "withinLast",
          "olderThan",
          "inPeriod",
          "targetIs",
          "targetIsNot",
          "relation"
        ]
      },
      "CalendarPeriodValue": {
        "type": "object",
        "description": "A whole calendar period, relative to the one the read falls in — the `value` of the `inPeriod` operator. `offset` 0 is the current period (\"today\", \"this week\"), -1 the previous one (\"yesterday\", \"last month\"), 1 the next (\"tomorrow\", \"next quarter\"); larger offsets reach further (\"the month three months back\" is -3).\n\nBoundaries are placed in the workspace's time zone and the period is half-open: a `date` column matches days from the first of the period up to the first of the next; a datetime column matches instants from the period's local midnight up to the next period's. Weeks run Monday to Sunday; quarters are calendar quarters.",
        "required": [
          "unit",
          "offset"
        ],
        "properties": {
          "unit": {
            "description": "The calendar unit the period is measured in: `day`, `week` (Monday to Sunday), `month`, `quarter` (calendar quarter) or `year`.",
            "type": "string",
            "enum": [
              "day",
              "week",
              "month",
              "quarter",
              "year"
            ]
          },
          "offset": {
            "description": "How many units from the period the read falls in: 0 is the current period, negative values are past periods (-1 last month), positive values future ones (1 next quarter). Up to 120 either way.",
            "type": "integer",
            "minimum": -120,
            "maximum": 120
          }
        }
      },
      "CurrentUserValue": {
        "type": "object",
        "description": "The current-user token, `{\"kind\": \"currentUser\"}`: written in place of a user id, it stands for whoever is making the request, resolved server-side from the authenticated caller and never from anything the client sends. A record write accepts it as the value of a reference field to workspace users (create, replace, patch, bulk writes, approval requests, and a flow's record steps), storing the caller's id — the id `createdBy` records — so a client need not look up its own id to send it back; on any other field it is a 400 naming the field. A record filter accepts it with `eq` / `neq` on a user-holding column. Reads never return it: a stored user reference is always the id.",
        "required": [
          "kind"
        ],
        "additionalProperties": false,
        "properties": {
          "kind": {
            "description": "Always `currentUser`, the one token kind; any other value is not this token.",
            "type": "string",
            "enum": [
              "currentUser"
            ]
          }
        }
      },
      "CurrentGroupsValue": {
        "type": "object",
        "description": "The current-user's-groups token, `{\"kind\": \"currentGroups\"}`: written in place of a group id, it stands for every group the requesting principal belongs to, resolved server-side from their membership and never from anything the client sends. A record filter and a role's row rule accept it with `eq` (\"one of my groups\") or `neq` (\"none of my groups\") on a reference field to workspace groups, or on a multi-reference to groups with `contains`; on any other field it is a 400 naming the rule. A principal in no group matches nothing with `eq`, everything with `neq`. Reads never return it.",
        "required": [
          "kind"
        ],
        "additionalProperties": false,
        "properties": {
          "kind": {
            "description": "Always `currentGroups`; any other value is not this token.",
            "type": "string",
            "enum": [
              "currentGroups"
            ]
          }
        }
      },
      "RecordVerb": {
        "type": "string",
        "enum": [
          "read",
          "update",
          "delete"
        ],
        "description": "The record operation a row rule governs. `read` decides which records a principal can list, open, aggregate and receive over the event stream; `update` which they can patch; `delete` which they can move to the recycle bin. Creating a record is gated by the `records:create` action and the field grants' `canCreate` bit, not by a row rule."
      },
      "RowRule": {
        "type": "object",
        "description": "One row rule on a role: principals holding the role may apply `verb` to the records of `tableId` that match `filter`. Rules on the same role, table and verb are OR-ed, and so are the rules of every role a principal holds, so a rule only ever grants. The first rule saved on a table and verb GOVERNS it: the baseline member and reader roles then grant nothing there, and a principal whose roles carry no matching rule sees no record of that table for that verb. Baseline workspace admins bypass every rule. Record shares still widen access on a governed table.",
        "required": [
          "id",
          "roleId",
          "tableId",
          "verb",
          "filter",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the rule, used to replace or delete it.",
            "type": "string"
          },
          "roleId": {
            "description": "The role whose principals the rule grants rows to.",
            "type": "string"
          },
          "tableId": {
            "description": "The table whose records the rule selects.",
            "type": "string"
          },
          "verb": {
            "$ref": "#/components/schemas/RecordVerb"
          },
          "filter": {
            "$ref": "#/components/schemas/RecordFilter"
          },
          "createdAt": {
            "description": "When the rule was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the rule's filter last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateRowRuleRequest": {
        "type": "object",
        "description": "A new row rule for the role: the table, the verb and the filter its records must match. The filter is the `RecordFilter` grammar with `{\"kind\": \"currentUser\"}` and `{\"kind\": \"currentGroups\"}` as values, checked against the table's fields when saved: a field the grammar cannot compare, or an operator the field does not take, is a 400 naming the path. Saving a rule requires unrestricted read access to the table (a baseline admin, or a principal no rule restricts there): a rule grants rows, and nobody may grant rows they cannot see.",
        "required": [
          "tableId",
          "verb",
          "filter"
        ],
        "properties": {
          "tableId": {
            "description": "The table the rule selects records of.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12
          },
          "verb": {
            "$ref": "#/components/schemas/RecordVerb"
          },
          "filter": {
            "$ref": "#/components/schemas/RecordFilter"
          }
        }
      },
      "UpdateRowRuleRequest": {
        "type": "object",
        "description": "Replaces a rule's filter. The table and verb of a rule never change; delete the rule and create another to move it.",
        "required": [
          "filter"
        ],
        "properties": {
          "filter": {
            "$ref": "#/components/schemas/RecordFilter"
          }
        }
      },
      "PermissionExplainRequest": {
        "type": "object",
        "description": "The question `POST /permissions/explain` answers: may this principal apply this verb to this record, and why. Exactly one of `userId`, `apiTokenId` and `automationId` names the principal.",
        "required": [
          "tableId",
          "verb",
          "recordId"
        ],
        "properties": {
          "userId": {
            "description": "A workspace member, by user id.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12
          },
          "apiTokenId": {
            "description": "An API token of this workspace, by token id; it answers as its owner, capped at the token's own grants.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12
          },
          "automationId": {
            "description": "A flow, by id, as its automation identity (only the roles attached to it).",
            "type": "string",
            "minLength": 12,
            "maxLength": 12
          },
          "tableId": {
            "description": "The table the record belongs to.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12
          },
          "verb": {
            "$ref": "#/components/schemas/RecordVerb"
          },
          "recordId": {
            "description": "The record to explain. The CALLER must be able to read it: a record outside the caller's own read access is a 404, so the endpoint never confirms a hidden id.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12
          },
          "write": {
            "description": "Optionally, the body of a patch (for `update`) the principal would send; the answer then lists the fields of it the principal may not change.",
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "PermissionExplanation": {
        "type": "object",
        "description": "Why a principal may or may not apply a verb to a record, computed from the same permission snapshot enforcement uses, at the workspace's current permissions version. `allowed` is the decision; `reason` is the one thing that decided it; `matchedRules` are every row rule of the principal's roles that the record satisfies, by the rule's id (a legacy scope grant folded in as a rule carries an id of the form `legacy:<scope>`).",
        "required": [
          "principal",
          "tableId",
          "verb",
          "recordId",
          "governed",
          "allowed",
          "reason",
          "matchedRules",
          "sharedAccess",
          "restrictedFields",
          "deniedFields"
        ],
        "properties": {
          "principal": {
            "type": "object",
            "description": "The principal the answer is about.",
            "required": [
              "kind",
              "id"
            ],
            "properties": {
              "kind": {
                "description": "Which kind of principal `id` names.",
                "type": "string",
                "enum": [
                  "member",
                  "apiToken",
                  "flow"
                ]
              },
              "id": {
                "description": "The member's user id, the token id or the flow id.",
                "type": "string"
              }
            }
          },
          "tableId": {
            "description": "The table, echoed from the request.",
            "type": "string"
          },
          "verb": {
            "$ref": "#/components/schemas/RecordVerb"
          },
          "recordId": {
            "description": "The record, echoed from the request.",
            "type": "string"
          },
          "governed": {
            "description": "Whether this verb on this table is governed for the principal: decided by row rules (and shares), with the baseline roles granting nothing. False on an open table and for a baseline admin.",
            "type": "boolean"
          },
          "allowed": {
            "description": "Whether the principal may apply the verb to the record.",
            "type": "boolean"
          },
          "reason": {
            "description": "What decided it. `unrestricted`: the principal reads every row of the table (a baseline admin, an open table, or a `workspace` scope). `rule`: a row rule matched. `scope`: a legacy ownership or group scope on a private table matched. `share`: a record share grants it. `none`: nothing grants it.",
            "type": "string",
            "enum": [
              "unrestricted",
              "rule",
              "scope",
              "share",
              "none"
            ]
          },
          "matchedRules": {
            "description": "The row rules of the principal's roles that this record satisfies for this verb.",
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "ruleId",
                "roleId"
              ],
              "properties": {
                "ruleId": {
                  "description": "The rule's id, or `legacy:<scope>` for a scope grant folded in as a rule.",
                  "type": "string"
                },
                "roleId": {
                  "description": "The role the rule belongs to; empty for a folded-in scope grant.",
                  "type": "string"
                }
              }
            }
          },
          "sharedAccess": {
            "description": "The access level a record share grants the principal on this record, or null when none does.",
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "view",
              "edit",
              null
            ]
          },
          "restrictedFields": {
            "type": "object",
            "description": "The fields of this table the principal may not read, change or set on insert.",
            "required": [
              "read",
              "update",
              "create"
            ],
            "properties": {
              "read": {
                "description": "Fields whose values are withheld from the principal.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "update": {
                "description": "Fields the principal may not change on an existing record.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "create": {
                "description": "Fields the principal may not set when creating a record.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "deniedFields": {
            "description": "When `write` was given: the fields of it the principal may not write for this verb (empty when none, or when no `write` was given).",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "RelativeDateValue": {
        "type": "object",
        "description": "A span measured from the moment of the read — the `value` of the `withinNext` / `withinLast` / `olderThan` operators.\n\nA unit-bearing quantity rather than a count of seconds, because the quantity is the AUTHOR'S INTENT: a saved view should still read \"7 days\" when someone opens it a year later, not 604800. It also lets `months` mean calendar months, which no fixed number of seconds can.\n\nUnlike a stored formula, a filter is compiled per request, so the STABLE arithmetic these imply (`now()`, and calendar-aware interval addition) is perfectly legal here. The IMMUTABLE-only rule binds generated columns, not the filter compiler — which is exactly why \"breached\" works as a filter and could never have worked as a stored value.",
        "required": [
          "quantity",
          "unit"
        ],
        "properties": {
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10000,
            "description": "How many `unit`s. Must be positive — which side of now the span falls on is the operator's job, not the value's."
          },
          "unit": {
            "description": "The unit `quantity` is counted in. `months` means calendar months (added date-wise, not as a fixed number of seconds); the others are fixed spans.",
            "type": "string",
            "enum": [
              "minutes",
              "hours",
              "days",
              "weeks",
              "months"
            ]
          }
        }
      },
      "RecordFilterCondition": {
        "type": "object",
        "description": "One `field op value` test. `field` must name a column the CALLER can read: a field on the table that is visible to them, or one of the system columns `id`, `createdAt`, `updatedAt`, `createdBy`, `updatedBy`, `ownedBy` (all of which every reader already receives on every item). A name that does not exist, or that exists but is masked from the caller by a field permission, is rejected identically — a filter can never be used to probe a value the caller cannot see.",
        "required": [
          "field",
          "op"
        ],
        "properties": {
          "field": {
            "type": "string",
            "maxLength": 255,
            "description": "Field name on the table, or a system column — or a stage clock, A lookup or rollup, by its own field name, when this caller could read its source unrestricted (the field list says so with `filterable`): `status.activeSeconds gt valueField:response_target` then compares a record's clock against the target looked up from its hardware type, nothing copied onto the record. A lookup whose source this caller can only partly see is refused exactly as an unknown name.\n`<stageField>.enteredAt`: when the record entered its CURRENT value of a designated stage field, derived from the transition log at read time (a datetime; nothing is stored, and it exists for every stage field the caller can read, with no declaration). With the relative operators, `status.enteredAt olderThan 4 hours` is \"in this stage for more than four hours\". It is exact or absent: a value written outside the stage machine has no clock (`isEmpty`), and the item payload's `stageEnteredAt` reports the same instant as `approximate`. Hidden with its stage field, and refused exactly as an unknown name is.\n`<stageField>.activeSeconds`: whole seconds the record has spent in values whose clock runs (every visit summed; `clock: paused` options and terminal values left out), derived from the same log. An integer, so it compares against a `duration` field of the row through `valueField`: `status.activeSeconds gt valueField:response_target` is \"over its own target, not counting time waiting on parts\". Same masking, same refusal."
          },
          "op": {
            "$ref": "#/components/schemas/RecordFilterOperator"
          },
          "valueField": {
            "type": "string",
            "maxLength": 255,
            "description": "Compare against ANOTHER COLUMN of the same row instead of a literal — `actual_cost > budget`, `arrival < departure`, `shipped != ordered`. Exactly one of `value` / `valueField` may be given; both, or neither, is a 400.\n\n**`valueField` resolves through the same catalogue as `field`, and is subject to the identical visibility rule.** A field that is masked from the caller is refused exactly as an unknown one is — otherwise a comparison against an invisible column would leak its value one bit at a time, which is the whole thing `filterable == readable` exists to prevent.\n\nBoth sides must compare in the same domain; a mismatch is a 400 naming both fields, never a coercion. Accepted with `eq` / `neq` and the ordering operators. NOT accepted with `contains` / `startsWith` (a substring match against another column is a different feature), with the nullary operators, or with the relative-date operators."
          },
          "value": {
            "description": "The comparison value, deliberately untyped here because its type follows the FIELD's type — string for text/picklist/reference, number for numeric fields, boolean for booleans, an ISO-8601 string for date (`YYYY-MM-DD`), datetime, and time (`HH:MM[:SS]`). A mismatch is a 400 naming the field and the type expected; values are never coerced. Omitted for `isEmpty` / `isNotEmpty`, and required for every other operator.\n\nOne value object is accepted: `{\"kind\": \"currentUser\"}`, legal only with `eq`/`neq` on a user-holding reference column (a user-entity reference field, or `createdBy`/`updatedBy`/ `ownedBy`). It resolves server-side to the AUTHENTICATED caller's user id, which is what lets one shared saved view (\"assignee = me\") mean each reader rather than its author. A client-supplied id is never trusted as \"me\". A second token, `{\"kind\": \"currentGroups\"}` (`CurrentGroupsValue`), is legal with `eq`/`neq` on a reference field to workspace groups, or with `contains` on a multi-reference to groups, and resolves to the caller's own group membership. Any other object value is a 400 naming the known tokens. Flow condition values (including a `find_records` block's filter) are scalars and do not accept either token.\n\nThe `withinNext` / `withinLast` / `olderThan` operators take a `RelativeDateValue` (`{ \"quantity\": 7, \"unit\": \"days\" }`), and `inPeriod` a `CalendarPeriodValue` (`{ \"unit\": \"month\", \"offset\": 0 }`) — the two other object values. `beforeNow` / `afterNow` take no value at all, like `isEmpty`.\n\n`in` / `notIn` / `containsAny` take an ARRAY of strings (1–50 entries, each at most 1000 characters); any other array is a 400."
          }
        }
      },
      "RecordFilterGroup": {
        "type": "object",
        "description": "A parenthesised set of terms with its own `match`, so a filter can express nesting — `a AND (b OR c)`, or `(a AND b) OR (c AND d)`. A group may itself hold `groups`, one level further: `a AND (b OR (c AND d))`. That is where the grammar stops — a group inside a group may not hold groups of its own — so the document is bounded rather than a general expression language. A group must contain at least one term, in `conditions` or in a nested group.",
        "properties": {
          "match": {
            "$ref": "#/components/schemas/RecordFilterMatch"
          },
          "conditions": {
            "description": "The group's own terms, at most 25, combined under its `match`. May be empty only when `groups` supplies at least one term.",
            "type": "array",
            "maxItems": 25,
            "items": {
              "$ref": "#/components/schemas/RecordFilterCondition"
            }
          },
          "groups": {
            "type": "array",
            "maxItems": 5,
            "description": "Groups nested inside this one, combined with its `conditions` under its `match`. Accepted on a top-level group only; a nested group carrying `groups` is a 400.",
            "items": {
              "$ref": "#/components/schemas/RecordFilterGroup"
            }
          }
        }
      },
      "RecordFilter": {
        "type": "object",
        "description": "The filter document accepted by `GET /tables/{tableId}/items`, passed JSON-encoded in the `filter` query parameter. Its top-level `conditions` and `groups` are combined with `match` (a group contributes as one parenthesised term). At least one condition must be present, in `conditions` or inside a group, and at most 50 in the document as a whole, nested groups included.\n\nThe compiled result is always AND-ed onto the caller's compiled row scope, so a filter can only ever narrow what they could already read.\n\nBecause the document travels as a JSON-encoded string, the bounds stated on this schema are enforced by the server's own parser rather than by request-schema validation; a document that breaks one comes back as a 400 naming the offending path.",
        "properties": {
          "match": {
            "$ref": "#/components/schemas/RecordFilterMatch"
          },
          "conditions": {
            "description": "Top-level leaf conditions, each comparing one field to a value, combined with `match`; up to 25 here. They count toward the document-wide total of 50.",
            "type": "array",
            "maxItems": 25,
            "items": {
              "$ref": "#/components/schemas/RecordFilterCondition"
            }
          },
          "groups": {
            "description": "Nested sub-filters, each contributing one parenthesised term to `match` and combining its own conditions with its own `match`; up to 5. Their conditions count toward the document-wide total of 50.",
            "type": "array",
            "maxItems": 5,
            "items": {
              "$ref": "#/components/schemas/RecordFilterGroup"
            }
          }
        }
      },
      "ChildRecordGroup": {
        "type": "object",
        "description": "A group of child records that point at a parent item through one field of the child table: a `reference` or `polymorphicReference` whose value is the parent, or a `multiReference` whose set contains it (the records linked to this one).",
        "required": [
          "fieldId",
          "fieldName",
          "fieldDisplayName",
          "fromTableId",
          "fromTableName",
          "fromTableDisplayName",
          "items"
        ],
        "properties": {
          "fieldId": {
            "description": "Stable identifier of the reference field on the child table that points at this record.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "fieldName": {
            "description": "That reference field's `fieldName`, the key it has in the child records' `data`.",
            "type": "string"
          },
          "fieldDisplayName": {
            "description": "The reference field's human-readable label, for the group heading.",
            "type": "string"
          },
          "fromTableId": {
            "description": "Stable identifier of the child table (the table that holds the reference field).",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "fromTableName": {
            "description": "The child table's internal name, as used in query and API paths.",
            "type": "string"
          },
          "fromTableDisplayName": {
            "description": "The child table's human-readable label, for the group heading.",
            "type": "string"
          },
          "items": {
            "description": "The child records that reference this record through the field, masked to what the caller may see and ordered newest-updated first, at most `childLimit` of them. Empty when no readable record points at this one.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TableItem"
            }
          },
          "nextCursor": {
            "description": "Present when more readable records point at this one than `items` holds: an opaque cursor naming the last row carried. Pass it as `childCursor`, with `include=children`, to read this relation's next rows; absent when `items` is the whole relation.",
            "type": "string",
            "maxLength": 512
          }
        }
      },
      "TableItemUpdateResponse": {
        "description": "The item after a PUT/PATCH. `changed` is false when every field the write named already held the requested value: the row was not written, `updatedAt` did not move, no `ItemUpdated` event or history entry was produced, and no automation ran. The response is still 200 — the record is in the requested state — so clients that only need the item can ignore the flag; clients that report on their own writes (agents, integrations) should not describe such a call as a change.",
        "allOf": [
          {
            "$ref": "#/components/schemas/TableItem"
          },
          {
            "type": "object",
            "required": [
              "changed"
            ],
            "properties": {
              "changed": {
                "description": "True when the write altered at least one field; false when every named field already held the requested value, so no row write, event, history entry or automation occurred.",
                "type": "boolean"
              }
            }
          }
        ]
      },
      "TableItemDetail": {
        "description": "A table item as the single-record read returns it: the record, its child records when the read asked for them with `include=children`, and its metadata when it asked with `metadata=*` or `metadata=<name>`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/TableItem"
          },
          {
            "type": "object",
            "properties": {
              "childRecords": {
                "description": "Present only when the read asked for it with `include=children`. Records of other tables that point at this one through a reference field, grouped by that referencing field and table. One group per reference field that targets this record's table, present even when no record currently points at this one (its `items` is then empty), so a client can offer to add the first — or, with `childCursor`, the one group the cursor continues. Only records the caller may read are included, newest-updated first, each group capped at `childLimit` rows with `nextCursor` naming the rest. Empty only when no table references this one.",
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ChildRecordGroup"
                }
              },
              "metadata": {
                "description": "Present only when the read asked for it with `metadata=*` (every metadata table of this record's table) or `metadata=<name>,…` (those). Keyed by the metadata table's name; each value holds this record's rows of that metadata table, keyed by host field name. A field the caller cannot read is absent, as is a field with no row. A metadata table the read asked for is present, empty when nothing is recorded.",
                "type": "object",
                "additionalProperties": {
                  "$ref": "#/components/schemas/RecordMetadata"
                }
              }
            }
          }
        ]
      },
      "RoleMetadataGrant": {
        "description": "A role's grant to write one metadata table's rows (metadata tables). A bit the role does not hold is false.",
        "type": "object",
        "required": [
          "roleId",
          "metadataTableId",
          "hostTableId",
          "name",
          "canCreate",
          "canUpdate",
          "canDelete"
        ],
        "properties": {
          "roleId": {
            "description": "The role the grant is on.",
            "type": "string"
          },
          "metadataTableId": {
            "description": "The metadata table's backing table id.",
            "type": "string"
          },
          "hostTableId": {
            "description": "The table the metadata table describes.",
            "type": "string"
          },
          "name": {
            "description": "The metadata table's name on its host.",
            "type": "string"
          },
          "canCreate": {
            "description": "Principals with this role may write a row about a field that has none yet.",
            "type": "boolean"
          },
          "canUpdate": {
            "description": "Principals with this role may change an existing row (never on an append-only table).",
            "type": "boolean"
          },
          "canDelete": {
            "description": "Principals with this role may delete a row.",
            "type": "boolean"
          }
        }
      },
      "RoleMetadataGrantRequest": {
        "description": "Request body of `PUT /roles/{roleId}/metadata-tables/{metadataTableId}`; a bit left out is false.",
        "type": "object",
        "properties": {
          "canCreate": {
            "description": "Let the role write a row about a field that has none yet.",
            "type": "boolean"
          },
          "canUpdate": {
            "description": "Let the role change an existing row.",
            "type": "boolean"
          },
          "canDelete": {
            "description": "Let the role delete a row.",
            "type": "boolean"
          }
        }
      },
      "MetadataRowWriteRequest": {
        "description": "Request body of `PUT /tables/{tableId}/items/{itemId}/metadata/{metadataName}/{fieldName}`: the row's values. The record and the field come from the path.",
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "description": "The row's values, keyed by the metadata table's field names. On a replace, a field left out keeps its value.",
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "RecordMetadataChange": {
        "description": "On a `MetadataChanged` history entry: which metadata table one request wrote, and how many rows it created, updated and deleted about each field of the record. Only fields the reader can read appear; an entry whose fields are all hidden is not shown at all.",
        "type": "object",
        "required": [
          "metadataTable",
          "label",
          "byField"
        ],
        "properties": {
          "metadataTable": {
            "description": "The metadata table's name on this record's table.",
            "type": "string"
          },
          "label": {
            "description": "What the app calls the metadata table, e.g. \"Detections\".",
            "type": "string"
          },
          "byField": {
            "description": "Per field name, the rows the request wrote about it.",
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/RecordMetadataFieldCounts"
            }
          }
        }
      },
      "RecordMetadataFieldCounts": {
        "description": "The metadata rows one request wrote about one field.",
        "type": "object",
        "required": [
          "created",
          "updated",
          "deleted"
        ],
        "properties": {
          "created": {
            "description": "Rows created.",
            "type": "integer"
          },
          "updated": {
            "description": "Rows whose values were replaced.",
            "type": "integer"
          },
          "deleted": {
            "description": "Rows deleted.",
            "type": "integer"
          }
        }
      },
      "RecordMetadata": {
        "description": "One record's rows of one metadata table, keyed by the host field each row describes. A metadata table holds at most one row per record and field. Only fields the caller can read appear.",
        "type": "object",
        "additionalProperties": {
          "$ref": "#/components/schemas/MetadataRow"
        }
      },
      "MetadataRow": {
        "description": "One metadata row: facts about one field of one record, such as where a scanner found the value on a page and how sure it was. Its values are the metadata table's own fields.",
        "type": "object",
        "required": [
          "id",
          "field",
          "data",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "The metadata row's id.",
            "type": "string"
          },
          "field": {
            "description": "The name of the host field this row describes.",
            "type": "string"
          },
          "data": {
            "description": "The row's values, keyed by the metadata table's field names, as a record's `data` is. The system columns `_record` and `_field` are not repeated here: the record is the one read, and the field is `field`.",
            "type": "object",
            "additionalProperties": true
          },
          "createdAt": {
            "description": "When the row was first written.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the row was last written.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateDataTableRequest": {
        "description": "Request body of `POST /tables`: the new table's names, description and table-level switches. Fields are added afterwards through `POST /tables/{tableId}/fields` or a schema plan.",
        "type": "object",
        "required": [
          "name",
          "displayName"
        ],
        "properties": {
          "name": {
            "description": "Stable internal name of the table, used in API paths, queries and formulas interchangeably with its id. Must be unique in the workspace, may not start with `sys_`, `_` or `pg_` (the system and catalog prefixes), and may not look like a 12-hex-digit id.",
            "type": "string"
          },
          "displayName": {
            "description": "Human-readable name shown in the UI. Can be changed later without affecting `name`.",
            "type": "string"
          },
          "description": {
            "description": "Free-text description of what the table holds, shown to people browsing the schema.",
            "type": "string"
          },
          "aiHint": {
            "type": "string",
            "description": "Hint for AI agents about this table's purpose and relationships"
          },
          "defaultRecordVisibility": {
            "$ref": "#/components/schemas/RecordVisibility"
          },
          "commentsEnabled": {
            "description": "Whether records in this table carry a discussion thread. Omit for the default (off); the comments endpoints 404 while it is false.",
            "type": "boolean"
          },
          "isSearchable": {
            "type": "boolean",
            "description": "Omit to keep the default (searchable)."
          },
          "baseType": {
            "$ref": "#/components/schemas/KnownSystemTableKey"
          }
        }
      },
      "UpdateDataTableRequest": {
        "description": "Request body of `PUT /tables/{tableId}`: the table settings to change; properties left out keep their current value.",
        "type": "object",
        "properties": {
          "displayName": {
            "description": "New human-readable name of the table. The internal table name does not change.",
            "type": "string"
          },
          "description": {
            "description": "Human-readable description of what the table holds, shown to users.",
            "type": "string"
          },
          "aiHint": {
            "type": "string",
            "description": "Hint for AI agents about this table's purpose and relationships"
          },
          "defaultRecordVisibility": {
            "$ref": "#/components/schemas/RecordVisibility"
          },
          "rowScopeField": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 63,
            "description": "Make this table's records follow a parent's row scope: the name of one of its own fields, a single reference to another table. Null clears it. Needs `permissions:manage`. Refused with 400 `ROW_SCOPE_INVALID` when the field is not such a reference, when the chain of inherited scopes would pass through more than four tables, or when it would lead back to this table."
          },
          "commentsEnabled": {
            "description": "Whether records in this table carry a discussion thread; with it off the comments sub-resource answers 404.",
            "type": "boolean"
          },
          "isSearchable": {
            "type": "boolean",
            "description": "Toggling this rebuilds (or drops) the table's search index out of band; the response returns as soon as the metadata is written."
          }
        }
      },
      "CreateTableFieldRequest": {
        "description": "Request body of `POST /tables/{tableId}/fields` and of `PUT /tables/{tableId}/fields/{fieldId}`: the full definition of a field on a table — its names, type, constraints, per-type configuration and, for reference fields, what it points at. On PUT the body replaces the field's definition; omitted optional keys take their defaults, except `displayOrder`, which is left alone when omitted.",
        "type": "object",
        "required": [
          "fieldName",
          "displayName",
          "fieldType"
        ],
        "properties": {
          "fieldName": {
            "description": "Column name the field is stored under and the key its value uses in record data and queries. Sanitised to snake_case on save (lower-cased, non-alphanumerics become underscores, a leading digit gets a `t_` prefix), so the stored name may differ from what was sent; stable afterwards even if `displayName` changes.",
            "type": "string"
          },
          "displayName": {
            "description": "Human-readable label shown for the field in grids, forms and pickers. Free text; renaming it does not touch `fieldName` or any record data.",
            "type": "string"
          },
          "fieldType": {
            "$ref": "#/components/schemas/FieldType"
          },
          "isRequired": {
            "description": "Whether every record must carry a value: writes that leave the field empty are rejected. Default false. Implied true when `isUnique` or `labelField` is set.",
            "type": "boolean",
            "default": false
          },
          "isUnique": {
            "description": "Whether two records may never share a value. Enforced by a database constraint, so existing duplicates make the change fail. Default false; a unique field is also required.",
            "type": "boolean",
            "default": false
          },
          "labelField": {
            "type": "boolean",
            "default": false,
            "description": "Make this field the table's display label (see TableField.labelField). Replaces any previous label — stored or computed — on the table. Text-family, picklist, autonumber, date and number fields qualify; computed (formula/lookup/rollup) schema fields do not — a derived label is a computed column created with `DerivedFieldCreate.labelField`."
          },
          "isSearchable": {
            "type": "boolean",
            "default": true,
            "description": "Whether this field's text feeds global search. Omit to keep the default (searchable); ignored for field types that are not searchable at all."
          },
          "defaultValue": {
            "type": [
              "string",
              "null"
            ],
            "description": "A literal in the field's value format, or on `date` / `datetime` fields the dynamic token `today` / `now` (resolved at record creation). Validated against the field's own rules."
          },
          "fieldConfig": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FieldConfig"
              },
              {
                "type": "null"
              }
            ],
            "description": "User-friendly field configuration (translated to JSON Schema)"
          },
          "referencedTableId": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "For a `reference` field pointing at a user table (when referencedEntityType is 'table'), the table its values point at. Required for a `multiReference` field: the one active, non-view user table (with a reference key) whose records it links to; the owning table itself is allowed."
          },
          "referencedEntityType": {
            "type": "string",
            "enum": [
              "table",
              "user",
              "group"
            ],
            "default": "table",
            "description": "What type of entity this reference field points to"
          },
          "referencedFieldId": {
            "description": "For a `reference` or `multiReference` field to a user table: the target table's field whose value this field displays. Omit or null to use the target's label field, else its single unique field; it must be given when the target has several unique fields and no label (`REF_LABEL_AMBIGUOUS`). Ignored for `user`/`group` references.",
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "referencedTableIds": {
            "description": "For a `polymorphicReference` field, the tables a value may point into, in display order: 2 to 10 distinct ids of active user tables (not views) that each have a reference key, never the owning table. Required for that type and refused on every other. A single entry is refused with `POLY_TARGETS_REQUIRED`: one target is a plain `reference`. The field's `fieldName` is capped at 49 characters for this type (each target is stored as `<field>__<tableId>`, which must fit a 63-character identifier); a longer one is refused with `POLY_FIELD_NAME_TOO_LONG`.",
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            },
            "minItems": 1,
            "maxItems": 10
          },
          "cascadeBehavior": {
            "description": "For a reference field to a user table: what happens to this table's records when the record they point at is purged from the recycle bin. `restrict` (the default) refuses the purge while any live record still points at it; `cascade` sends the pointing records to the recycle bin together with it, as one batch that restores together, and purges them with it; `set_null` clears the reference when the target is purged, so the field cannot be required (`CASCADE_SET_NULL_REQUIRED`). Ignored for `user`/`group` references and for every other field type, except a `multiReference` field, which refuses it with `MULTI_REFERENCE_NO_CASCADE` (a link always goes with either purged record). Omitted on an update, the field keeps its behaviour.",
            "type": "string",
            "enum": [
              "restrict",
              "cascade",
              "set_null"
            ],
            "default": "restrict"
          },
          "displayOrder": {
            "type": "integer",
            "description": "Where this field sits in the table's default field order — the order `GET /tables/{tableId}/fields` returns, and therefore the order every surface draws before a saved view overrides it.\n\nOMITTING IT MEANS \"leave it alone\": on create the field is appended after the table's existing fields, and on update the stored position is kept. It used to mean position 0, which silently moved any field edited by a client that did not echo it to the front of the table. Arranging fields is `PUT /tables/{tableId}/fields/order`, which moves many fields at once and runs no schema DDL."
          },
          "description": {
            "type": "string",
            "description": "Human-readable description of this field"
          },
          "aiHint": {
            "type": "string",
            "description": "Hint for AI agents about this field's meaning and usage"
          }
        }
      },
      "PatchTableFieldRequest": {
        "type": "object",
        "minProperties": 1,
        "description": "A partial field update for `PATCH /tables/{tableId}/fields/{fieldId}`: the properties of `CreateTableFieldRequest`, every one optional and none defaulted. A property left out keeps the field's current value; a property sent replaces it. `fieldConfig` is replaced whole, not deep-merged — send the complete config (read it from the field first) to change one option. To clear a nullable property send `null` (`defaultValue`, `referencedTableId`, `referencedFieldId`); to clear `description` or `aiHint` send an empty string. An empty body is refused (400).",
        "properties": {
          "fieldName": {
            "type": "string",
            "description": "Optional. The internal name cannot change after creation; when sent it must equal the field's current name."
          },
          "displayName": {
            "description": "New human-readable label of the field. Renaming the label never changes `fieldName`.",
            "type": "string"
          },
          "fieldType": {
            "$ref": "#/components/schemas/FieldType"
          },
          "isRequired": {
            "description": "Whether a value must be present when a record is created or updated.",
            "type": "boolean"
          },
          "isUnique": {
            "description": "Whether values must be distinct across the table's records.",
            "type": "boolean"
          },
          "labelField": {
            "type": "boolean",
            "description": "Make this field the table's display label (see CreateTableFieldRequest.labelField)."
          },
          "isSearchable": {
            "description": "Whether this field's text feeds global search; ignored for field types that are not searchable at all.",
            "type": "boolean"
          },
          "defaultValue": {
            "type": [
              "string",
              "null"
            ],
            "description": "As CreateTableFieldRequest.defaultValue; `null` removes the default."
          },
          "fieldConfig": {
            "$ref": "#/components/schemas/FieldConfig",
            "description": "The complete FieldConfig; replaces the stored one whole."
          },
          "referencedTableId": {
            "description": "For a reference field with `referencedEntityType` `table`, the table its values point at; send null to clear.",
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "referencedEntityType": {
            "description": "What a reference field points at: `table` (records of `referencedTableId`), `user` (workspace users) or `group` (workspace groups).",
            "type": "string",
            "enum": [
              "table",
              "user",
              "group"
            ]
          },
          "referencedFieldId": {
            "description": "For a reference field, the field on the referenced table whose value is shown as the reference's display text; send null to clear and show the referenced table's own display label.",
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "referencedTableIds": {
            "description": "For a `polymorphicReference` field, the complete new list of target tables, in display order (2 to 10 distinct ids, same rules as on create). A table not in the current list is added; a current target left out is removed, which is refused with `POLY_TARGET_IN_USE` while any row, live or binned, still points into it. Not clearable: the list goes away only by retyping the field. A single entry is refused with `POLY_TARGETS_REQUIRED`.",
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            },
            "minItems": 1,
            "maxItems": 10
          },
          "cascadeBehavior": {
            "description": "As CreateTableFieldRequest.cascadeBehavior: what happens to this table's records when the referenced record is purged. Omitted, the field keeps its behaviour.",
            "type": "string",
            "enum": [
              "restrict",
              "cascade",
              "set_null"
            ]
          },
          "displayOrder": {
            "type": "integer",
            "description": "Position in the table's default field order. Prefer `PUT /tables/{tableId}/fields/order` for arranging fields."
          },
          "description": {
            "type": "string",
            "description": "Human-readable description of this field; an empty string clears it"
          },
          "aiHint": {
            "type": "string",
            "description": "Hint for AI agents about this field's meaning and usage; an empty string clears it"
          }
        }
      },
      "ReorderTableFieldsRequest": {
        "description": "Request body of `PUT /tables/{tableId}/fields/order`: the new display order of the table's fields, given as field ids. Fields not named keep their relative order after the named ones.",
        "type": "object",
        "required": [
          "fieldIds"
        ],
        "properties": {
          "fieldIds": {
            "type": "array",
            "minItems": 1,
            "maxItems": 500,
            "description": "The table's field ids in the order they should appear. Fields the list does not name keep their relative order and follow the named ones, so reordering the first three fields of a wide table does not require sending the rest.\n\nUnlike a saved view's `columns` — soft references validated for shape, because a view outlives the fields it names — every id here must be a live field of this table: the caller just read the list, the set is small and closed, and a typo that silently did nothing would look exactly like a reorder that worked.",
            "items": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        }
      },
      "CreateTableItemRequest": {
        "description": "Request body of `POST /tables/{tableId}/items` (and each entry of a bulk create): the field values of one new record, keyed by field name.",
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "description": "Field values of the record keyed by field name, each in the field type's value format. Required fields without a default must be present; a field left out takes its default. A reference to workspace users may be written as the `CurrentUserValue` token, stored as the caller's id. Fields the caller cannot write are refused.",
            "type": "object",
            "additionalProperties": {}
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "description": "Sandbox workspaces only. When this write moves a designated stage field, the transition is recorded as having happened at this instant instead of now — it must not be in the future and not earlier than the record's latest recorded transition for that field (400 `OCCURRED_AT_OUT_OF_ORDER`), so every timeline stays in order. Ignored when nothing stage-designated moves. A production workspace refuses it (400 `OCCURRED_AT_NOT_ALLOWED`)."
          }
        }
      },
      "RecordRef": {
        "type": "object",
        "description": "A pointer to a record created earlier in the same record-graph write, by the `ref` its `create` operation declared. It stands wherever a record id goes in a later operation's `data`: a `reference` field's value, the `id` of a `polymorphicReference` value, or one entry of a `multiReference` list. The server replaces it with the new record's id before checking the value.",
        "required": [
          "ref"
        ],
        "additionalProperties": false,
        "properties": {
          "ref": {
            "type": "string",
            "description": "The `ref` of an earlier `create` operation in the same request. Pointing at a later operation, or at a name no operation declared, refuses the whole request with `GRAPH_REF_INVALID`.",
            "pattern": "^[a-z][a-z0-9_]{0,62}$",
            "example": "inv"
          }
        }
      },
      "RecordGraphMetadata": {
        "type": "object",
        "description": "Metadata rows to write for the operation's record, keyed by metadata table name and then by the host field the row is about: an object of the row's values writes the row, `null` deletes it. Each row goes through the same checks as the single metadata write (the caller's grant on the metadata table, the covered fields, append-only), and each counts as one operation against the request's limit.",
        "additionalProperties": {
          "type": "object",
          "description": "The rows of one metadata table, keyed by the host field each row is about.",
          "additionalProperties": {
            "type": [
              "object",
              "null"
            ],
            "description": "The row's values keyed by field name, or `null` to delete the row.",
            "additionalProperties": true
          }
        },
        "example": {
          "detections": {
            "total": {
              "page": 1,
              "confidence": 62,
              "read_text": "1,260.00"
            }
          }
        }
      },
      "RecordGraphCreate": {
        "type": "object",
        "description": "Create one record. Its `data` is exactly what the single-record create takes, including staged attachment keys; a reference may name an earlier create by `{ \"ref\": … }`.",
        "required": [
          "op",
          "table",
          "data"
        ],
        "additionalProperties": false,
        "properties": {
          "op": {
            "type": "string",
            "enum": [
              "create"
            ],
            "description": "The operation kind; `create` writes a new record."
          },
          "ref": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{0,62}$",
            "description": "A name for the new record within this request, unique in it, so later operations can point at the record before it has an id. Its result carries the same `ref`.",
            "example": "inv"
          },
          "table": {
            "type": "string",
            "minLength": 1,
            "maxLength": 63,
            "description": "The table to write, by its id or its name.",
            "example": "invoices"
          },
          "data": {
            "type": "object",
            "additionalProperties": true,
            "description": "The record's values keyed by field name, as the single-record create takes them."
          },
          "metadata": {
            "$ref": "#/components/schemas/RecordGraphMetadata"
          }
        }
      },
      "RecordGraphUpdate": {
        "type": "object",
        "description": "Change fields of one existing record, as the single-record PATCH does: the fields named are set, the rest are left alone. An approval rule that would intercept the change refuses the whole request.",
        "required": [
          "op",
          "table",
          "id",
          "data"
        ],
        "additionalProperties": false,
        "properties": {
          "op": {
            "type": "string",
            "enum": [
              "update"
            ],
            "description": "The operation kind; `update` changes an existing record."
          },
          "table": {
            "type": "string",
            "minLength": 1,
            "maxLength": 63,
            "description": "The record's table, by its id or its name."
          },
          "id": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The id of an existing record. A record created in the same request cannot be updated by it."
          },
          "expectedUpdatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "The record's `updatedAt` as the caller read it. When another write has moved it since, the request is refused with `STALE_RECORD` and nothing is written."
          },
          "data": {
            "type": "object",
            "additionalProperties": true,
            "description": "The fields to change, keyed by field name."
          },
          "metadata": {
            "$ref": "#/components/schemas/RecordGraphMetadata"
          }
        }
      },
      "RecordGraphDelete": {
        "type": "object",
        "description": "Move one existing record to the recycle bin, with the records a cascade reference takes along, as the single-record delete does.",
        "required": [
          "op",
          "table",
          "id"
        ],
        "additionalProperties": false,
        "properties": {
          "op": {
            "type": "string",
            "enum": [
              "delete"
            ],
            "description": "The operation kind; `delete` bins an existing record."
          },
          "table": {
            "type": "string",
            "minLength": 1,
            "maxLength": 63,
            "description": "The record's table, by its id or its name."
          },
          "id": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The id of an existing record. A record created in the same request cannot be deleted by it."
          },
          "expectedUpdatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "The record's `updatedAt` as the caller read it. When another write has moved it since, the request is refused with `STALE_RECORD`."
          }
        }
      },
      "RecordGraphOperation": {
        "description": "One operation of a record-graph write, chosen by `op`.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/RecordGraphCreate"
          },
          {
            "$ref": "#/components/schemas/RecordGraphUpdate"
          },
          {
            "$ref": "#/components/schemas/RecordGraphDelete"
          }
        ]
      },
      "RecordGraphRequest": {
        "type": "object",
        "description": "An ordered list of record operations to apply in one transaction: every one is applied, or none is.",
        "required": [
          "operations"
        ],
        "additionalProperties": false,
        "properties": {
          "operations": {
            "type": "array",
            "minItems": 1,
            "maxItems": 500,
            "description": "The operations, applied in this order. At most 500, counting each metadata row as one.",
            "items": {
              "$ref": "#/components/schemas/RecordGraphOperation"
            }
          },
          "dryRun": {
            "type": "boolean",
            "description": "When true, every check runs and nothing is kept: no record, no file and no idempotency answer. The results show what would be written; their ids are not kept."
          }
        }
      },
      "RecordGraphResult": {
        "type": "object",
        "description": "What one operation wrote.",
        "required": [
          "index",
          "op",
          "table",
          "id"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "minimum": 0,
            "description": "The operation's position in the request, from 0."
          },
          "op": {
            "type": "string",
            "x-known-values": "KnownRecordGraphOp",
            "description": "The operation kind, as the request named it."
          },
          "ref": {
            "type": "string",
            "description": "The create's `ref`, when it declared one."
          },
          "table": {
            "type": "string",
            "description": "The id of the record's table."
          },
          "id": {
            "type": "string",
            "description": "The record's id; for a create, the id it was given."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "The record's lock token after the write, for a create or update: send it as `expectedUpdatedAt` with a later change."
          },
          "changed": {
            "type": "boolean",
            "description": "For an update, false when the record already held every value sent."
          }
        }
      },
      "KnownRecordGraphOp": {
        "type": "string",
        "description": "The operation kinds a record-graph write applies.",
        "enum": [
          "create",
          "update",
          "delete"
        ]
      },
      "RecordGraphResponse": {
        "type": "object",
        "description": "The answer to a record-graph write that was applied, one result per operation.",
        "required": [
          "results",
          "replayed"
        ],
        "properties": {
          "results": {
            "type": "array",
            "description": "One result per operation, in request order.",
            "items": {
              "$ref": "#/components/schemas/RecordGraphResult"
            }
          },
          "replayed": {
            "type": "boolean",
            "description": "True when this is the stored answer to an earlier request with the same `Idempotency-Key`: nothing was written this time."
          },
          "dryRun": {
            "type": "boolean",
            "description": "True when the request was a dry run and nothing was kept."
          }
        }
      },
      "RecordGraphOperationRef": {
        "type": "object",
        "description": "Which operation of a record-graph write a refusal is about.",
        "required": [
          "index",
          "table"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "minimum": 0,
            "description": "The operation's position in the request, from 0."
          },
          "ref": {
            "type": "string",
            "description": "The operation's `ref`, when it declared one."
          },
          "table": {
            "type": "string",
            "description": "The table as the operation named it."
          },
          "field": {
            "type": "string",
            "description": "The field the refusal is about, when there is one; a metadata row is named `<metadata table>.<field>`."
          }
        }
      },
      "RecordGraphError": {
        "type": "object",
        "description": "A refused record-graph write. Nothing was written. It is the shared error shape, with `operation` naming the first operation that failed and the single-record write's own extras (`details`, `conflict`, `ruleId`) where that refusal carries them.",
        "required": [
          "error"
        ],
        "additionalProperties": true,
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable explanation of the refusal, safe to show to a user."
          },
          "code": {
            "type": "string",
            "description": "Stable reason a client may branch on: `GRAPH_REF_INVALID`, `GRAPH_TOO_LARGE`, `VALIDATION_ERROR`, `UNIQUE_VIOLATION`, `PERMISSION_DENIED`, `STALE_RECORD`, `APPROVAL_REQUIRED`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_KEY_IN_FLIGHT`, `TRANSACTION_CONFLICT`, or a metadata write's own code (`METADATA_GRANT_MISSING`, `METADATA_APPEND_ONLY`, …)."
          },
          "details": {
            "type": "object",
            "description": "What is wrong per field, as the single-record write reports it.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "conflict": {
            "$ref": "#/components/schemas/UniqueConflict"
          },
          "ruleId": {
            "type": "string",
            "description": "For `APPROVAL_REQUIRED`, the approval rule that would intercept the update."
          },
          "ruleName": {
            "type": "string",
            "description": "For `APPROVAL_REQUIRED`, that rule's name."
          },
          "operation": {
            "$ref": "#/components/schemas/RecordGraphOperationRef"
          }
        }
      },
      "IntakeDocumentKind": {
        "type": "string",
        "description": "The kind of external document an intake accepts, which decides how a document is checked and how its values are selected: `textract-expense` is AWS Textract AnalyzeExpense output, checked structurally and read by Textract's own field types; `json` is any JSON document, checked against the definition's `documentSchema` and read by JSON pointers.",
        "enum": [
          "textract-expense",
          "json"
        ]
      },
      "IntakeValueSelector": {
        "type": "object",
        "description": "Where one value is read from in a document. Exactly one of `summary`, `lineField` or `pointer`, matching the intake's document kind: `summary` and `lineField` for `textract-expense`, `pointer` for `json`.",
        "additionalProperties": false,
        "properties": {
          "summary": {
            "type": "string",
            "minLength": 1,
            "description": "textract-expense: a summary field by its normalised type (`TOTAL`, `INVOICE_RECEIPT_ID`, …), or `OTHER` together with `label`."
          },
          "lineField": {
            "type": "string",
            "minLength": 1,
            "description": "textract-expense, inside a line item: a field of the line by its normalised type (`ITEM`, `QUANTITY`, `PRICE`, …)."
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "description": "With `summary` `OTHER`, the field's printed label as Textract read it."
          },
          "pick": {
            "type": "string",
            "enum": [
              "highestConfidence",
              "first",
              "last"
            ],
            "description": "Which field to take when the type occurs more than once (two `TOTAL`s, say): the highest type confidence (the default, the first in document order on a tie), the first, or the last."
          },
          "pointer": {
            "type": "string",
            "description": "json: a JSON pointer to a scalar value, relative to the record's scope (the document for the root, the entry for a child), such as `/header/total`."
          }
        }
      },
      "IntakeEachSelector": {
        "type": "object",
        "description": "The entries a child mapping makes one record for, in document order. Exactly one of `lineItems` (textract-expense) or `each` (json).",
        "additionalProperties": false,
        "properties": {
          "lineItems": {
            "type": "boolean",
            "enum": [
              true
            ],
            "description": "textract-expense: every line item of every line item group, in order. A line split across pages is one line."
          },
          "each": {
            "type": "string",
            "description": "json: a JSON pointer ending in `/*` to an array whose entries each become a record, such as `/lines/*`."
          }
        }
      },
      "IntakeFieldMapping": {
        "type": "object",
        "description": "One value of the document, read by `from`, converted by `rules`, written to the field `to`.",
        "required": [
          "from",
          "to"
        ],
        "additionalProperties": false,
        "properties": {
          "from": {
            "$ref": "#/components/schemas/IntakeValueSelector"
          },
          "to": {
            "type": "string",
            "minLength": 1,
            "description": "The field of the record's table that receives the value, by name."
          },
          "rules": {
            "$ref": "#/components/schemas/ImportColumnRules"
          }
        }
      },
      "IntakeEvidence": {
        "type": "object",
        "description": "Where each mapped value's evidence is recorded: one row of a metadata table per value found, about the field the value was written to. `fields` names, for each field of the metadata table, the part of the source value it receives; the intake copies parts and never computes one.",
        "required": [
          "metadataTable",
          "fields"
        ],
        "additionalProperties": false,
        "properties": {
          "metadataTable": {
            "type": "string",
            "minLength": 1,
            "description": "The metadata table, declared on the record's table, that receives the rows."
          },
          "fields": {
            "type": "object",
            "description": "Metadata field name → the source part it receives. textract-expense parts are `page`, `type.text`, `type.confidence`, `label.text`, `label.confidence`, `value.text`, `value.confidence` and `value.box`; json's only part is `value.text`.",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "IntakeRecordMapping": {
        "type": "object",
        "description": "How the document makes one record, and the records under it.",
        "required": [
          "table",
          "fields"
        ],
        "additionalProperties": false,
        "properties": {
          "table": {
            "type": "string",
            "minLength": 1,
            "description": "The table the record is created in, by name."
          },
          "fields": {
            "type": "array",
            "description": "The values the record takes from the document. Fields not listed keep their defaults.",
            "items": {
              "$ref": "#/components/schemas/IntakeFieldMapping"
            }
          },
          "evidence": {
            "$ref": "#/components/schemas/IntakeEvidence"
          },
          "children": {
            "type": "array",
            "description": "Records made under this one, once per entry their `each` finds. Records nest at most 3 levels deep.",
            "items": {
              "$ref": "#/components/schemas/IntakeChildMapping"
            }
          }
        }
      },
      "IntakeChildMapping": {
        "type": "object",
        "description": "A record mapping made once per entry of the document, linked to its parent record.",
        "required": [
          "each",
          "table",
          "link",
          "fields"
        ],
        "additionalProperties": false,
        "properties": {
          "each": {
            "$ref": "#/components/schemas/IntakeEachSelector"
          },
          "table": {
            "type": "string",
            "minLength": 1,
            "description": "The table each record is created in, by name."
          },
          "link": {
            "type": "string",
            "minLength": 1,
            "description": "The reference field of this table that points at the parent record."
          },
          "fields": {
            "type": "array",
            "description": "The values each record takes from its entry.",
            "items": {
              "$ref": "#/components/schemas/IntakeFieldMapping"
            }
          },
          "evidence": {
            "$ref": "#/components/schemas/IntakeEvidence"
          },
          "children": {
            "type": "array",
            "description": "Records made under each of these, at most 3 levels deep in all.",
            "items": {
              "$ref": "#/components/schemas/IntakeChildMapping"
            }
          }
        }
      },
      "IntakeFiles": {
        "type": "object",
        "description": "The attachment fields of the root table that keep a delivery's files.",
        "required": [
          "document",
          "source"
        ],
        "additionalProperties": false,
        "properties": {
          "document": {
            "type": "string",
            "minLength": 1,
            "description": "The attachment field that receives the raw document, exactly as delivered."
          },
          "source": {
            "type": "string",
            "minLength": 1,
            "description": "The attachment field that receives the source file the document was read from, such as the scanned PDF."
          }
        }
      },
      "IntakeDefinition": {
        "type": "object",
        "description": "What an intake does with a document: the kind of document it accepts, how the document's values map onto a record and the records under it, and where the delivery's files are kept.",
        "required": [
          "documentKind",
          "files",
          "root"
        ],
        "additionalProperties": false,
        "properties": {
          "documentKind": {
            "$ref": "#/components/schemas/IntakeDocumentKind"
          },
          "documentSchema": {
            "type": "object",
            "additionalProperties": true,
            "description": "json only: the JSON Schema (draft-07) a document must satisfy. Refused on textract-expense, which has a built-in check."
          },
          "files": {
            "$ref": "#/components/schemas/IntakeFiles"
          },
          "root": {
            "$ref": "#/components/schemas/IntakeRecordMapping"
          },
          "corrections": {
            "type": "array",
            "maxItems": 50,
            "description": "Correction rules, run in order on every delivery after the mapping and reference lookups and before the write. A value a rule sets is named in the delivery's `corrected` and in the record's history.",
            "items": {
              "$ref": "#/components/schemas/IntakeCorrectionRule"
            }
          },
          "learning": {
            "$ref": "#/components/schemas/IntakeLearning"
          }
        }
      },
      "IntakeLearning": {
        "type": "object",
        "description": "How the platform studies reviewers' corrections to this intake's records to suggest correction rules. Without it the intake is not studied.",
        "additionalProperties": false,
        "properties": {
          "minCorrections": {
            "type": "integer",
            "minimum": 2,
            "maximum": 50,
            "description": "How many records corrected the same way make a suggestion; 3 when absent."
          },
          "windowDays": {
            "type": "integer",
            "minimum": 7,
            "maximum": 730,
            "description": "How far back, in days, a correction counts; 120 when absent."
          },
          "contextFields": {
            "type": "array",
            "maxItems": 5,
            "description": "Fields of the root's table whose value a correction is grouped by, so \"set department to Facilities\" is suggested for the supplier it keeps recurring with.",
            "items": {
              "type": "string",
              "description": "A field name on the root's table."
            }
          }
        }
      },
      "IntakeRuleSuggestion": {
        "type": "object",
        "description": "A correction rule the platform suggests from reviewers' corrections, with those corrections as evidence.",
        "required": [
          "id",
          "kind",
          "status",
          "rule",
          "recordCount",
          "evidence",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "description": "The suggestion's id."
          },
          "kind": {
            "type": "string",
            "x-known-values": "KnownIntakeRuleSuggestionKind",
            "description": "`text`: the same text the document held was corrected to the same value. `context`: the same value was set while a context field agreed. Open contract: clients must tolerate kinds they do not know."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownIntakeRuleSuggestionStatus",
            "description": "`open`, `accepted` or `dismissed`. Open contract: clients must tolerate statuses they do not know."
          },
          "rule": {
            "$ref": "#/components/schemas/IntakeCorrectionRule"
          },
          "recordCount": {
            "type": "integer",
            "description": "How many records were corrected this way within the window, including any the caller cannot read."
          },
          "evidence": {
            "type": "array",
            "description": "The corrections, one per record, newest first, on records the caller can read.",
            "items": {
              "$ref": "#/components/schemas/IntakeRuleEvidence"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the suggestion was first made."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When its evidence last changed."
          },
          "decidedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was accepted or dismissed."
          },
          "decidedBy": {
            "type": [
              "string",
              "null"
            ],
            "description": "The user id of the admin who accepted or dismissed it."
          },
          "acceptedAs": {
            "type": [
              "string",
              "null"
            ],
            "description": "The name the accepted rule was given in the draft."
          }
        }
      },
      "KnownIntakeRuleSuggestionStatus": {
        "type": "string",
        "enum": [
          "open",
          "accepted",
          "dismissed"
        ],
        "description": "The statuses a suggestion takes today."
      },
      "KnownIntakeRuleSuggestionKind": {
        "type": "string",
        "enum": [
          "text",
          "context"
        ],
        "description": "The kinds of suggestion made today."
      },
      "IntakeRuleEvidence": {
        "type": "object",
        "description": "One reviewer correction a suggestion rests on.",
        "required": [
          "tableId",
          "recordId",
          "field",
          "after",
          "userId",
          "at"
        ],
        "additionalProperties": false,
        "properties": {
          "tableId": {
            "type": "string",
            "description": "The corrected record's table."
          },
          "recordId": {
            "type": "string",
            "description": "The corrected record."
          },
          "field": {
            "type": "string",
            "description": "The field corrected."
          },
          "before": {
            "description": "The value the delivery gave it, absent when it gave none."
          },
          "after": {
            "description": "The value the reviewer set."
          },
          "readText": {
            "type": [
              "string",
              "null"
            ],
            "description": "The text the document held for the field, when the intake kept it as evidence."
          },
          "userId": {
            "type": "string",
            "description": "Who made the correction."
          },
          "userName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name, for display."
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "description": "When the correction was made."
          }
        }
      },
      "IntakeRuleSuggestionList": {
        "type": "object",
        "description": "An intake's suggested correction rules.",
        "required": [
          "suggestions"
        ],
        "additionalProperties": false,
        "properties": {
          "suggestions": {
            "type": "array",
            "description": "Open suggestions first, then decided ones, newest first.",
            "items": {
              "$ref": "#/components/schemas/IntakeRuleSuggestion"
            }
          }
        }
      },
      "IntakeRuleSuggestionRefresh": {
        "type": "object",
        "description": "What a run of the suggestion job found for one intake.",
        "required": [
          "studied",
          "open",
          "created"
        ],
        "additionalProperties": false,
        "properties": {
          "studied": {
            "type": "boolean",
            "description": "False when the published version has no `learning` block, so nothing was looked at."
          },
          "open": {
            "type": "integer",
            "description": "Open suggestions after the run."
          },
          "created": {
            "type": "integer",
            "description": "Suggestions the run made."
          }
        }
      },
      "IntakeRuleSuggestionAccepted": {
        "type": "object",
        "description": "An accepted suggestion and the intake whose draft now holds its rule.",
        "required": [
          "suggestion",
          "intake"
        ],
        "additionalProperties": false,
        "properties": {
          "suggestion": {
            "$ref": "#/components/schemas/IntakeRuleSuggestion"
          },
          "intake": {
            "$ref": "#/components/schemas/Intake"
          }
        }
      },
      "IntakeCorrectionRule": {
        "type": "object",
        "description": "One correction rule: on every record a delivery builds for `table` whose conditions all hold, set the given values, overwriting what the mapping produced. A rule never clears a value, creates a record or reads another delivery; anything beyond that is a flow on `ItemCreated`.",
        "required": [
          "name",
          "table",
          "when",
          "set"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,62}$",
            "description": "Unique within the definition; what the delivery's answer and the record's history name."
          },
          "table": {
            "type": "string",
            "description": "A table the mapping writes (the root's or a child's)."
          },
          "when": {
            "type": "array",
            "minItems": 1,
            "maxItems": 8,
            "description": "Conditions that must all hold for the rule to apply.",
            "items": {
              "$ref": "#/components/schemas/IntakeCorrectionCondition"
            }
          },
          "set": {
            "type": "object",
            "minProperties": 1,
            "maxProperties": 8,
            "additionalProperties": true,
            "description": "Field name to value, as the record API takes it for the field's type (a reference takes the record id). Checked against each field's value contract at publish and at delivery. The intake's files and a child's link to its parent cannot be set."
          }
        }
      },
      "IntakeCorrectionCondition": {
        "type": "object",
        "description": "One condition of a correction rule.",
        "required": [
          "field",
          "op"
        ],
        "additionalProperties": false,
        "properties": {
          "of": {
            "$ref": "#/components/schemas/IntakeCorrectionSubject"
          },
          "field": {
            "type": "string",
            "description": "The field tested, on the record, on its root record, or (for `read`) the field whose read text is tested."
          },
          "op": {
            "$ref": "#/components/schemas/IntakeCorrectionOperator"
          },
          "value": {
            "description": "The value compared against: the stored form for `record` and `root` (a record id for a reference), text for `read`, an array of those for `in`. Omitted for `isEmpty` and `isNotEmpty`."
          }
        }
      },
      "IntakeCorrectionSubject": {
        "type": "string",
        "enum": [
          "record",
          "root",
          "read"
        ],
        "description": "What a condition reads: `record` (the default) the mapped value on the record the rule sets, `root` the mapped value on the delivery's root record, `read` the text the document held for that field on this record, before any import rule ran. Values are compared after reference lookups, as the write would store them; text from `read` is compared case- and whitespace-insensitively."
      },
      "IntakeCorrectionOperator": {
        "type": "string",
        "enum": [
          "eq",
          "neq",
          "in",
          "isEmpty",
          "isNotEmpty",
          "contains",
          "startsWith"
        ],
        "description": "The comparison: `eq` / `neq` an equal value, `in` any of an array of values, `isEmpty` / `isNotEmpty` whether there is a value, `contains` / `startsWith` text matching case-insensitively."
      },
      "IntakeVersion": {
        "type": "object",
        "description": "One version of an intake's definition. The draft is edited in place; a published version never changes.",
        "required": [
          "version",
          "state",
          "definition",
          "updatedAt"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "The version's number, counting from 1."
          },
          "state": {
            "type": "string",
            "x-known-values": "KnownIntakeVersionState",
            "description": "`draft` (editable), `published` (the one deliveries run), or `archived` (an earlier published version)."
          },
          "definition": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/IntakeDefinition"
              },
              {
                "type": "null"
              }
            ],
            "description": "The definition. Null when the stored definition no longer reads under the current rules (`issues` says why): a delivery refuses such a version, and saving the draft over it repairs it."
          },
          "issues": {
            "type": "array",
            "description": "Why the stored definition no longer reads, each problem at its path; present only when `definition` is null.",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "publishedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the version was published; null for the draft."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the version last changed. For the draft, send it as `expectedUpdatedAt` when saving."
          }
        }
      },
      "KnownIntakeVersionState": {
        "type": "string",
        "description": "The states an intake version can be in.",
        "enum": [
          "draft",
          "published",
          "archived"
        ]
      },
      "Intake": {
        "type": "object",
        "description": "An intake, with its draft and the number of its published version.",
        "required": [
          "id",
          "name",
          "label",
          "documentKind",
          "publishedVersion",
          "draft",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The intake's id."
          },
          "name": {
            "type": "string",
            "description": "The intake's API name, used in its paths."
          },
          "label": {
            "type": "string",
            "description": "The intake's name as people see it."
          },
          "documentKind": {
            "$ref": "#/components/schemas/IntakeDocumentKind"
          },
          "publishedVersion": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The version deliveries run, or null before the first publish."
          },
          "draft": {
            "$ref": "#/components/schemas/IntakeVersion"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the intake was created."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the intake last changed."
          }
        }
      },
      "IntakeList": {
        "type": "array",
        "description": "The workspace's intakes.",
        "items": {
          "$ref": "#/components/schemas/Intake"
        }
      },
      "IntakeVersionList": {
        "type": "array",
        "description": "An intake's versions, newest first.",
        "items": {
          "$ref": "#/components/schemas/IntakeVersion"
        }
      },
      "CreateIntakeRequest": {
        "type": "object",
        "description": "A new intake, with the definition of its first draft.",
        "required": [
          "name",
          "label",
          "definition"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{0,62}$",
            "description": "The API name, unique in the workspace."
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "The name people see."
          },
          "definition": {
            "$ref": "#/components/schemas/IntakeDefinition"
          }
        }
      },
      "SaveIntakeDraftRequest": {
        "type": "object",
        "description": "A new definition for the intake's draft.",
        "required": [
          "definition",
          "expectedUpdatedAt"
        ],
        "additionalProperties": false,
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "A new name people see, when it changes."
          },
          "definition": {
            "$ref": "#/components/schemas/IntakeDefinition"
          },
          "expectedUpdatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "The draft's `updatedAt` as read. A draft saved since is refused with `STALE_RECORD`."
          }
        }
      },
      "IntakeIssuesError": {
        "type": "object",
        "description": "A refused definition, with every problem found, each naming its path in the definition.",
        "required": [
          "error",
          "issues"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable summary of the refusal."
          },
          "code": {
            "type": "string",
            "description": "`INTAKE_INVALID`."
          },
          "issues": {
            "type": "array",
            "description": "Each problem, with the path it is about.",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          }
        }
      },
      "IntakeDeliveryFiles": {
        "type": "object",
        "description": "The delivery's files, each the attachment value a record create takes: a file the caller staged on that attachment field of the intake's root table with `POST /tables/{tableId}/fields/{fieldId}/attachments/staged`. The delivery binds both to the record it creates.",
        "required": [
          "source"
        ],
        "additionalProperties": false,
        "properties": {
          "document": {
            "$ref": "#/components/schemas/Attachment"
          },
          "source": {
            "$ref": "#/components/schemas/Attachment"
          }
        }
      },
      "IntakeDeliveryRequest": {
        "type": "object",
        "description": "One document for an intake to turn into records. The document arrives either staged, as `files.document`, or inline, as `document`; exactly one of the two. A staged document suits a large one (Textract output with its OCR blocks is often larger than a request body may be) and is kept byte for byte; an inline document is written to the definition's document field as JSON.",
        "required": [
          "files"
        ],
        "additionalProperties": false,
        "properties": {
          "document": {
            "type": "object",
            "additionalProperties": true,
            "description": "The document itself, for a small one. Leave `files.document` out when sending it."
          },
          "files": {
            "$ref": "#/components/schemas/IntakeDeliveryFiles"
          },
          "dryRun": {
            "type": "boolean",
            "description": "When true, everything runs and nothing is kept: no record, no file and no idempotency answer. The answer includes the record-graph request the intake built, to check a mapping against a sample document."
          },
          "draft": {
            "type": "boolean",
            "description": "When true, the intake's draft runs instead of its published version, to test a change before publishing it. Only with `dryRun`."
          }
        }
      },
      "IntakeDeliveryUnresolved": {
        "type": "object",
        "description": "A reference the document named that matched no record the caller can read, or more than one. The field was left empty; its evidence row keeps the text that was read.",
        "required": [
          "index",
          "field",
          "text",
          "reason"
        ],
        "additionalProperties": false,
        "properties": {
          "index": {
            "type": "integer",
            "description": "The operation's position in the record-graph request, as in `results`."
          },
          "field": {
            "type": "string",
            "description": "The reference field left empty."
          },
          "text": {
            "type": "string",
            "description": "The text the document held, which matched no record."
          },
          "reason": {
            "type": "string",
            "description": "Why it did not resolve: `unmatched`, `ambiguous`, `below_threshold`, or a sentence for a key the target cannot match on."
          }
        }
      },
      "IntakeDeliveryBlanked": {
        "type": "object",
        "description": "A value the document held that did not convert to its field's type. The field was left empty rather than the delivery refused; its evidence row keeps the text that was read.",
        "required": [
          "index",
          "field",
          "text",
          "reason"
        ],
        "additionalProperties": false,
        "properties": {
          "index": {
            "type": "integer",
            "description": "The operation's position in the record-graph request, as in `results`."
          },
          "field": {
            "type": "string",
            "description": "The field left empty."
          },
          "text": {
            "type": "string",
            "description": "The text the document held."
          },
          "reason": {
            "type": "string",
            "description": "Why it did not convert, in a sentence."
          }
        }
      },
      "IntakeDeliveryResponse": {
        "type": "object",
        "description": "What a delivery wrote, and what it could not map. `results` are the record-graph write's, one per record created, in the order the intake built them: the root first, then each child after its parent.",
        "required": [
          "results",
          "replayed",
          "intake",
          "unresolved",
          "blanked",
          "corrected"
        ],
        "additionalProperties": false,
        "properties": {
          "results": {
            "type": "array",
            "description": "One entry per record written, as the record-graph write answers.",
            "items": {
              "$ref": "#/components/schemas/RecordGraphResult"
            }
          },
          "replayed": {
            "type": "boolean",
            "description": "True when this is the stored answer to an earlier delivery with the same `Idempotency-Key`."
          },
          "dryRun": {
            "type": "boolean",
            "description": "True when nothing was kept."
          },
          "intake": {
            "$ref": "#/components/schemas/IntakeDeliveryVersion"
          },
          "unresolved": {
            "type": "array",
            "description": "References left empty because no single readable record matched.",
            "items": {
              "$ref": "#/components/schemas/IntakeDeliveryUnresolved"
            }
          },
          "blanked": {
            "type": "array",
            "description": "Values left empty because they did not convert.",
            "items": {
              "$ref": "#/components/schemas/IntakeDeliveryBlanked"
            }
          },
          "corrected": {
            "type": "array",
            "description": "Values a correction rule set, one per record and field (the last rule to set it).",
            "items": {
              "$ref": "#/components/schemas/IntakeDeliveryCorrected"
            }
          },
          "request": {
            "$ref": "#/components/schemas/RecordGraphRequest"
          }
        }
      },
      "IntakeDeliveryVersion": {
        "type": "object",
        "description": "The intake and version that made the records; their events carry the same as `metadata.intake`.",
        "required": [
          "name",
          "version"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "description": "The intake's name."
          },
          "version": {
            "type": "integer",
            "description": "The version that ran."
          },
          "corrections": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "On a record's history only: field name to the correction rule that set that field when the delivery created the record. Absent when no rule applied."
          }
        }
      },
      "IntakeDeliveryCorrected": {
        "type": "object",
        "description": "One value a correction rule set.",
        "required": [
          "index",
          "field",
          "rule"
        ],
        "additionalProperties": false,
        "properties": {
          "index": {
            "type": "integer",
            "description": "The record's operation index in the delivery, as `results` are ordered."
          },
          "field": {
            "type": "string",
            "description": "The field the rule set."
          },
          "rule": {
            "type": "string",
            "description": "The rule's name."
          }
        }
      },
      "IntakeDocumentProblem": {
        "type": "object",
        "description": "One reason the document is not one the intake accepts, at a JSON pointer into the document.",
        "required": [
          "path",
          "message"
        ],
        "additionalProperties": false,
        "properties": {
          "path": {
            "type": "string",
            "description": "A JSON pointer into the document; empty for the document as a whole."
          },
          "message": {
            "type": "string",
            "description": "What is wrong there, and what to send instead."
          }
        }
      },
      "IntakeDocumentError": {
        "type": "object",
        "description": "A delivery refused before anything was written: the document is not one the intake accepts (`DOCUMENT_INVALID`), or the request names its document wrongly (`DOCUMENT_SOURCE`).",
        "required": [
          "error",
          "code",
          "problems"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable summary of the refusal."
          },
          "code": {
            "type": "string",
            "description": "`DOCUMENT_INVALID` or `DOCUMENT_SOURCE`."
          },
          "problems": {
            "type": "array",
            "description": "Each problem, with where in the document it is.",
            "items": {
              "$ref": "#/components/schemas/IntakeDocumentProblem"
            }
          }
        }
      },
      "BulkCreateRecordsRequest": {
        "description": "Request body of `POST /tables/{tableId}/items/bulk`: a batch of records to create in one call, each shaped like a single-record create.",
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "description": "The records to create, one CreateTableItemRequest each, in the order their outcomes come back. Non-empty and within the server's per-call cap, which bounds one request's runtime — a larger batch is the client's to page.\n",
            "minItems": 1,
            "maxItems": 500,
            "items": {
              "$ref": "#/components/schemas/CreateTableItemRequest"
            }
          },
          "onMatch": {
            "type": "string",
            "enum": [
              "create",
              "update",
              "skip"
            ],
            "description": "What to do with an item whose `matchBy` key equals an existing record's: `create` (the default) creates it anyway, so a unique key refuses it; `update` merges the item's fields into that record, as a PATCH would, so a batch can be sent again without duplicating what landed the first time; `skip` leaves the record alone. Items that match nothing are created. An item sharing a key with an earlier item of the same batch matches the record that item created. `update` also needs the `records:update` action."
          },
          "matchBy": {
            "type": "string",
            "description": "The key `onMatch` compares on: the name of a unique field of this table, or `referenceKey` for the table's own reference key (its unique label, its one unique field, or the fields of its nominated reference-key constraint). Required when `onMatch` is `update` or `skip`. An item with no value for the key matches nothing."
          },
          "dryRun": {
            "type": "boolean",
            "description": "Check every item and write nothing: each outcome says what the call would do (`action`) or why the item would fail. A dry run matches items, checks field permissions, field rules and table constraints; stage rules, approval rules and automations are only run by the real write. No records, events or ids are produced."
          },
          "resolve": {
            "type": "object",
            "description": "Reference fields whose values are target KEY values rather than record ids, and the key to look each up by: the name of a unique field of the target table (`\"service_partner\": \"name\"`), or `referenceKey` for the target's own reference key — its unique label, its one unique field, or the fields of its nominated reference-key constraint, in which case the value is an object naming every key field (`{ \"site\": \"<id>\", \"date\": \"2026-03-01\" }`). A value that is an existing record's id passes as one; a value that matches no record, or several, fails its own record. A reference to users resolves by member `email`. Without this map every reference value must be a record id — the CSV import resolves keys on its own, this endpoint only when asked. An entry the table cannot honour (not a reference, not a unique field, a target with no key) refuses the whole request with 400 `RESOLVE_INVALID` before anything is written.",
            "additionalProperties": {
              "type": "string",
              "description": "The target's field whose value the request carries for this reference, or `referenceKey`."
            }
          }
        }
      },
      "BulkCreateRecordOutcome": {
        "type": "object",
        "description": "What happened to one requested record in a bulk create.",
        "required": [
          "index",
          "ok",
          "action"
        ],
        "properties": {
          "action": {
            "type": "string",
            "x-known-values": "KnownBulkCreateAction",
            "description": "What the call did with the item (or, on a dry run, would do): `created`, `updated` (an existing record matched and was updated), `skipped` (an existing record matched and `onMatch` is `skip`) or `failed`. Open-ended: clients tolerate a value they do not know and read `ok`."
          },
          "index": {
            "type": "integer",
            "description": "Position of the request in `items` (0-based)."
          },
          "ok": {
            "description": "`true` when the item was created, updated or skipped as asked (or would be, on a dry run); `false` when it failed, with `reason` and `message` saying why.",
            "type": "boolean"
          },
          "itemId": {
            "type": "string",
            "description": "The record's id: the created one, or the existing record an `updated` or `skipped` item matched. Absent for a failure and for an item a dry run would create."
          },
          "reason": {
            "type": "string",
            "description": "Why this record was not created. Mirrors the failure kinds of the single-record create.\n",
            "enum": [
              "not_found",
              "permission",
              "validation",
              "view_readonly",
              "mirrored_read_only"
            ]
          },
          "message": {
            "type": "string",
            "description": "Human-readable detail for this record's failure."
          },
          "details": {
            "type": "array",
            "description": "Per-field validation messages, when `reason` is validation.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "KnownBulkCreateAction": {
        "type": "string",
        "description": "What a bulk create did with one item.",
        "enum": [
          "created",
          "updated",
          "skipped",
          "failed"
        ]
      },
      "BulkCreateRecordsResult": {
        "description": "Response of `POST /tables/{tableId}/items/bulk`. The call is not a transaction: the counts and the per-record `results` describe how many of the requested records were created and which ones failed, so a 200 must be read together with them.",
        "type": "object",
        "required": [
          "requested",
          "succeeded",
          "created",
          "updated",
          "skipped",
          "failed",
          "results"
        ],
        "properties": {
          "requested": {
            "description": "How many records the request asked to create (the length of `items`), echoed so a client can confirm nothing was dropped.",
            "type": "integer"
          },
          "succeeded": {
            "description": "How many of the requested items succeeded: created, updated or skipped (or would be, on a dry run). Equals `requested` only when every entry of `results` is `ok`.",
            "type": "integer"
          },
          "created": {
            "description": "How many items were created (or would be, on a dry run).",
            "type": "integer"
          },
          "updated": {
            "description": "How many items updated the existing record they matched (or would).",
            "type": "integer"
          },
          "skipped": {
            "description": "How many items matched an existing record and were left alone (or would be).",
            "type": "integer"
          },
          "dryRun": {
            "description": "True when the request was a dry run and nothing was written.",
            "type": "boolean"
          },
          "matchedBy": {
            "type": "string",
            "description": "The key items were matched on, in field names (`email`, or `site, date` for a composite key). Absent when the request gave no `onMatch` other than `create`."
          },
          "failed": {
            "description": "How many of the requested records were not created (`requested` minus `succeeded`); each failure's reason is in `results`.",
            "type": "integer"
          },
          "results": {
            "type": "array",
            "description": "One entry per requested record, in request order, so the created ids line up with `items` without a second read.\n",
            "items": {
              "$ref": "#/components/schemas/BulkCreateRecordOutcome"
            }
          },
          "automationWarnings": {
            "type": "array",
            "description": "Automation warnings raised while writing, de-duplicated across the batch.\n",
            "items": {
              "type": "string"
            }
          },
          "resolvedBy": {
            "type": "object",
            "description": "For each field named in the request's `resolve`, the target key its values were looked up by — a field name (`name`, `email`) or the comma-separated fields of a composite reference key (`site, date`) — the way an import's resolved mapping reports `matchBy`. Absent when the request gave no `resolve`.",
            "additionalProperties": {
              "type": "string",
              "description": "The key field (or fields) the values of this reference were matched on."
            }
          }
        }
      },
      "BulkUpdateRecordsRequest": {
        "description": "Request body of `POST /tables/{tableId}/items/bulk-update`: an explicit list of record ids and the field values to merge into every one of them.",
        "type": "object",
        "required": [
          "itemIds",
          "data"
        ],
        "properties": {
          "itemIds": {
            "type": "array",
            "description": "Record ids to operate on: an explicit list the caller selected. Must be non-empty, free of duplicates, and within the server's per-call cap, which bounds one request's blast radius and its runtime — a larger selection is the client's to page.\n\nSelection by filter (\"everything matching this view\") is deliberately not accepted: a filter selects a set the caller cannot see in full at the moment they confirm it, so it needs a counted preview before it is safe to point a delete at. Ids keep the destructive surface to what a user actually pointed at.\n",
            "minItems": 1,
            "maxItems": 500,
            "items": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          "data": {
            "type": "object",
            "description": "Field values to apply to every selected record, merged over each record's existing values. At least one field is required — an empty object is a 400 rather than a no-op, because a bulk write that changes nothing is far more likely to be a client bug than an intention.\n",
            "minProperties": 1,
            "additionalProperties": {}
          },
          "results": {
            "type": "string",
            "enum": [
              "all",
              "failures"
            ],
            "description": "Which per-record outcomes to return: `all` (the default) lists every record in the order requested; `failures` lists only the records that were not changed, so a caller that only needs the counts and the problems is not sent one `ok: true` line per row.\n"
          }
        }
      },
      "BulkPatchRecordsRequest": {
        "description": "Request body of `POST /tables/{tableId}/items/bulk-patch`: a list of records, each with its own field values to merge into it — the per-record form of bulk update, for a change whose value differs from record to record (a backfill derived from other columns, a picklist set from a lookup).",
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "description": "The records to change, each named once, with the values for that record. Must be non-empty, free of duplicate ids, and within the server's per-call cap (the same cap as bulk update) — a larger set is the client's to page. Outcomes come back in this order.\n",
            "minItems": 1,
            "maxItems": 500,
            "items": {
              "$ref": "#/components/schemas/BulkPatchRecordItem"
            }
          },
          "results": {
            "type": "string",
            "enum": [
              "all",
              "failures"
            ],
            "description": "Which per-record outcomes to return: `all` (the default) lists every record in the order requested; `failures` lists only the records that were not changed, so a caller that only needs the counts and the problems is not sent one `ok: true` line per row.\n"
          }
        }
      },
      "BulkPatchRecordItem": {
        "description": "One record of a bulk patch: which record, the field values to merge into it, and optionally the `updatedAt` the caller last read, so a record that moved since is refused rather than overwritten.",
        "type": "object",
        "required": [
          "id",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The record (an item is a record) to change. Echoed back as `itemId` in this record's outcome.",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "data": {
            "type": "object",
            "description": "Field values for this record, keyed by field name, merged over its existing values (fields not named are left alone; a key set to null clears that field). At least one field is required — a record in the batch that changes nothing is far more likely to be a client bug than an intention.\n",
            "minProperties": 1,
            "additionalProperties": {}
          },
          "expectedUpdatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When set, this record is written only if its current `updatedAt` still matches this timestamp (millisecond precision). On mismatch the record is not changed and its outcome is `reason: conflict`; the rest of the batch is unaffected. Omit for last-write-wins.\n"
          }
        }
      },
      "BulkDeleteRecordsRequest": {
        "description": "Request body of `POST /tables/{tableId}/items/bulk-delete`: the explicit list of record ids to delete (selection by filter is deliberately not accepted) and how much of the per-record outcome to return.",
        "type": "object",
        "required": [
          "itemIds"
        ],
        "properties": {
          "itemIds": {
            "type": "array",
            "description": "Record ids to operate on: an explicit list the caller selected. Must be non-empty, free of duplicates, and within the server's per-call cap, which bounds one request's blast radius and its runtime — a larger selection is the client's to page.\n\nSelection by filter (\"everything matching this view\") is deliberately not accepted: a filter selects a set the caller cannot see in full at the moment they confirm it, so it needs a counted preview before it is safe to point a delete at. Ids keep the destructive surface to what a user actually pointed at.\n",
            "minItems": 1,
            "maxItems": 500,
            "items": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          "results": {
            "type": "string",
            "enum": [
              "all",
              "failures"
            ],
            "description": "Which per-record outcomes to return: `all` (the default) lists every record in the order requested; `failures` lists only the records that were not changed, so a caller that only needs the counts and the problems is not sent one `ok: true` line per row.\n"
          }
        }
      },
      "BulkRecordOutcome": {
        "type": "object",
        "description": "What happened to one record in a bulk operation.",
        "required": [
          "itemId",
          "ok"
        ],
        "properties": {
          "itemId": {
            "description": "The record this outcome is about (an item is a record), echoed from the request so outcomes can be matched to inputs in any order.",
            "type": "string"
          },
          "ok": {
            "description": "`true` when the operation was applied to this record; `false` when it was not, with `reason` and `message` saying why.",
            "type": "boolean"
          },
          "reason": {
            "type": "string",
            "description": "Why this record was not written. Mirrors the failure kinds of the single-record write path so a bulk failure is diagnosable the same way: `not_found` also covers a record outside the caller's row scope (an out-of-scope record is not distinguishable from a missing one, by design — distinguishing them would leak existence). `mirrored_read_only`: the table is mirrored from an external source, and its records and mirrored fields are changed only by the sync. `conflict` on a bulk patch also covers an entry whose `expectedUpdatedAt` no longer matches the record.\n",
            "enum": [
              "not_found",
              "permission",
              "validation",
              "approval_required",
              "conflict",
              "view_readonly",
              "mirrored_read_only"
            ]
          },
          "message": {
            "type": "string",
            "description": "Human-readable detail for this record's failure."
          },
          "details": {
            "type": "array",
            "description": "Per-field validation messages, when `reason` is validation.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "BulkRecordOperationResult": {
        "description": "Outcome of a bulk update, bulk patch or bulk delete over a selection of records: the counts, the per-record results and, for deletes, the recycle-bin batch. Response of `POST /tables/{tableId}/items/bulk-update`, `bulk-patch` and `bulk-delete`.",
        "type": "object",
        "required": [
          "requested",
          "succeeded",
          "failed",
          "results"
        ],
        "properties": {
          "requested": {
            "description": "How many records the request named, before any of them were attempted.",
            "type": "integer"
          },
          "succeeded": {
            "description": "Records that were actually changed (updated or deleted).",
            "type": "integer"
          },
          "failed": {
            "description": "Records that were not changed, for any reason (validation, permissions, concurrency). `succeeded + failed = requested`; `results` has the reason per record.",
            "type": "integer"
          },
          "results": {
            "type": "array",
            "description": "One entry per requested record, in the order requested. Present even when every record succeeded, so a client can report per-record outcomes without a second read — unless the request asked for `results: failures`, when only the records that were not changed are listed (the counts above are always complete).\n",
            "items": {
              "$ref": "#/components/schemas/BulkRecordOutcome"
            }
          },
          "batchId": {
            "type": "string",
            "description": "Bulk delete only: the recycle-bin batch every deleted record shares. Restoring any one of those records from the bin restores the whole batch. Absent when nothing was deleted.\n"
          },
          "automationWarnings": {
            "type": "array",
            "description": "Automation warnings raised while writing, de-duplicated across the selection — a rule that warns on every one of 200 records should not produce 200 identical lines.\n",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "UpdateTableItemRequest": {
        "type": "object",
        "description": "Body for PUT/PATCH on a table item. Only fields present in `data` are written (omitted optional columns keep their existing values). PUT still validates required fields as present in `data`; PATCH validates only the fields supplied. Optional `expectedUpdatedAt` enables optimistic concurrency: the update succeeds only if the row's `updatedAt` still matches the value the client last read.\n",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "description": "The field values to write, keyed by field name. Only the keys present are changed; a key set to null clears that field. A reference to workspace users may be written as the `CurrentUserValue` token, stored as the caller's id.",
            "type": "object",
            "additionalProperties": {}
          },
          "expectedUpdatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When set, the server updates the row only if its current `updated_at` still matches this timestamp (millisecond precision). On mismatch the API returns 409 with code `STALE_RECORD` and changes nothing. Omit for last-write-wins (the default).\n"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "description": "Sandbox workspaces only. When this write moves a designated stage field, the transition is recorded as having happened at this instant instead of now — it must not be in the future and not earlier than the record's latest recorded transition for that field (400 `OCCURRED_AT_OUT_OF_ORDER`), so every timeline stays in order. Ignored when nothing stage-designated moves. A production workspace refuses it (400 `OCCURRED_AT_NOT_ALLOWED`)."
          }
        }
      },
      "StageMachine": {
        "type": "object",
        "description": "The transition rules themselves. Everything here is optional: the default (`transitionPolicy: any` and nothing else) is a stage field with no restrictions, which is what designation gives you until you add rules.",
        "properties": {
          "transitionPolicy": {
            "type": "string",
            "x-known-values": "KnownTransitionPolicy",
            "description": "`any` — no matrix; a record may move between any active values. `matrix` — `transitions` is an explicit allow-map and anything not listed is **denied**.\n\nOpen vocabulary: clients must tolerate a policy this build does not know. A policy the SERVER does not recognise blocks every transition rather than allowing them — an unreadable rule must never read as \"no rule\". Writes are validated against the known set."
          },
          "transitions": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "description": "Allowed moves, keyed by the value being left: `{\"qualified\": [\"proposal\", \"closed_lost\"]}`. Only consulted when `transitionPolicy` is `matrix`, where it is default-deny — a value absent from the map has no exits at all, which is how you freeze a stage. Every value named here must be one of the field's options."
          },
          "transitionActors": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/components/schemas/TransitionActorGate"
              }
            },
            "description": "WHOSE move each edge is — a sibling map keyed `{from: {to: gate}}` so the stored `transitions` shape never changes. An edge absent from this map is unrestricted (consistent with `initialStages: null` meaning \"any\"): the matrix says the edge exists, `transitionActors` says whose move it is, and approval rules say who signs it off — three independent questions. Applies whatever the `transitionPolicy` is. A gate the server cannot read fails CLOSED, blocking that move and naming what was not understood, exactly as an unknown `transitionPolicy` does. First-set (`null → value`) and clearing are never actor-gated — there is no edge in this map to look up. The caller matches when they hold any named role (via role assignment; system roles cannot be named — use a custom role or a group) or belong to any named group. The approvals APPLY path is exempt: it runs as the system, authorised by the decision itself."
          },
          "initialStages": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "The values a record may START at — the first time the field is set, whether that is at creation or later. `null` (the default) means any active option. This is governed here and never by the matrix: there is no value being left, so there is no edge to look up."
          },
          "allowClear": {
            "type": "boolean",
            "description": "Whether the field may be emptied once set. Defaults to true. Only reachable on a field that is not required anyway."
          },
          "stageRequirements": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "requiredFields": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "fieldName values that must hold a value. A requirement names required fields, a `rule`, or both."
                },
                "rule": {
                  "type": "string",
                  "maxLength": 500,
                  "description": "A true/false expression in the formula grammar that must hold for a record to enter the stage, e.g. `lines_without_department = 0`. Unlike `condition`, it may read derived fields (rollups, lookups, formulas), which are read live from the record when the write moves into the stage; a create reads them as null. It must be TRUE: false or unknown (a null operand) refuses the move. It is checked only on a write that moves the record into the stage (or creates it there), never on later writes while it sits there. It applies whatever the requirement's `condition` says: the condition decides only whether the required fields are required. An import that would move a record into a stage with a rule refuses that row, and a record-graph write may move a record into such a stage only as its sole operation. A field the rule reads cannot be deleted while the rule names it."
                },
                "ruleMessage": {
                  "type": "string",
                  "maxLength": 200,
                  "description": "What the rule asks for, completing \"stage '<value>' needs …\", e.g. `every line to have a department`. Absent, the refusal quotes the rule."
                },
                "condition": {
                  "type": "string",
                  "description": "When the fields are required, as a true/false expression in the formula grammar over the record's own fields — the language a check constraint's expression is written in: `deal_type = 'enterprise'`, `amount >= 10000 and not is_null(region)`. Absent, the fields are always required in the stage. Judged on the record as it will be after the write, together with the fields themselves; a write that changes a field the condition reads is checked too. An unknown result (a null operand) does not bind. Field names are written as they are (no display labels); comparisons, and/or/not, arithmetic and the functions if, coalesce, nullif, is_null, and, or, not, lower, upper, trim, length, contains, starts_with, abs, round, floor, ceil, least and greatest are available. A condition that does not compile to true/false, reads no field, or uses anything else is refused."
                }
              }
            },
            "description": "Fields that must be filled in before a record may sit in a stage, keyed by stage value — always, or only when the entry's `condition` holds.\n\nEvaluated against the record as it will be AFTER the write, not against what the request contained — so moving into the stage fails when the stored row is missing one, and clearing a required field while in the stage fails too. A write touching neither the stage nor a required field (nor a field the condition reads) is unaffected, so adding a requirement never retroactively freezes records already in the stage.\n\nOnly fields a person can fill in may be named: computed columns are rejected, since the user would have nothing to act on."
          },
          "valueSet": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StageValue"
            },
            "description": "The vocabulary of a **computed** stage source, in process order — a formula's output has no option list to read, so it is declared here. Forbidden on a picklist source, which takes its vocabulary from the field's own options; declaring it in two places could only ever disagree.\n\nAdvisory rather than binding: nothing constrains a formula's output to this set, so a value that is not in it resolves to an implicit \"Unknown\" entry (category `open`, ordered last) rather than being dropped or silently merged into a declared one."
          }
        }
      },
      "StageDescriptorValue": {
        "type": "object",
        "description": "One resolved value of a stage's vocabulary — the storage-independent view a board or report reads.",
        "required": [
          "value",
          "label",
          "category",
          "isActive",
          "isUnknown"
        ],
        "properties": {
          "value": {
            "description": "The stored stage value — what a record's stage field holds and what filters and transitions name.",
            "type": "string"
          },
          "label": {
            "type": "string",
            "description": "Falls back to `value` when none was configured."
          },
          "color": {
            "description": "Display colour configured for this value, as authored on the picklist option or computed value set; null when none was set.",
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "description": "What being in this value means, as authored on the picklist option or computed value set; null when none was written. Prose, never evaluated — the enforced rules for entering the value are the machine's `stageRequirements`.",
            "type": [
              "string",
              "null"
            ]
          },
          "category": {
            "type": "string",
            "x-known-values": "KnownStageCategory",
            "description": "Unknown categories read as `open`."
          },
          "clock": {
            "type": "string",
            "x-known-values": "KnownStageClock",
            "description": "`running` or `paused` — whether time in this value counts toward `<stageField>.activeSeconds`. Absent reads as `running`."
          },
          "isActive": {
            "type": "boolean",
            "description": "False for a retired picklist option — a lane that still holds records but can no longer be moved into. Always true for a computed value, which has no retirement concept."
          },
          "isUnknown": {
            "type": "boolean",
            "description": "True only for the synthetic entry a record falls into when its value is not in the vocabulary. Never stored and never declared: a computed source's `valueSet` is advisory, so this is where a value the formula produced but nobody listed shows up, rather than being dropped."
          }
        }
      },
      "StageValue": {
        "type": "object",
        "description": "One declared value of a computed stage source's vocabulary.",
        "required": [
          "value"
        ],
        "properties": {
          "value": {
            "type": "string",
            "description": "The exact string the formula produces."
          },
          "label": {
            "type": "string",
            "description": "How it reads to a person; falls back to `value`."
          },
          "color": {
            "type": "string",
            "description": "Display colour, for boards and chips."
          },
          "description": {
            "type": "string",
            "maxLength": 280,
            "description": "What this value means, in a sentence or two — the same prose a picklist option's `description` carries. Optional; never evaluated."
          },
          "category": {
            "type": "string",
            "x-known-values": "KnownStageCategory",
            "description": "`open` (default), `terminal_success`, or `terminal_failure`. Open vocabulary — an unknown category reads as `open`."
          },
          "clock": {
            "type": "string",
            "x-known-values": "KnownStageClock",
            "description": "`running` (default) or `paused` — whether time in this value counts toward `<stageField>.activeSeconds`, exactly as on a picklist option. Open vocabulary — an unknown clock reads as `running`."
          }
        }
      },
      "StageConfig": {
        "type": "object",
        "description": "Designates one field as a lifecycle (\"stage\") field and carries its machine. One row per designated field; a table may designate several fields independently. There is no separate pipeline object — designating a field IS creating this, and undesignating is deleting it, with no data migration either way.",
        "required": [
          "id",
          "tableId",
          "sourceKind",
          "config",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Identifier of this stage designation. Distinct from the field's id: deleting the designation removes this row and leaves the field and its data untouched.",
            "type": "string"
          },
          "tableId": {
            "description": "The table whose field this designation governs — the `{tableId}` of the stage-config endpoints.",
            "type": "string"
          },
          "fieldId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The stored picklist field this machine governs — the `sourceKind = picklist` case."
          },
          "derivedFieldId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The computed column this machine reads (`sourceKind: computed`). Exactly one of `fieldId` / `derivedFieldId` is ever set. Computed sources are not accepted yet — the shape ships now so they are additive later."
          },
          "sourceKind": {
            "type": "string",
            "x-known-values": "KnownStageSourceKind",
            "description": "Where the stage value comes from: `picklist` (a stored option list) or `computed` (a formula-derived column). Open vocabulary — clients must tolerate a kind they do not know. A kind the server does not recognise is treated as unusable rather than guessed at."
          },
          "config": {
            "$ref": "#/components/schemas/StageMachine"
          },
          "values": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StageDescriptorValue"
            },
            "description": "The **descriptor**: this stage's values in canonical order, however they are stored. A picklist source resolves it from the field's own options, a computed source from its declared `valueSet` — so a client can lay out lanes, colour chips and decide what counts as finished without knowing which it is looking at."
          },
          "writable": {
            "type": "boolean",
            "description": "Whether the stage can be SET directly. False for a computed source, whose value is a consequence of other fields: a board must not offer a drag it could not carry out, since mapping a drop back to \"which driver field do we write?\" has no single answer."
          },
          "createdAt": {
            "description": "When the field was designated as a stage field, ISO-8601 UTC. Transition history is recorded from this point on (or from a snapshot).",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the machine was last saved through `PUT …/stage-config`, ISO-8601 UTC; equals `createdAt` until the first change.",
            "type": "string",
            "format": "date-time"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Non-blocking advice from the last save (e.g. an end-state value that still has outgoing edges — legal, since reopening is normal, but usually not what was meant). Present on the PUT response only."
          },
          "snapshotted": {
            "type": "integer",
            "minimum": 0,
            "description": "Baseline transitions written because the request set `snapshotExisting`. Present on the PUT response only, and only when the flag was set."
          }
        }
      },
      "StageConfigRequest": {
        "type": "object",
        "description": "Full replacement of a field's stage machine.",
        "properties": {
          "sourceKind": {
            "type": "string",
            "x-known-values": "KnownStageSourceKind",
            "description": "Where the stage's value comes from. `picklist` (the default on a\nfield's stage config) reads a stored option list. `computed` reads\na formula column: set it on a `formula` field, or designate a\nstored text formula column through\n`PUT /tables/{tableId}/derived-fields/{derivedFieldId}/stage-config`,\nwhere `computed` is the default and the only accepted value.\n"
          },
          "config": {
            "$ref": "#/components/schemas/StageMachine"
          },
          "snapshotExisting": {
            "type": "boolean",
            "description": "Optional, false when omitted. Also write a baseline transition for every existing record whose value for this field is set and that has no history for it yet: `fromValue` null, `toValue` the current value, `source` `snapshot`, timestamped now. Records that predate the machine then have a bounded `enteredAt` (\"in this stage since at least designation\") and their first real move is measurable, instead of an empty timeline. Idempotent — records already carrying any transition for the field are left alone — so it is also safe on a re-PUT. Picklist sources only. Default false keeps the old semantics: history starts at designation, nothing is backfilled."
          },
          "snapshotDating": {
            "$ref": "#/components/schemas/StageSnapshotDating"
          }
        }
      },
      "StageSnapshotDating": {
        "type": "object",
        "description": "Date the baseline from the record's own fields instead of now, so\nrecords that predate the machine get a real timeline (cycle time,\naging) rather than \"entered this stage at designation\". Implies\n`snapshotExisting`. Every named field must be a date or datetime\nfield of the table; every key of `stages` an option value of the\nstage field. Picklist sources only.\n",
        "properties": {
          "at": {
            "type": "string",
            "description": "The field naming when the record entered its CURRENT value; a record whose value is null is dated at its creation instead."
          },
          "stages": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Stage value → the field naming when the record entered that stage. One earlier move per mapped stage whose field is set, in date order, before the move into the current value (which is never dated before the last mapped move). A record whose latest mapped stage is its current value gets no extra row."
          }
        }
      },
      "StageSnapshotRequest": {
        "description": "Request body of `POST /tables/{tableId}/fields/{fieldId}/stage-config/snapshot`: optionally dates the baseline stage history from the records' own date fields instead of now. An empty body dates it now.",
        "type": "object",
        "properties": {
          "snapshotDating": {
            "$ref": "#/components/schemas/StageSnapshotDating"
          }
        }
      },
      "StageSnapshotResult": {
        "description": "Response of `POST /tables/{tableId}/fields/{fieldId}/stage-config/snapshot`: how many baseline stage transitions this call wrote for records that had no history yet. Zero on a re-run.",
        "type": "object",
        "required": [
          "inserted"
        ],
        "properties": {
          "inserted": {
            "type": "integer",
            "minimum": 0,
            "description": "Baseline rows written by this call."
          }
        }
      },
      "StageTransitionSeedEntry": {
        "description": "One historical stage transition to import: a record entered `toValue` in the stage field at `occurredAt`. Item of `StageTransitionSeedRequest.entries`.",
        "type": "object",
        "required": [
          "itemId",
          "fieldName",
          "toValue",
          "occurredAt"
        ],
        "properties": {
          "itemId": {
            "description": "The record whose stage history the transition belongs to.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "fieldName": {
            "type": "string",
            "description": "The designated (picklist) stage field's name."
          },
          "toValue": {
            "type": [
              "string",
              "null"
            ],
            "description": "The value entered at `occurredAt`; null for a clear."
          },
          "occurredAt": {
            "description": "When the record entered `toValue`, ISO-8601 UTC. Entries are ordered by this to rebuild the record's timeline.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "StageTransitionSeedRequest": {
        "description": "Request body of `POST /tables/{tableId}/stage-transitions/seed`: backdated stage moves for records that already exist, written as history in one transaction. With `source` `seeded` (the default) it is the sandbox-only way demo data gets a believable timeline; with `source` `import` it is a migration carrying a system's real history over, allowed on any workspace for a principal holding `records:backfillHistory`.",
        "type": "object",
        "required": [
          "entries"
        ],
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "seeded",
              "import"
            ],
            "default": "seeded",
            "description": "How the rows are labelled and who may write them: `seeded` (demo history; sandbox workspaces only, `fields:manage`) or `import` (history migrated from another system; any workspace, needs `records:backfillHistory` as well as `fields:manage`)."
          },
          "entries": {
            "description": "The moves to record, 1 to 500. Entries for the same record and field are applied in `occurredAt` order and the last one must land on the value the record holds now.",
            "type": "array",
            "minItems": 1,
            "maxItems": 500,
            "items": {
              "$ref": "#/components/schemas/StageTransitionSeedEntry"
            }
          },
          "replace": {
            "type": "boolean",
            "default": false,
            "description": "Remove each named record's existing `import` and `seeded` rows for the field before writing, in the same transaction, so a table whose records already carry an import-time baseline can be backdated. Rows a live write produced (`api`, `automation`, …) are never removed: a chain that would have to precede one is refused as out of order. Sandbox workspaces only, with either `source` (400 `SANDBOX_ONLY` elsewhere); the call is audited like every write."
          }
        }
      },
      "StageTransitionSeedResult": {
        "description": "Response of `POST /tables/{tableId}/stage-transitions/seed`: how many backdated transition rows the seed call wrote, and — with `replace` — how many it removed first.",
        "type": "object",
        "required": [
          "inserted"
        ],
        "properties": {
          "inserted": {
            "type": "integer",
            "minimum": 0,
            "description": "Transition rows written, all with the request's `source` (`seeded` by default)."
          },
          "replaced": {
            "type": "integer",
            "minimum": 0,
            "description": "`import` and `seeded` rows removed before writing. Present only when the request passed `replace: true`."
          }
        }
      },
      "SandboxDateShiftRequest": {
        "type": "object",
        "description": "Exactly one of `days` and `anchorField`. Field references are `table.field` using the table's and field's names (not display names); `created_at` and `updated_at` are accepted as anchor fields.",
        "properties": {
          "days": {
            "type": "integer",
            "minimum": -36500,
            "maximum": 36500,
            "description": "Days to add to every date; negative moves the workspace back in time."
          },
          "anchorField": {
            "type": "string",
            "maxLength": 520,
            "description": "`table.field`: the field whose latest non-null value (over live records) should land on `anchorTo`. The shift is the difference, in days, between the two."
          },
          "anchorTo": {
            "type": "string",
            "format": "date",
            "description": "Where the anchor lands, `YYYY-MM-DD`. Today, in the workspace time zone, when omitted."
          },
          "alignWeeks": {
            "type": "boolean",
            "description": "Round a computed shift to the nearest whole number of weeks, so every date keeps its weekday. Defaults to true with an anchor. With an explicit `days`, `true` requires a multiple of 7."
          },
          "excludeFields": {
            "type": "array",
            "maxItems": 200,
            "items": {
              "type": "string",
              "maxLength": 520
            },
            "description": "`table.field` dates that stay exactly as they are."
          },
          "dryRun": {
            "type": "boolean",
            "description": "Report the shift and what it would touch without writing anything."
          }
        }
      },
      "SandboxDateShiftResult": {
        "description": "Response of `POST /workspace/sandbox/shift-dates`: the shift that was applied (or, on a dry run, computed) and a per-table account of the fields and rows it moved or would move.",
        "type": "object",
        "required": [
          "days",
          "dryRun",
          "tables",
          "stageTransitions"
        ],
        "properties": {
          "days": {
            "type": "integer",
            "description": "The shift applied (or, on a dry run, computed), in days."
          },
          "dryRun": {
            "description": "True when the request only computed the shift and nothing was written; `days` and `tables` then describe what a real run would do.",
            "type": "boolean"
          },
          "anchor": {
            "$ref": "#/components/schemas/SandboxDateShiftAnchor"
          },
          "tables": {
            "description": "Every table in the workspace, with the date and datetime fields that were (or would be) moved and the number of rows affected.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SandboxDateShiftTable"
            }
          },
          "stageTransitions": {
            "type": "integer",
            "minimum": 0,
            "description": "Stage transition rows whose `created_at` moved."
          }
        }
      },
      "SandboxDateShiftAnchor": {
        "type": "object",
        "description": "Present when the shift was computed from an anchor field.",
        "required": [
          "field",
          "latest",
          "landsOn"
        ],
        "properties": {
          "field": {
            "type": "string",
            "description": "The `table.field` the shift was computed from."
          },
          "latest": {
            "type": "string",
            "format": "date",
            "description": "The latest value that field held before the shift, as a date in the workspace time zone."
          },
          "landsOn": {
            "type": "string",
            "format": "date",
            "description": "The date that value holds after the shift — `anchorTo`, or within three days of it when the shift was aligned to whole weeks."
          }
        }
      },
      "SandboxDateShiftTable": {
        "description": "One table touched by a sandbox date shift, as listed in `SandboxDateShiftResult.tables`: which of its date fields moved and how many records were affected.",
        "type": "object",
        "required": [
          "table",
          "fields",
          "rows"
        ],
        "properties": {
          "table": {
            "type": "string",
            "description": "Table name."
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The date and datetime fields moved, by name. System timestamps move whether or not this is empty."
          },
          "rows": {
            "type": "integer",
            "minimum": 0,
            "description": "Records in the table (every one moves, live and deleted alike)."
          }
        }
      },
      "StageHistoryEntry": {
        "type": "object",
        "description": "One recorded move of a stage field.",
        "required": [
          "id",
          "fieldId",
          "fromValue",
          "toValue",
          "source",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Identifier of this transition row.",
            "type": "string"
          },
          "fieldId": {
            "type": "string",
            "description": "The stage field that moved."
          },
          "fieldName": {
            "type": "string",
            "description": "Its column name, so a client need not join back to the field list."
          },
          "fromValue": {
            "type": [
              "string",
              "null"
            ],
            "description": "The value left behind; null when this was the first time the stage was set."
          },
          "toValue": {
            "type": [
              "string",
              "null"
            ],
            "description": "The value moved to; null when the stage was cleared."
          },
          "source": {
            "type": "string",
            "description": "Which write surface made the move — `api`, `import`, `automation`, `apply`, … Open vocabulary and descriptive only; never dispatch on it. Two values mark rows that are not live moves: `snapshot` (a baseline `null → current` written at designation or by the snapshot endpoint, dated when it was written) and `seeded` (a backdated move written through the sandbox-only seed endpoint, dated by the caller)."
          },
          "actorType": {
            "type": [
              "string",
              "null"
            ],
            "description": "Principal kind that acted (`user`, `api_token`, `automation`, `system`)."
          },
          "actorId": {
            "description": "Id of the principal that made the move, in the id space `actorType` names (a user id, API token id or flow id). Null when no actor was recorded.",
            "type": [
              "string",
              "null"
            ]
          },
          "actorOnBehalfOfUserId": {
            "type": [
              "string",
              "null"
            ],
            "description": "For automation- or system-attributed moves, the user whose action set the chain off."
          },
          "createdAt": {
            "description": "When the move happened, ISO-8601 UTC. For `snapshot` rows it is when the baseline was written; for `seeded` rows it is the date the caller supplied.",
            "type": "string",
            "format": "date-time"
          },
          "durationMs": {
            "type": [
              "integer",
              "null"
            ],
            "description": "How long the record sat in `fromValue` before this move — the gap since the previous recorded transition. Null on the earliest recorded entry, where the previous move is unknown rather than zero."
          }
        }
      },
      "StageCycleTime": {
        "type": "object",
        "description": "How long this record took to first reach an end state on one stage field. \"End state\" is decided by the option's `category` (`terminal_success`/`terminal_failure`), never by matching particular values, so renaming Won/Lost keeps the number correct.",
        "required": [
          "fieldId",
          "value",
          "reachedAt",
          "elapsedMs"
        ],
        "properties": {
          "fieldId": {
            "description": "The stage field this cycle time is measured on.",
            "type": "string"
          },
          "fieldName": {
            "description": "Name of that stage field, for display.",
            "type": "string"
          },
          "value": {
            "type": "string",
            "description": "The end-state value first reached."
          },
          "reachedAt": {
            "description": "When the record first entered an end-state option of the field, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "elapsedMs": {
            "type": "integer",
            "description": "From the record's creation to `reachedAt`. Measured against record creation rather than the first recorded transition, so it stays meaningful for records that predate the stage machine (history is not backfilled)."
          }
        }
      },
      "FieldAggregates": {
        "type": "object",
        "description": "Per-option-value aggregates over the caller-visible records of one table.",
        "required": [
          "groupBy",
          "rows"
        ],
        "properties": {
          "groupBy": {
            "type": "string",
            "description": "The grouping field's fieldName, echoed."
          },
          "sum": {
            "type": [
              "string",
              "null"
            ],
            "description": "The summed field's fieldName, when one was requested."
          },
          "rows": {
            "description": "One row per distinct value of the grouping field (including an empty-value row), each with its record count and, when requested, its sum.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FieldAggregateRow"
            }
          }
        }
      },
      "FieldAggregateRow": {
        "description": "One group in a per-option aggregate: an option value of the grouping field with the number of caller-visible records holding it and, when requested, the sum of a numeric field over them. Item of `FieldAggregates.rows`.",
        "type": "object",
        "required": [
          "value",
          "count"
        ],
        "properties": {
          "value": {
            "type": [
              "string",
              "null"
            ],
            "description": "The option value, or null for records where the field is empty."
          },
          "count": {
            "description": "Number of caller-visible records in the table whose grouping field holds `value`.",
            "type": "integer"
          },
          "sum": {
            "type": [
              "number",
              "null"
            ],
            "description": "Sum of the requested numeric field over the group; null when no row in the group carries a value (SQL sum semantics), absent when no `sum` was requested."
          }
        }
      },
      "RecordAggregateFn": {
        "type": "string",
        "enum": [
          "count",
          "sum",
          "avg",
          "min",
          "max"
        ],
        "description": "An aggregate over the caller-visible records of a table. `count` needs no field; `sum`/`avg` need a numeric field (integer, number, currency, percent, duration, rating); `min`/`max` accept a numeric or date/time field."
      },
      "RecordAggregateMetric": {
        "type": "object",
        "description": "One aggregated column of a record aggregate.",
        "required": [
          "fn"
        ],
        "properties": {
          "fn": {
            "$ref": "#/components/schemas/RecordAggregateFn"
          },
          "field": {
            "type": "string",
            "maxLength": 255,
            "description": "fieldName of the field aggregated; omitted for `count`."
          },
          "alias": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "pattern": "^[a-z][a-z0-9_]*$",
            "description": "The result column's name. Defaults to the function for `count` and `<fn>_<field>` otherwise."
          }
        }
      },
      "RecordAggregateBucket": {
        "type": "string",
        "enum": [
          "day",
          "week",
          "month",
          "quarter",
          "year"
        ],
        "description": "How a date or datetime grouping field is bucketed."
      },
      "RecordAggregateGroupBy": {
        "type": "object",
        "description": "The dimension of a record aggregate: one row per distinct value of `field` (an empty value is one `null` bucket). A date or datetime field is bucketed by `bucket` (default `month`) and reported as the bucket's first day, `YYYY-MM-DD`; a picklist, text, email, url, phone or boolean field groups on its value.",
        "required": [
          "field"
        ],
        "properties": {
          "field": {
            "description": "Internal name of the field to group by; must be readable by the caller.",
            "type": "string",
            "maxLength": 255
          },
          "bucket": {
            "$ref": "#/components/schemas/RecordAggregateBucket"
          }
        }
      },
      "RecordAggregateSpec": {
        "type": "object",
        "description": "A structured aggregate over one table's records, executed through the record read path — the caller's row scope is applied before grouping and every field named must be readable by them, so the numbers describe exactly the records they could list. This is the query a chart runs when it is drawn for viewers whose record visibility is restricted, for whom raw SQL is unavailable (`POST /query`). `filter` is AND-ed onto the caller's row scope like the items list's `filter` parameter and can only narrow it.",
        "required": [
          "metrics"
        ],
        "properties": {
          "groupBy": {
            "$ref": "#/components/schemas/RecordAggregateGroupBy"
          },
          "metrics": {
            "description": "The aggregates to compute per group, one to five, each naming a function and (except for counts) the readable field it runs over. Results come back in the same order.",
            "type": "array",
            "minItems": 1,
            "maxItems": 5,
            "items": {
              "$ref": "#/components/schemas/RecordAggregateMetric"
            }
          },
          "filter": {
            "$ref": "#/components/schemas/RecordFilter"
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 500,
            "description": "Maximum number of groups returned (ascending by group value); 100 when omitted."
          }
        }
      },
      "RecordAggregateResult": {
        "type": "object",
        "description": "The rows of a record aggregate, keyed by column name — the grouping field's name (when grouped) followed by each metric's alias — in the shape a chart renders directly, with the statement that produced them (`explain`) so a reader can see, and re-run, exactly what the numbers are.",
        "required": [
          "columns",
          "rows",
          "truncated",
          "explain"
        ],
        "properties": {
          "explain": {
            "$ref": "#/components/schemas/RecordAggregateExplain"
          },
          "columns": {
            "description": "The output columns in row order: the group column first when grouped, then one metric column per requested metric, each with its kind and type.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecordAggregateColumn"
            }
          },
          "rows": {
            "description": "One row per group (or a single row when ungrouped), keyed by the column names in `columns`.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QueryResultRow"
            }
          },
          "truncated": {
            "type": "boolean",
            "description": "True when more groups existed than `limit` allowed."
          }
        }
      },
      "RecordAggregateExplain": {
        "type": "object",
        "description": "What a record aggregate ran, stated so a person can review and re-run it: the compiled SQL for the spec with its bound values listed separately, whether the caller's row scope narrowed the rows, and when they were read. The caller's own scope predicate is never part of `sql` or `params` — it is conjoined after the spec is compiled, and the statement here is the spec alone — so two viewers of one chart read the same statement and `scoped` is the only thing that differs. Nothing here says how many records a scope hid.",
        "required": [
          "sql",
          "params",
          "scoped",
          "readAt"
        ],
        "properties": {
          "sql": {
            "type": "string",
            "description": "The SELECT the spec compiled to — the group expression, each metric and the spec's own `filter` — over the table's live (undeleted) rows, with every value as a `$n` placeholder. Runnable as written against the workspace schema once the placeholders are bound from `params`."
          },
          "params": {
            "type": "array",
            "description": "The values bound to the `$n` placeholders of `sql`, in order (`$1` is the first entry). Only the spec's filter contributes values; a spec with no filter has none.",
            "items": {
              "description": "One bound value — a string, number, boolean, null, or a list for a list operator."
            }
          },
          "scoped": {
            "type": "boolean",
            "description": "True when the caller's row scope was applied before grouping, so the rows describe what they can see rather than the whole table. The scope's predicate and the number of records it hid are not reported."
          },
          "readAt": {
            "type": "string",
            "format": "date-time",
            "description": "The server time at which the rows were read."
          }
        }
      },
      "RecordAggregateColumn": {
        "description": "One column of a record aggregate result, in the order the rows' keys appear: the grouping dimension (if grouped) followed by each metric. Item of `RecordAggregateResult.columns`.",
        "type": "object",
        "required": [
          "name",
          "kind"
        ],
        "properties": {
          "name": {
            "description": "The key under which this column's value appears in each row: the grouping field's `fieldName` for the group column, the metric's `alias` for a metric (defaulting to the function name for `count`, `<fn>_<field>` otherwise).",
            "type": "string"
          },
          "kind": {
            "description": "`group` for the dimension column (at most one, first when present); `metric` for an aggregated value.",
            "type": "string",
            "enum": [
              "group",
              "metric"
            ]
          },
          "resultType": {
            "type": "string",
            "description": "The metric's scalar type (`integer`, `number`, `date`, `datetime`, `time`); absent on the group column."
          }
        }
      },
      "RecordReportDimension": {
        "type": "object",
        "description": "One dimension of a record report: one group per distinct value of `field`. A date or datetime field is bucketed by `bucket` (default `month`) and keyed by the bucket's first day, `YYYY-MM-DD`; a picklist, text, email, url, phone, boolean, whole-number or rating field groups on its value; a single-valued reference field groups on the referenced record's id (a client labels it through the field's reference options, under its own scope on the referenced table); a lookup field groups on the value it resolves to, when the caller may read its source. An empty value is one `null` group.",
        "required": [
          "field"
        ],
        "properties": {
          "field": {
            "type": "string",
            "maxLength": 255,
            "description": "Internal name of the field to group by; must be readable by the caller."
          },
          "bucket": {
            "$ref": "#/components/schemas/RecordAggregateBucket"
          }
        }
      },
      "RecordReportSpec": {
        "type": "object",
        "description": "A grouped report over one table's records (#1075): the same row-scoped, field-masked execution as `RecordAggregateSpec` — the caller's row scope is applied before grouping and every field named must be readable by them — over one to three dimensions at once, with a subtotal row per level and a grand total, so a numeric field reads broken down by segment × tier × geography without SQL. `filter` is AND-ed onto the caller's row scope and can only narrow it. Not available for a table of kind `view`.",
        "required": [
          "dimensions",
          "metrics"
        ],
        "properties": {
          "dimensions": {
            "type": "array",
            "minItems": 1,
            "maxItems": 3,
            "description": "The grouping dimensions, outermost first; a row's `keys` follow this order.",
            "items": {
              "$ref": "#/components/schemas/RecordReportDimension"
            }
          },
          "metrics": {
            "description": "The aggregates computed per group, one to five, each naming a function and (except for counts) the readable field it runs over, as in a record aggregate.",
            "type": "array",
            "minItems": 1,
            "maxItems": 5,
            "items": {
              "$ref": "#/components/schemas/RecordAggregateMetric"
            }
          },
          "filter": {
            "$ref": "#/components/schemas/RecordFilter"
          },
          "subtotals": {
            "type": "boolean",
            "description": "Whether the result carries a subtotal row for every group above the leaves and a grand total row (`true` when omitted). With `false` only the leaf groups are returned."
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2000,
            "description": "Maximum rows returned, subtotals included, in report order; 500 when omitted."
          }
        }
      },
      "RecordReportDimensionColumn": {
        "type": "object",
        "description": "One dimension of a report result, with what a client needs to read its keys.",
        "required": [
          "field",
          "fieldType"
        ],
        "properties": {
          "field": {
            "type": "string",
            "description": "The dimension field's internal name, as the request named it."
          },
          "fieldType": {
            "type": "string",
            "description": "The field's type, which says how a key reads: a picklist value, a date bucket's first day, a referenced record's id, a lookup's resolved value."
          },
          "bucket": {
            "$ref": "#/components/schemas/RecordAggregateBucket"
          }
        }
      },
      "RecordReportRow": {
        "type": "object",
        "description": "One group of a report. `depth` says how many leading `keys` are the group's own: a leaf row has every key, a subtotal row the first `depth` with `null` beyond, and the grand total has `depth` 0. A key within `depth` may itself be `null` — the \"unset\" group — which is why `depth`, not the keys, says what level a row is.",
        "required": [
          "depth",
          "keys",
          "values"
        ],
        "properties": {
          "depth": {
            "type": "integer",
            "minimum": 0,
            "description": "How many leading dimensions this row is grouped by: the number of dimensions for a leaf, 0 for the grand total."
          },
          "keys": {
            "type": "array",
            "description": "The dimension values, one per dimension in request order; `null` for an unset value and for every position beyond `depth`.",
            "items": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "values": {
            "type": "object",
            "additionalProperties": true,
            "description": "The metric values, keyed by the metric column names in `metrics`, as JSON scalars."
          }
        }
      },
      "RecordReportResult": {
        "type": "object",
        "description": "The rows of a record report in report order: the grand total first (when subtotals are on), then each outermost group's subtotal followed by its inner groups down to the leaves, groups ordered by key with the unset group last.",
        "required": [
          "dimensions",
          "metrics",
          "rows",
          "truncated"
        ],
        "properties": {
          "dimensions": {
            "type": "array",
            "description": "The dimensions as resolved, in the order the rows' `keys` follow.",
            "items": {
              "$ref": "#/components/schemas/RecordReportDimensionColumn"
            }
          },
          "metrics": {
            "type": "array",
            "description": "One entry per metric in request order (each of kind `metric`), naming the key under which every row's `values` carries it.",
            "items": {
              "$ref": "#/components/schemas/RecordAggregateColumn"
            }
          },
          "rows": {
            "type": "array",
            "description": "The report's rows, in report order.",
            "items": {
              "$ref": "#/components/schemas/RecordReportRow"
            }
          },
          "truncated": {
            "type": "boolean",
            "description": "True when more rows existed than `limit` allowed."
          }
        }
      },
      "DedupeKey": {
        "type": "object",
        "description": "A field whose values identify a record, so two records sharing one are worth a second look. Keys are derived from the table's own schema — never configured separately — either because the field carries an identifying type (`email`, `phone`, `url`) or because an admin marked it unique in a type whose values can still differ by case or spacing.",
        "required": [
          "fieldName",
          "displayName",
          "fieldType",
          "kind",
          "reason"
        ],
        "properties": {
          "fieldName": {
            "description": "Internal name of the field, as it appears as a key in record values.",
            "type": "string"
          },
          "displayName": {
            "description": "Human-readable label of the field, for showing the key to a user.",
            "type": "string"
          },
          "fieldType": {
            "description": "The field's type (`email`, `phone`, `url`, `text`, …), which is what made it a key when `reason` is `semantic-type`.",
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "email",
              "phone",
              "url",
              "text"
            ],
            "description": "How values of this key are folded before comparison: `phone` keeps only digits, every other kind lower-cases and trims."
          },
          "reason": {
            "type": "string",
            "enum": [
              "semantic-type",
              "unique-field"
            ],
            "description": "Why this field is a key — so a result can explain itself."
          }
        }
      },
      "DuplicateRecordSummary": {
        "type": "object",
        "description": "One record in a duplicate result, carrying just the dedupe-key values the caller may read — enough to recognise the row before opening it.",
        "required": [
          "id",
          "values"
        ],
        "properties": {
          "id": {
            "description": "The record's id, to open it or feed it to a merge.",
            "type": "string"
          },
          "values": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "Key values as stored (not folded), by field name."
          }
        }
      },
      "DuplicateMatch": {
        "type": "object",
        "description": "One key on which a candidate value collides with existing records.",
        "required": [
          "fieldName",
          "normalizedValue",
          "records",
          "truncated"
        ],
        "properties": {
          "fieldName": {
            "description": "Column name of the dedupe key the candidate collided on — one of the entries in `DuplicateCheckResult.checkedFields`.",
            "type": "string"
          },
          "normalizedValue": {
            "type": "string",
            "description": "The folded value the candidate and the records share."
          },
          "records": {
            "description": "The existing records sharing `normalizedValue` on this key, limited to those the caller may read. Capped; `truncated` says whether more matched than are listed.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DuplicateRecordSummary"
            }
          },
          "truncated": {
            "type": "boolean",
            "description": "True when more records matched than are listed."
          }
        }
      },
      "DuplicateGroup": {
        "type": "object",
        "description": "Records that already share one folded value of one key.",
        "required": [
          "fieldName",
          "normalizedValue",
          "count",
          "records",
          "truncated"
        ],
        "properties": {
          "fieldName": {
            "description": "Name of the dedupe-key field whose values collide.",
            "type": "string"
          },
          "normalizedValue": {
            "description": "The folded form the records share: trimmed and lower-cased for text keys, digits only for phone keys. Use `records[].values` for the values as actually stored.",
            "type": "string"
          },
          "count": {
            "type": "integer",
            "description": "How many records share it, including any beyond `records`."
          },
          "records": {
            "description": "The records that share the value, each with the key values the caller may read. Capped; `count` and `truncated` say whether there are more.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DuplicateRecordSummary"
            }
          },
          "truncated": {
            "type": "boolean",
            "description": "True when `count` exceeds the records listed."
          }
        }
      },
      "DuplicateCheckRequest": {
        "type": "object",
        "description": "A candidate record to test against what is already there. Only the dedupe-key fields are read; anything else in `values` is ignored, so a whole draft record can be posted as-is.",
        "required": [
          "values"
        ],
        "properties": {
          "values": {
            "type": "object",
            "additionalProperties": true,
            "description": "Candidate field values by field name."
          },
          "excludeItemId": {
            "type": "string",
            "description": "The record being edited, which is never reported as a duplicate of itself."
          }
        }
      },
      "DuplicateCheckResult": {
        "description": "Response of `POST /tables/{tableId}/duplicates/check`: which dedupe keys were compared and, per key, the existing records a candidate collides with. An empty `matches` means no duplicate was found on the keys that were checked.",
        "type": "object",
        "required": [
          "keys",
          "checkedFields",
          "matches"
        ],
        "properties": {
          "keys": {
            "type": "array",
            "description": "The table's dedupe keys the caller may read.",
            "items": {
              "$ref": "#/components/schemas/DedupeKey"
            }
          },
          "checkedFields": {
            "type": "array",
            "description": "The keys the candidate actually supplied a usable value for — a key absent here was not compared, because the candidate left it blank.",
            "items": {
              "type": "string"
            }
          },
          "matches": {
            "description": "One entry per dedupe key on which the candidate's value collides with existing records; keys with no collision are absent. Empty when the candidate is clear.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DuplicateMatch"
            }
          }
        }
      },
      "DuplicateScanResult": {
        "description": "Response of `GET /tables/{tableId}/duplicates`: the dedupe keys the table was scanned on and the groups of records that collide on one, largest first, with an exact count of groups the cap left out.",
        "type": "object",
        "required": [
          "keys",
          "groups",
          "groupsOmitted"
        ],
        "properties": {
          "keys": {
            "description": "The dedupe keys the scan compared records on, derived from the table's schema (identifying field types and case-insensitive unique fields). Empty when the table has none, in which case `groups` is empty too.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DedupeKey"
            }
          },
          "groups": {
            "type": "array",
            "description": "Collisions found, largest first.",
            "items": {
              "$ref": "#/components/schemas/DuplicateGroup"
            }
          },
          "groupsOmitted": {
            "type": "integer",
            "description": "How many further groups were found and not returned, because the per-scan cap was reached — the exact number, not \"at least one\", so a badly duplicated table does not report like a nearly clean one. Zero means the report is complete."
          }
        }
      },
      "ChartRecordSource": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RecordAggregateSpec"
          },
          {
            "type": "object",
            "required": [
              "tableId"
            ],
            "properties": {
              "tableId": {
                "description": "The table whose records the aggregate runs over; the rest of the spec (grouping, metrics, filter) is inherited from `RecordAggregateSpec`.",
                "type": "string",
                "minLength": 12,
                "maxLength": 12,
                "pattern": "^[0-9a-f]{12}$"
              }
            }
          }
        ],
        "description": "A chart drawn from a table's records rather than from SQL: the aggregate is run through `POST /tables/{tableId}/aggregate` for whoever views the chart, so it renders for restricted-visibility viewers with their own row scope applied. Mutually exclusive with `customSql` and a linked saved query."
      },
      "StageEnteredAt": {
        "type": "object",
        "description": "When a record entered the current value of one stage field — the card-aging primitive (PIPELINES_STATE_MACHINES_DESIGN §12.4).",
        "required": [
          "at",
          "approximate"
        ],
        "properties": {
          "at": {
            "description": "When the record entered its current stage value, ISO-8601 UTC — the latest recorded transition into it. When `approximate` is true this is the record's `updatedAt` instead, an upper bound rather than the real entry time.",
            "type": "string",
            "format": "date-time"
          },
          "approximate": {
            "type": "boolean",
            "description": "True when no transition is recorded for the field (history is not backfilled, so records predating their machine have none) and `at`"
          },
          "activeSeconds": {
            "type": "integer",
            "minimum": 0,
            "description": "Whole seconds the record has spent in values whose clock RUNS — every visit, summed from the transition log, the current one up to now — leaving out values marked `clock: paused` and the terminal values. The same quantity a filter or sort reaches as `<stageField>.activeSeconds`. Absent when the entry is `approximate` (no exact history to sum).\nis the record's `updatedAt` instead — an upper bound on time in the gate, not the true entry time."
          }
        }
      },
      "StageHistory": {
        "description": "Response of `GET /tables/{tableId}/items/{itemId}/stage-history`: one page of a record's stage-field transitions, newest first, with a cursor for older ones and whole-record cycle times.",
        "type": "object",
        "required": [
          "entries",
          "nextCursor"
        ],
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StageHistoryEntry"
            },
            "description": "Newest first."
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass as `cursor` for the next (older) page; null when exhausted."
          },
          "cycleTimes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StageCycleTime"
            },
            "description": "One entry per readable stage field the record has closed on; a field it never closed on is simply absent. Whole-record rather than page-scoped, so paging back through the timeline does not change it."
          }
        }
      },
      "StageTransitionFeedEntry": {
        "type": "object",
        "description": "One stage move, with the record it happened to — the payload an integration trigger receives.",
        "required": [
          "id",
          "itemId",
          "fieldId",
          "fromValue",
          "toValue",
          "source",
          "createdAt",
          "record"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the transition row; the watermark cursors are positions among these.",
            "type": "string"
          },
          "itemId": {
            "type": "string",
            "description": "The record that moved."
          },
          "fieldId": {
            "description": "The stage field that moved.",
            "type": "string"
          },
          "fieldName": {
            "description": "Name of that stage field, for display.",
            "type": "string"
          },
          "fromValue": {
            "description": "The stage option value before the move. Null when the record had no value yet, including the `snapshot` baseline rows.",
            "type": [
              "string",
              "null"
            ]
          },
          "toValue": {
            "description": "The stage option value after the move. Null when the stage was cleared.",
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": "string",
            "description": "Which write surface made the move — `api`, `import`, `automation`, `apply`, … Open vocabulary and descriptive only; never dispatch on it. Two values mark rows that are not live moves: `snapshot` (a baseline `null → current` written at designation or by the snapshot endpoint, dated when it was written) and `seeded` (a backdated move written through the sandbox-only seed endpoint, dated by the caller)."
          },
          "actorType": {
            "description": "What kind of principal made the move: `user`, `api_token`, `automation` (a flow) or `system`. Null on rows that recorded no actor.",
            "type": [
              "string",
              "null"
            ]
          },
          "actorId": {
            "description": "Id of that principal by `actorType`: a user id, an API token id, or the flow id for `automation`. Null when none was recorded.",
            "type": [
              "string",
              "null"
            ]
          },
          "actorOnBehalfOfUserId": {
            "description": "When an API token or flow acted for a user, that user's id; null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the move happened, ISO-8601 UTC; for `seeded` rows, the backdated instant the caller supplied.",
            "type": "string",
            "format": "date-time"
          },
          "record": {
            "$ref": "#/components/schemas/TableItem"
          }
        }
      },
      "StageTransitionFeed": {
        "description": "Response of `GET /tables/{tableId}/stage-transitions`: one page of a table's stage moves, oldest first, with the watermark cursors a poller stores to receive each move exactly once.",
        "type": "object",
        "required": [
          "entries",
          "nextCursor",
          "latestCursor",
          "hasMore"
        ],
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StageTransitionFeedEntry"
            },
            "description": "Oldest first, so a poller can process them in the order they happened."
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "The watermark to send as `cursor` next time. Keep it: it is a position in the table's history, not a page boundary, and it stays valid indefinitely. Null only when the table has no stage history at all."
          },
          "latestCursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "The watermark at the END of the whole feed, whatever this page contains. It is how a poller starts from \"now\": store it on the first call and send it as `cursor` from then on, instead of replaying every stage change the table has ever recorded. Null when the table has no stage history at all."
          },
          "hasMore": {
            "type": "boolean",
            "description": "True when more transitions were already waiting behind this page — poll again immediately rather than waiting for the next interval."
          }
        }
      },
      "RecordWriteError": {
        "type": "object",
        "description": "The 400 body of a record write (create, replace, patch and the attachment confirm/remove endpoints) the server refused: a field value that fails its contract, a missing required field, a stage move the field's transition matrix does not allow, or a unique rule another record already satisfies. `details` says what is wrong per field; a stage refusal adds `code` and `transition`, the vocabulary a client needs to both explain the refusal and pre-empt it — a board greys out the columns absent from `allowedTargets` rather than letting the user drag into a rejection — and a unique refusal adds `conflict`, the record the write collides with.\n",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "description": "Human-readable headline of the refusal, ready to show the user: `Validation failed` for an ordinary field problem (the per-field wording is in `details`), the refused move's own sentence for a stage refusal.",
            "type": "string",
            "example": "Stage cannot move from 'closed_won' to 'prospecting'"
          },
          "code": {
            "description": "Machine-readable reason, present when the refusal has one a client is expected to react to: `TRANSITION_NOT_ALLOWED` (the write moves a stage field along an edge its transition matrix does not allow; `transition` says which) or `UNIQUE_VIOLATION` (a unique field or a composite-unique constraint already holds these values; `conflict` names the record). Absent on a plain field-validation refusal. Clients branch on this, not on `error`.",
            "type": "string",
            "enum": [
              "TRANSITION_NOT_ALLOWED",
              "UNIQUE_VIOLATION"
            ]
          },
          "details": {
            "type": "object",
            "description": "What is wrong, per field — the same map `ErrorResponse.details` carries. Each key is the name of the field in `data` the value failed on, or the comma-joined field list of a composite constraint (`\"job,visit_date,engineer\"` for a composite unique; the scope and range of a no-overlap or capacity rule), or the request property the problem belongs to (`occurredAt` for a refused backdate, `data` for a problem no single field explains). The value says what is wrong with it, written to show the user; several problems on one key are joined with `; `.",
            "additionalProperties": {
              "type": "string"
            },
            "example": {
              "last_name": "Field 'Last Name' is required",
              "job,visit_date,engineer": "Fields (job, visit_date, engineer) must be unique together — another row already has these values"
            }
          },
          "transition": {
            "description": "The refused edge in structured form: which stage field, the current and requested values, and every value the record may move to from here.",
            "type": "object",
            "required": [
              "field",
              "allowedTargets"
            ],
            "properties": {
              "field": {
                "type": "string",
                "description": "fieldName of the stage field that refused the move.",
                "example": "stage"
              },
              "from": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The value the record holds now; null when it has none yet."
              },
              "to": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The value the write asked for; null when clearing."
              },
              "allowedTargets": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Every value reachable from `from` under the current rules. Empty means the stage has no exits — a deliberately frozen end state, not a bug."
              }
            }
          },
          "conflict": {
            "$ref": "#/components/schemas/UniqueConflict"
          }
        }
      },
      "UniqueConflict": {
        "type": "object",
        "description": "Carried on a record write's 400 when a unique field or a composite-unique constraint refused it: the record already holding the values, so the client can update that record instead of searching for it, or change the conflicting values. `recordId` and `label` are present only when the caller's row scope lets them read the colliding record; a record they may not see collides anonymously, with `fields` alone.",
        "required": [
          "fields"
        ],
        "properties": {
          "fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "fieldName of each field that must be unique (together) and already holds these values."
          },
          "recordId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "Id of the record holding the values, when the caller may read it."
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "That record's display label, when the caller may read it and the table has one; null when it has none or the caller may not read the label column."
          }
        }
      },
      "TransitionActorGate": {
        "type": "object",
        "description": "Who may make one specific move. The caller passes when they hold ANY of the named roles or belong to ANY of the named groups. At least one list must be non-empty when the gate is present. Role and group ids must exist at save time (dangling references are rejected); system roles cannot be named — name a custom role or a group instead.",
        "properties": {
          "roleIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Custom role ids (roles assigned via role targets)."
          },
          "groupIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Workspace group ids."
          }
        }
      },
      "TransitionNotPermittedError": {
        "type": "object",
        "description": "Returned when a move EXISTS but is not the caller's to make — the edge carries a `transitionActors` gate the caller does not satisfy. Deliberately distinct from `TRANSITION_NOT_ALLOWED` (the move does not exist), the same condition/validator split Jira draws: the client hides moves that are not yours; this error explains a refusal when one is attempted anyway, carrying enough to say whose move it is.",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "description": "Human-readable explanation of the refusal naming the field, the move and who may make it, suitable for showing to the user.",
            "type": "string",
            "example": "Field 'Stage': only the property team may move 'offer' to 'agreed'"
          },
          "code": {
            "description": "Machine-readable discriminator, always `TRANSITION_NOT_PERMITTED`: the move exists but the caller is not among its permitted actors (contrast `TRANSITION_NOT_ALLOWED`).",
            "type": "string",
            "enum": [
              "TRANSITION_NOT_PERMITTED"
            ]
          },
          "details": {
            "description": "What is wrong, per field, in the same shape as a 400 validation failure's `details` (`RecordWriteError.details`): the refused move is keyed by its stage field.",
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "example": {
              "stage": "Field 'Stage': only the property team may move 'offer' to 'agreed'"
            }
          },
          "transition": {
            "description": "The machine-readable half: which stage field, which move, and whose move it is. Only the first refused stage field is reported.",
            "type": "object",
            "required": [
              "field"
            ],
            "properties": {
              "field": {
                "description": "Name of the stage field whose transition was refused.",
                "type": "string"
              },
              "from": {
                "description": "The field's current value; null when the record had no stage yet.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "to": {
                "description": "The value the write tried to move to; null when it tried to clear the field.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "requiredRoleIds": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Roles whose holders may make this move."
              },
              "requiredGroupIds": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Groups whose members may make this move."
              }
            }
          }
        }
      },
      "RecordInUseError": {
        "type": "object",
        "description": "Returned when a DELETE is refused because another record still references this one through a reference field with restrict cascade behaviour. Clear or delete the referencing records first, or change the field's cascade behaviour.\n",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "description": "Human-readable explanation of why the delete was refused, naming the referencing table when known.",
            "type": "string",
            "example": "This record is referenced by records in 'invoices' and cannot be deleted"
          },
          "code": {
            "type": "string",
            "enum": [
              "RECORD_IN_USE"
            ],
            "description": "Machine-readable in-use code for clients and agents"
          },
          "referencingTable": {
            "type": "string",
            "description": "Physical name of the table whose records hold the reference, when the database names it. A table identifier only — never row data."
          }
        }
      },
      "FieldDependant": {
        "type": "object",
        "description": "One object that still depends on a field, reported when deleting the field is refused. `kind` says what it is, `table` which table (or view) owns it, and `name` the identifier a client or agent needs to act on it: the dependant field's name for lookup/rollup/formula/ computed_column, the constraint name, the stage field's name for a stage_requirement (with the stage in `stage`), or the view name.\n",
        "required": [
          "kind",
          "table",
          "name",
          "description"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "lookup",
              "rollup",
              "formula",
              "computed_column",
              "constraint",
              "stage_requirement",
              "view"
            ],
            "description": "lookup/rollup: a schema-level computed field elsewhere reads this field. formula: a sibling formula field's expression mentions it. computed_column: a derived (computed) column on this table inlines it. constraint: a table-level constraint includes it. stage_requirement: a stage machine on this table requires it to enter a stage. view: a SQL view's SELECT reads the column."
          },
          "table": {
            "type": "string",
            "description": "Name of the table or view that owns the dependant"
          },
          "name": {
            "type": "string",
            "description": "The dependant's own identifier — field name, constraint name, stage field name, or view name"
          },
          "stage": {
            "type": "string",
            "description": "stage_requirement only — the stage whose rule requires the field"
          },
          "description": {
            "type": "string",
            "description": "Human-readable sentence fragment naming the dependant"
          }
        }
      },
      "DeletedField": {
        "description": "A field deleted from a table whose values are kept (#1549), as listed by `GET /tables/{tableId}/deleted-fields`.",
        "type": "object",
        "required": [
          "id",
          "fieldName",
          "restorable",
          "field",
          "deletedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The entry's id, used to restore the field or delete its values permanently."
          },
          "fieldName": {
            "type": "string",
            "description": "The deleted field's name. No new field can take it until this entry is restored or deleted permanently."
          },
          "restorable": {
            "type": "boolean",
            "description": "Whether the field can be restored. False for a field deleted before deletions were recorded, whose definition is unknown: its values can only be deleted permanently."
          },
          "field": {
            "description": "The field as it was when it was deleted, or null when its definition is unknown. On restore it comes back with this id.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/TableField"
              },
              {
                "type": "null"
              }
            ]
          },
          "deletedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the field was deleted, or null when that is unknown."
          }
        }
      },
      "RestoreDeletedFieldResponse": {
        "description": "Response of restoring a deleted field.",
        "type": "object",
        "required": [
          "field",
          "adjustments"
        ],
        "properties": {
          "field": {
            "$ref": "#/components/schemas/TableField"
          },
          "adjustments": {
            "type": "array",
            "description": "How the restored field differs from the definition it was deleted with, and why. Empty when it came back exactly as it was.",
            "items": {
              "$ref": "#/components/schemas/FieldRestoreAdjustment"
            }
          }
        }
      },
      "FieldRestoreAdjustment": {
        "description": "One way a restored field differs from the definition it was deleted with.",
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "x-known-values": "KnownFieldRestoreAdjustment",
            "description": "What changed: `REQUIRED_RELAXED` (some records have no value, so the field is optional), `LABEL_NOT_RESTORED` (the table has another label), `REFERENCED_FIELD_CLEARED` (the field it displayed from the referenced table no longer exists, so it shows that table's label). Open-ended: clients tolerate a code they do not know and show its `message`."
          },
          "message": {
            "type": "string",
            "description": "The adjustment in words, for showing to the person who restored the field."
          }
        }
      },
      "KnownFieldRestoreAdjustment": {
        "type": "string",
        "description": "The ways a restored field can differ from the definition it was deleted with.",
        "enum": [
          "REQUIRED_RELAXED",
          "LABEL_NOT_RESTORED",
          "REFERENCED_FIELD_CLEARED"
        ]
      },
      "FieldInUseError": {
        "type": "object",
        "description": "Returned when a field DELETE is refused because other schema objects still depend on it. Nothing was changed. Each entry in `dependants` names one blocker precisely enough to remove or change it, after which the delete can be retried.\n",
        "required": [
          "error",
          "code",
          "dependants"
        ],
        "properties": {
          "error": {
            "description": "Human-readable explanation naming the blocking dependants; the same information is available structured in `dependants`.",
            "type": "string",
            "example": "Field \"avg_score\" cannot be deleted while other objects depend on it: rollup \"avg_score_half\" on table \"artworks\". Remove or change those first."
          },
          "code": {
            "type": "string",
            "enum": [
              "FIELD_IN_USE"
            ],
            "description": "Machine-readable in-use code for clients and agents"
          },
          "dependants": {
            "description": "Every schema object that still depends on the field (rollups, lookups, formulas, views, …), each located precisely enough to remove or change it.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FieldDependant"
            }
          }
        }
      },
      "TableDeleteConflict": {
        "type": "object",
        "description": "Why a table delete was refused with 409: what still depends on the table. For TABLE_HAS_INCOMING_REFERENCES, show incomingReferences to the person before offering to delete with force=true.",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable explanation of the refusal, suitable to show the user."
          },
          "code": {
            "type": "string",
            "description": "TABLE_HAS_INCOMING_REFERENCES when reference fields or automation rules on other tables point at this table (overridable with force=true); VIEW_HAS_DEPENDENTS when other SQL views are built on this view (not overridable).",
            "enum": [
              "TABLE_HAS_INCOMING_REFERENCES",
              "VIEW_HAS_DEPENDENTS"
            ]
          },
          "suggestion": {
            "type": "string",
            "description": "What to do before trying the delete again, when the server has advice."
          },
          "incomingReferences": {
            "type": "array",
            "description": "Every reference field and automation rule on another table that points at this one. Present only with TABLE_HAS_INCOMING_REFERENCES.",
            "items": {
              "$ref": "#/components/schemas/IncomingTableReference"
            }
          }
        }
      },
      "IncomingTableReference": {
        "type": "object",
        "description": "One thing on another table that points at the table being deleted and stops working once it is gone.",
        "required": [
          "kind",
          "sourceTableId",
          "sourceTableName",
          "id",
          "name"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "referenceField",
              "automationRule"
            ],
            "description": "referenceField — a reference field whose values point at records of this table; automationRule — an automation rule that writes into this table."
          },
          "sourceTableId": {
            "type": "string",
            "description": "Id of the table that holds the field or rule."
          },
          "sourceTableName": {
            "type": "string",
            "description": "Display name of the table that holds the field or rule, for showing to the person."
          },
          "id": {
            "type": "string",
            "description": "Id of the reference field or automation rule."
          },
          "name": {
            "type": "string",
            "description": "Display name of the reference field, or the automation rule's name."
          }
        }
      },
      "StaleRecordError": {
        "type": "object",
        "description": "Returned when PUT/PATCH includes `expectedUpdatedAt` and another writer already changed the record (or the timestamp does not match).\n",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "description": "Human-readable explanation that another writer changed the record first, suitable to show the user.",
            "type": "string",
            "example": "Record was modified by another user"
          },
          "code": {
            "type": "string",
            "enum": [
              "STALE_RECORD"
            ],
            "description": "Machine-readable stale-write code for clients and agents"
          }
        }
      },
      "EventLog": {
        "description": "One row of the workspace's HTTP audit trail (`HttpAuditLogsResponse.logs`): a write request (POST/PUT/PATCH/DELETE), who made it, with what body, and how the server answered. Reads are never logged.",
        "type": "object",
        "required": [
          "id",
          "httpMethod",
          "path",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "12-character hex ID"
          },
          "httpMethod": {
            "description": "The write verb of the request; only POST, PUT, PATCH and DELETE are audited.",
            "type": "string",
            "enum": [
              "POST",
              "PUT",
              "PATCH",
              "DELETE"
            ]
          },
          "path": {
            "description": "Request path as received, e.g. `/tables/abc123def456/items`; an inbound-flow-hook URL token is redacted from it.",
            "type": "string"
          },
          "requestBody": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {},
            "description": "Request body with sensitive fields (passwords, tokens) redacted"
          },
          "responseStatus": {
            "description": "HTTP status the server answered with, so a failed attempt (4xx) is distinguishable from a successful write; null only when no status was recorded.",
            "type": [
              "integer",
              "null"
            ]
          },
          "userId": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$",
            "description": "Null for unauthenticated writes (e.g. failed login attempts)"
          },
          "userMetadata": {
            "description": "Snapshot of the actor at request time plus provenance flags; keys beyond those listed (for example `impersonation` or `hostedSite`) may appear. For an unauthenticated request it carries `unauthenticated: true` and, on auth endpoints, `attemptedEmail`.",
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true,
            "properties": {
              "email": {
                "description": "Email of the acting user at the time of the request.",
                "type": "string",
                "format": "email"
              },
              "name": {
                "description": "Display name of the acting user at the time of the request; may be empty.",
                "type": "string"
              },
              "unauthenticated": {
                "type": "boolean",
                "description": "True when no actor could be derived for the request"
              },
              "attemptedEmail": {
                "type": "string",
                "description": "Email supplied on an unauthenticated auth attempt"
              },
              "requestSource": {
                "type": "string",
                "description": "Present ('mcp') when the write arrived through the MCP forwarder — an AI client acting over /mcp — absent for ordinary web/REST writes. A provenance label only, never an authorization input."
              },
              "operator": {
                "type": "object",
                "description": "Present when the write came from the platform admin control plane (e.g. template provisioning). userId is null on these rows — the acting administrator is not a customer user — and this object names them instead.",
                "properties": {
                  "adminUserId": {
                    "description": "Id of the platform administrator in the operator directory — not a customer user id, so it does not join to `userId`.",
                    "type": "string"
                  },
                  "email": {
                    "description": "Email of the acting platform administrator.",
                    "type": "string"
                  },
                  "name": {
                    "description": "Display name of the acting platform administrator.",
                    "type": "string"
                  }
                }
              },
              "agent": {
                "description": "Present when the request was made through an agent's OAuth grant: `userId` is still the member who owns the agent, which is what the row joins to, and this names the agent that acted. Absent on a person's own requests.",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/AgentSummary"
                  }
                ]
              },
              "connectedApp": {
                "description": "Present when the request was made with a connected app's token: `userId` is the member the app acted as, and this names the app.",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/ConnectedAppSummary"
                  }
                ]
              }
            }
          },
          "createdAt": {
            "description": "When the request was recorded (server time, ISO-8601 UTC); effectively when the write happened.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ApplicationEvent": {
        "description": "One entry of the workspace's application event log: a lifecycle event (record created/updated, field added, approval decided, …) with who caused it, what it touched and masked before/after state. Item of the `ApplicationEventsResponse` list and of the `ApplicationEventFeed`.",
        "type": "object",
        "required": [
          "id",
          "eventType",
          "userId",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "12-character hex ID"
          },
          "eventType": {
            "type": "string",
            "x-known-values": "KnownApplicationEventType",
            "description": "Lifecycle vocabulary: the values known to this version are enumerated by the KnownApplicationEventType schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed (this set grows as new subsystems emit events; the approval pair arrived after the record/schema events)."
          },
          "tableId": {
            "description": "The table the event concerns; null for events that are not about a table (for example workspace-level or user events).",
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "itemId": {
            "description": "The record the event concerns (an item is a record); null for schema-level events such as a table or field change.",
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "fieldId": {
            "description": "The field the event concerns, for field lifecycle events; null otherwise.",
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "userId": {
            "description": "The user who caused the event. For writes the platform applied on someone's behalf (an approved pending change, an automation) this is the attributed user, not the approver.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$"
          },
          "beforeData": {
            "description": "The object's state before the event (a record's data, a field's definition, …), masked to the fields the caller may read. Null for create events and for events with no prior state.",
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {}
          },
          "afterData": {
            "description": "The object's state after the event, masked to the fields the caller may read. Null for delete events.",
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {}
          },
          "metadata": {
            "description": "Event-specific extras that are not state: for an update the `changedFields`, for an approved write the `approvedBy` and `pendingChangeId`, and similar. Masked like the data; null when the producer recorded none.",
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {}
          },
          "createdAt": {
            "description": "When the event was logged, ISO-8601 UTC. `GET /audit/events` lists newest first; the change feed lists oldest first.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ApplicationEventFeed": {
        "description": "Response of `GET /audit/events/feed`: one page of the workspace's change feed, oldest first, with the watermark cursors a poller stores to receive each event exactly once.",
        "type": "object",
        "required": [
          "entries",
          "nextCursor",
          "latestCursor",
          "hasMore"
        ],
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApplicationEvent"
            },
            "description": "Oldest first, so a consumer can apply them in the order they were logged."
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "The watermark to send as `cursor` next time. Keep it: it is a position in the workspace's feed, not a page boundary. When this page is empty it echoes the cursor you sent. Null only when no cursor was sent and the feed has no events yet."
          },
          "latestCursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "The watermark at the end of the whole feed, whatever this page contains. Store it on the first call and send it as `cursor` from then on to receive only changes made from now, instead of replaying every event still held. It is read from the same snapshot as the page, so when `hasMore` is false it equals `nextCursor`. Null when the feed has no events yet."
          },
          "hasMore": {
            "type": "boolean",
            "description": "True when more events were already waiting behind this page: poll again immediately rather than waiting for the next interval."
          }
        }
      },
      "ApplicationEventsResponse": {
        "description": "One page of the workspace's application event log, returned by `GET /audit/events`: the matching events plus the paging window they were cut from.",
        "type": "object",
        "required": [
          "events",
          "pagination"
        ],
        "properties": {
          "events": {
            "description": "The events matching the request's filters, within the requested paging window.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApplicationEvent"
            }
          },
          "pagination": {
            "description": "The paging window this page was cut from, echoing the request's `limit` and `offset` with the total match count.",
            "type": "object",
            "required": [
              "limit",
              "offset",
              "total"
            ],
            "properties": {
              "limit": {
                "description": "Maximum number of events in this page, as requested (or the default applied).",
                "type": "integer"
              },
              "offset": {
                "description": "Number of matching events skipped before this page; 0-based.",
                "type": "integer"
              },
              "total": {
                "description": "Total number of events matching the filters across all pages, so a client can tell whether more remain.",
                "type": "integer"
              }
            }
          }
        }
      },
      "WebSocketEventType": {
        "description": "The `type` of a frame on the workspace event stream (`WebSocketMessage`), which decides the shape of its `payload`: schema changes (`Table*`, `Field*`, `FieldsReordered`, `Constraint*`), record changes (`Item*`), comments (`Comment*`), approvals (`ApprovalRequested`, `ApprovalDecided`), `NotificationRaised`, live-editing `FieldPresence`, `RefreshRequired` when the client should reload its data, `RecordLayoutChanged`, `FlowChanged`, and the connection-level `Connected` and `Error`.",
        "type": "string",
        "enum": [
          "TableCreated",
          "TableUpdated",
          "TableDeleted",
          "FieldCreated",
          "FieldUpdated",
          "FieldDeleted",
          "FieldsReordered",
          "ConstraintCreated",
          "ConstraintDeleted",
          "ItemCreated",
          "ItemUpdated",
          "ItemDeleted",
          "CommentCreated",
          "CommentUpdated",
          "CommentDeleted",
          "ChartCommentCreated",
          "ChartCommentUpdated",
          "ApprovalRequested",
          "ApprovalDecided",
          "NotificationRaised",
          "FieldPresence",
          "RefreshRequired",
          "RecordLayoutChanged",
          "FlowChanged",
          "Connected",
          "Error"
        ]
      },
      "WebSocketMessage": {
        "type": "object",
        "description": "Base WebSocket message envelope",
        "required": [
          "type",
          "timestamp",
          "workspaceId"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/WebSocketEventType"
          },
          "timestamp": {
            "description": "When the server emitted the message, ISO-8601 UTC; order by it when frames arrive out of sequence.",
            "type": "string",
            "format": "date-time"
          },
          "workspaceId": {
            "type": "string",
            "maxLength": 12,
            "pattern": "^([0-9a-f]{12})?$",
            "description": "Workspace this event belongs to — every message is explicitly scoped. Empty only on an `Error` frame that refuses the connection before it is authenticated, when there is no workspace to name."
          },
          "userId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$",
            "description": "User who triggered the event (not present for system events)"
          },
          "payload": {
            "description": "Event-specific payload data",
            "oneOf": [
              {
                "$ref": "#/components/schemas/TableEventPayload"
              },
              {
                "$ref": "#/components/schemas/FieldEventPayload"
              },
              {
                "$ref": "#/components/schemas/FieldsReorderedPayload"
              },
              {
                "$ref": "#/components/schemas/ConstraintEventPayload"
              },
              {
                "$ref": "#/components/schemas/ItemEventPayload"
              },
              {
                "$ref": "#/components/schemas/CommentEventPayload"
              },
              {
                "$ref": "#/components/schemas/ChartCommentEventPayload"
              },
              {
                "$ref": "#/components/schemas/ApprovalEventPayload"
              },
              {
                "$ref": "#/components/schemas/NotificationEventPayload"
              },
              {
                "$ref": "#/components/schemas/FieldPresencePayload"
              },
              {
                "$ref": "#/components/schemas/RefreshRequiredPayload"
              },
              {
                "$ref": "#/components/schemas/RecordLayoutChangedPayload"
              },
              {
                "$ref": "#/components/schemas/FlowChangedPayload"
              },
              {
                "$ref": "#/components/schemas/ConnectionPayload"
              },
              {
                "$ref": "#/components/schemas/ErrorPayload"
              }
            ]
          }
        }
      },
      "CommentEventPayload": {
        "type": "object",
        "description": "Payload for record-comment events, so an open thread updates without a refresh.\nNote that a TOMBSTONE arrives as `CommentUpdated` carrying `deleted: true` and a null body, not as `CommentDeleted`: an open client replaces the text in place rather than removing the node, so the thread keeps its shape and a moderator's removal is visibly a removal. `CommentDeleted` is reserved for a genuine row removal — which today happens only when the parent record is deleted.",
        "required": [
          "tableId",
          "recordId",
          "commentId"
        ],
        "properties": {
          "tableId": {
            "description": "The table of the record the comment belongs to, so a client can route the event to the right open thread.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "recordId": {
            "description": "The record whose discussion changed.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "commentId": {
            "description": "The comment that was created, updated, tombstoned or removed; on `CommentDeleted` this is the only reference the client gets.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "comment": {
            "$ref": "#/components/schemas/RecordComment",
            "description": "The comment itself; absent on CommentDeleted, which carries ids only."
          }
        }
      },
      "ChartCommentEventPayload": {
        "type": "object",
        "description": "Payload for the comment events on a chart (`ChartCommentCreated`, `ChartCommentUpdated`), so an open chart discussion updates without a refresh. Delivered to principals holding `charts:read` and `comments:read`, the same gate the chart's own comment endpoints apply. A tombstone and a resolution both arrive as `ChartCommentUpdated`.",
        "required": [
          "chartId",
          "commentId"
        ],
        "properties": {
          "chartId": {
            "description": "The chart whose discussion changed.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "commentId": {
            "description": "The comment that was created or updated.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "comment": {
            "$ref": "#/components/schemas/RecordComment"
          }
        }
      },
      "TableEventPayload": {
        "type": "object",
        "description": "Payload for table create/update/delete events",
        "required": [
          "tableId"
        ],
        "properties": {
          "tableId": {
            "description": "The table that was created, updated or deleted; the only reference carried on a delete.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "table": {
            "$ref": "#/components/schemas/DataTable",
            "description": "Full table data (present for create/update, null for delete)"
          }
        }
      },
      "FieldEventPayload": {
        "type": "object",
        "description": "Payload for field create/update/delete events",
        "required": [
          "tableId",
          "fieldId"
        ],
        "properties": {
          "tableId": {
            "description": "Id of the table the field belongs to.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "fieldId": {
            "description": "Id of the field that was created, updated or deleted; on a delete it is the only identification left.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "field": {
            "$ref": "#/components/schemas/TableField",
            "description": "Full field data (present for create/update, null for delete)"
          }
        }
      },
      "FieldsReorderedPayload": {
        "type": "object",
        "description": "The table's default field order changed — every open grid re-sorts its columns and every open record form re-sorts its inputs.\nOne event for the whole table rather than a `FieldUpdated` per field: a reorder is a single act on the table's arrangement, and fanning it out per field would make N-1 intermediate states visible to other tabs, each of them an order nobody asked for.",
        "required": [
          "tableId",
          "fieldIds"
        ],
        "properties": {
          "tableId": {
            "description": "The table whose default field order changed; `fieldIds` is its complete new order.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "fieldIds": {
            "type": "array",
            "description": "Every field of the table, in its new order. The complete list, not a delta — a receiver re-sorts what it holds rather than trying to replay a move against state it may have missed an event for.",
            "items": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        }
      },
      "ConstraintEventPayload": {
        "type": "object",
        "description": "Payload for table-constraint create/delete events",
        "required": [
          "tableId",
          "constraintId"
        ],
        "properties": {
          "tableId": {
            "description": "Id of the table whose constraint was created or deleted, so the client can refresh that table's schema.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "constraintId": {
            "description": "Id of the affected constraint. On a `ConstraintDeleted` event this is the only reference to it, since `constraint` is absent.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "constraint": {
            "$ref": "#/components/schemas/TableConstraint",
            "description": "Full constraint data (present for create, null for delete)"
          }
        }
      },
      "ItemEventPayload": {
        "type": "object",
        "description": "Payload for item create/update/delete events",
        "required": [
          "tableId",
          "itemId"
        ],
        "properties": {
          "tableId": {
            "description": "The table the record belongs to (12 hex characters), so a client can route the event to the right open view.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "itemId": {
            "description": "The affected record's id (12 hex characters). For a delete this is all that is sent; `item` is absent.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "item": {
            "$ref": "#/components/schemas/TableItem",
            "description": "The record as the recipient reads it: its `data` carries the fields that person may read. Present for a create or an update, absent for a delete."
          }
        }
      },
      "NotificationEventPayload": {
        "type": "object",
        "description": "Payload for NotificationRaised — a notification became true for you. It carries the whole rendered notification (reusing the REST shape rather than re-describing it) so a banner can appear without a refetch.\n\nDelivery is audience-filtered per recipient exactly as the REST read is: a socket only receives frames for notifications that reader is in the audience for.\n",
        "required": [
          "notification"
        ],
        "properties": {
          "notification": {
            "$ref": "#/components/schemas/Notification"
          }
        }
      },
      "FieldPresencePayload": {
        "type": "object",
        "description": "Payload for FieldPresence — another user has a record field focused for editing (state `editing`), or has stopped (state `stopped`). A best-effort, ephemeral signal: `editing` frames repeat as keepalives while the editor stays focused, and a claim not renewed by `expiresAt` should be dropped by the client even if no `stopped` frame ever arrives (the editor's tab may have closed or lost connectivity). Carries no field content — only that the field is being edited, by whom (the envelope's `userId`), and where. Delivery is scoped per recipient like item events: a socket only receives presence for records its reader is allowed to see.\n",
        "required": [
          "tableId",
          "itemId",
          "fieldName",
          "state",
          "expiresAt"
        ],
        "properties": {
          "tableId": {
            "description": "Table of the record being edited. With `itemId` and `fieldName`, identifies the cell to decorate.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "itemId": {
            "description": "The record (legacy `item`) whose field has focus.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "fieldName": {
            "type": "string",
            "description": "Column name of the focused field, as used in item data."
          },
          "state": {
            "description": "`editing` — the sender has the field focused (repeated as a keepalive, each renewing `expiresAt`); `stopped` — they have left it, and the indicator should go at once.",
            "type": "string",
            "enum": [
              "editing",
              "stopped"
            ]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "When this claim goes stale unless renewed by another `editing` frame. Server-computed; clients should not show the indicator past this time."
          }
        }
      },
      "RefreshRequiredPayload": {
        "type": "object",
        "description": "Instructs the client to refetch the named scope via REST (which enforces authorization) instead of receiving entity data over the socket. Sent when a permission or visibility change makes incremental delivery unsafe or impractical — e.g. the recipient's permissions changed, a record share was granted/revoked, or an event payload was too large to relay across instances.\n",
        "required": [
          "scope"
        ],
        "properties": {
          "scope": {
            "type": "string",
            "enum": [
              "workspace",
              "table",
              "record"
            ],
            "description": "How much of the client's cached data should be refetched"
          },
          "tableId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "Present for table/record scopes"
          },
          "itemId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "Present for record scope"
          },
          "reason": {
            "type": "string",
            "description": "Machine-readable hint for debugging/telemetry (e.g. permissions-changed, shares-changed, payload-truncated). Not a contract — clients should refetch regardless of the reason.\n"
          }
        }
      },
      "RecordLayoutChangedPayload": {
        "type": "object",
        "description": "A table's record layout was written or discarded, for any audience (the workspace's, a group's, or one person's own). Carries no document: a receiver forgets what it holds for the table and reads the layout resolved for ITSELF on the next record page, since which document applies is decided on the server per viewer. Sent for a personal layout too — the one re-read that costs a colleague is cheaper than teaching every client the resolution order.",
        "required": [
          "tableId"
        ],
        "properties": {
          "tableId": {
            "description": "The table whose record layout changed. Drop any layout cached for it and re-read on the next record page.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          }
        }
      },
      "FlowChangedPayload": {
        "type": "object",
        "description": "A flow was created, updated, published or deleted. Carries no document: a receiver that holds the flow list (the record page's \"Run flow\" menu and its named flow actions) forgets it and re-reads through REST, which enforces flows:read.",
        "required": [
          "flowId"
        ],
        "properties": {
          "flowId": {
            "description": "Id of the flow that was created, updated, published or deleted. The payload says nothing else; re-read the flow list to learn what changed.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          }
        }
      },
      "ConnectionPayload": {
        "type": "object",
        "description": "Payload for connection established event",
        "required": [
          "workspaceId"
        ],
        "properties": {
          "workspaceId": {
            "type": "string",
            "description": "Workspace this connection is scoped to"
          },
          "message": {
            "description": "Human-readable confirmation (`Connected to real-time updates`); informational only.",
            "type": "string"
          }
        }
      },
      "ErrorPayload": {
        "type": "object",
        "description": "Payload for error events",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "description": "Machine-readable error code identifying what went wrong (for example an unknown event type or a rejected subscription), for client branching.",
            "type": "string"
          },
          "message": {
            "description": "Human-readable explanation of the error, for logging or display.",
            "type": "string"
          }
        }
      },
      "WebSocketPing": {
        "type": "object",
        "description": "Client → server keepalive.",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `ping`.",
            "type": "string",
            "enum": [
              "ping"
            ]
          }
        }
      },
      "WebSocketPong": {
        "type": "object",
        "description": "Server → client reply to a ping.",
        "required": [
          "type",
          "timestamp"
        ],
        "properties": {
          "type": {
            "description": "Always `pong`, identifying the frame as the reply to a client `ping`.",
            "type": "string",
            "enum": [
              "pong"
            ]
          },
          "timestamp": {
            "description": "Server time when the pong was sent, ISO-8601 UTC. Compare with the ping's send time to measure round-trip latency or clock skew.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FieldPresenceClientMessage": {
        "type": "object",
        "description": "Client → server field-editing presence report. Send `editing` when a field gains focus and repeat it periodically as a keepalive while focus is held (well inside the broadcast `expiresAt` window, e.g. every 15s for a 45s TTL); send `stopped` on blur. There is no acknowledgement: delivery is best-effort and the client should not block or retry on it.",
        "required": [
          "type",
          "tableId",
          "itemId",
          "fieldName",
          "state"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `presence.field`.",
            "type": "string",
            "enum": [
              "presence.field"
            ]
          },
          "tableId": {
            "description": "The table of the record being edited.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "itemId": {
            "description": "The record being edited (`item` is the legacy wire name for record).",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "fieldName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 63,
            "description": "Column name of the focused field, as used in item data."
          },
          "state": {
            "description": "`editing` announces, or refreshes as a keepalive, that the sender has the field focused; `stopped` withdraws it on blur so peers drop the indicator before the TTL would.",
            "type": "string",
            "enum": [
              "editing",
              "stopped"
            ]
          }
        }
      },
      "SchemaAssistantMessage": {
        "type": "object",
        "description": "One transcript entry replayed to the model each turn. The conversation is stateless and client-held, so the client sends the full transcript every turn.",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "description": "`user` is something the person said (or a structured answer the client rendered as text); `assistant` is a reply the model gave earlier in this conversation.",
            "type": "string",
            "enum": [
              "user",
              "assistant"
            ]
          },
          "content": {
            "description": "The message text as it appeared in the transcript; for an assistant turn, the final text of its `done` frame.",
            "type": "string"
          }
        }
      },
      "SchemaAssistantQuestionOption": {
        "type": "object",
        "description": "One option of a select-style interview question.",
        "required": [
          "value",
          "label"
        ],
        "properties": {
          "value": {
            "description": "The value sent back when the user picks this option; stable and machine-readable.",
            "type": "string"
          },
          "label": {
            "description": "What the option says in the UI.",
            "type": "string"
          }
        }
      },
      "SchemaAssistantQuestion": {
        "type": "object",
        "description": "A structured interview question the model asked via the ask_user tool. The frontend renders these as a form instead of free-form chat.",
        "required": [
          "id",
          "prompt",
          "kind"
        ],
        "properties": {
          "id": {
            "description": "Key the client echoes with the answer so the server can pair answers to questions; unique within one `done` frame.",
            "type": "string"
          },
          "prompt": {
            "description": "The question text shown to the user.",
            "type": "string"
          },
          "kind": {
            "description": "How to answer: `single_select` pick one of `options`, `multi_select` pick any number of them, `text` type a free answer (no `options`).",
            "type": "string",
            "enum": [
              "single_select",
              "multi_select",
              "text"
            ]
          },
          "options": {
            "type": "array",
            "description": "Present for the select kinds.",
            "items": {
              "$ref": "#/components/schemas/SchemaAssistantQuestionOption"
            }
          },
          "allowFreeText": {
            "type": "boolean",
            "description": "For select kinds: also offer an \"Other…\" free-text input."
          }
        }
      },
      "SchemaAssistantProposedPlan": {
        "type": "object",
        "description": "A validated plan the model settled on this turn — what the user confirms before apply. Reuses the shared schema-plan schemas so the assistant and the /schema-plans endpoints never diverge.",
        "required": [
          "plan",
          "stats",
          "issues",
          "summary"
        ],
        "properties": {
          "plan": {
            "description": "The raw plan document (version 1) the model validated. Sent back verbatim to POST /schema-plans/apply. Deliberately untyped — see SchemaPlanRequest."
          },
          "stats": {
            "$ref": "#/components/schemas/SchemaPlanStats"
          },
          "issues": {
            "type": "array",
            "description": "Warnings from the successful validation (errors would make it not proposed).",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "summary": {
            "type": "string",
            "description": "Human-readable confirmation view of the proposed changes."
          }
        }
      },
      "SchemaAssistantInboundMessage": {
        "type": "object",
        "description": "Client → server. Carries the full prior conversation plus the latest user message for one design turn.",
        "required": [
          "type",
          "messages"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `schema_assistant.message`.",
            "type": "string",
            "enum": [
              "schema_assistant.message"
            ]
          },
          "correlationId": {
            "type": "string",
            "description": "Client-generated id echoed on every frame of this turn so the client can ignore frames from a superseded turn."
          },
          "messages": {
            "description": "The whole conversation so far in order, ending with the user's latest message; the server keeps no turn state, so the client resends it every turn.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SchemaAssistantMessage"
            }
          }
        }
      },
      "SchemaAssistantChunkFrame": {
        "type": "object",
        "description": "Server → client. A streamed fragment of the assistant's reply (repeated).",
        "required": [
          "type",
          "text"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `schema_assistant.chunk`.",
            "type": "string",
            "enum": [
              "schema_assistant.chunk"
            ]
          },
          "correlationId": {
            "description": "The client-generated id of the turn this chunk belongs to, echoed from the message frame so a client can drop chunks from a superseded turn.",
            "type": "string"
          },
          "text": {
            "description": "The next fragment of the assistant's reply; append it to what the turn has shown so far.",
            "type": "string"
          }
        }
      },
      "SchemaAssistantDoneFrame": {
        "type": "object",
        "description": "Server → client. Terminal frame for a turn — the settled reply plus any proposed plan or interview questions, and on a conversation's first turn in a workspace with no tables, any library part offered in place of designing from scratch.",
        "required": [
          "type",
          "text"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `schema_assistant.done`.",
            "type": "string",
            "enum": [
              "schema_assistant.done"
            ]
          },
          "correlationId": {
            "description": "The `correlationId` the client sent with the turn, echoed so frames from a superseded turn can be ignored.",
            "type": "string"
          },
          "text": {
            "description": "The assistant's complete reply for the turn, superseding the streamed chunks (render this, not the concatenation).",
            "type": "string"
          },
          "proposedPlan": {
            "description": "The validated plan when the model produced one this turn, else null.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/SchemaAssistantProposedPlan"
              },
              {
                "type": "null"
              }
            ]
          },
          "questions": {
            "type": [
              "array",
              "null"
            ],
            "description": "Structured interview questions when the model ended the turn via ask_user, else null.",
            "items": {
              "$ref": "#/components/schemas/SchemaAssistantQuestion"
            }
          },
          "libraryOffer": {
            "description": "A library part that matches what the person asked for, offered before the assistant designs from scratch: present only on the first turn of a conversation in a workspace with no tables, when at least two of the words that describe the request (stop words and filler such as \"need\" or \"track\" left out) match a part the library listing shows the caller, and that part's latest version is installable. The client shows it as a card offering to install the part through the install wizard or to design from scratch; the assistant never installs anything itself. Null otherwise.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/SchemaAssistantLibraryOffer"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "SchemaAssistantLibraryOffer": {
        "type": "object",
        "description": "The library part the schema assistant offers in place of designing from scratch, with what the offer card shows and what the install wizard needs to open on it.",
        "required": [
          "partId",
          "name",
          "summary",
          "stats",
          "publisher",
          "latestVersionNumber"
        ],
        "properties": {
          "partId": {
            "type": "string",
            "description": "The offered part's id: what the install wizard installs and what the part's library page is addressed by."
          },
          "name": {
            "type": "string",
            "description": "The part's display name, shown as the offer's subject (\"A Recipes part exists\")."
          },
          "summary": {
            "type": "string",
            "description": "One or two sentences on what the part is for, shown under the offer."
          },
          "stats": {
            "$ref": "#/components/schemas/SchemaPartStats"
          },
          "publisher": {
            "$ref": "#/components/schemas/SchemaPartPublisher"
          },
          "latestVersionNumber": {
            "type": "integer",
            "description": "The version the client installs: the part's latest version, which is also its latest installable one, since the offer is only made when the two coincide. The client opens the install wizard on it when the person chooses Install, and `stats` describes it."
          }
        }
      },
      "SchemaAssistantErrorFrame": {
        "type": "object",
        "description": "Server → client. Terminal frame when the turn failed.",
        "required": [
          "type",
          "error"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `schema_assistant.error`.",
            "type": "string",
            "enum": [
              "schema_assistant.error"
            ]
          },
          "correlationId": {
            "description": "The client-generated id of the turn that failed, echoed so the client can ignore an error from a superseded turn.",
            "type": "string"
          },
          "error": {
            "description": "Human-readable explanation of why the turn failed, suitable to show the user.",
            "type": "string"
          }
        }
      },
      "SchemaAssistantProgressFrame": {
        "type": "object",
        "description": "Server → client. A lightweight heartbeat emitted while a turn is still running but nothing has streamed for a while (the model is thinking or drafting a large tool call), so the client can show a \"still working\" indicator instead of appearing frozen. Carries no content — a slow turn can take a couple of minutes, and this is what tells the user it's alive.",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `schema_assistant.progress`.",
            "type": "string",
            "enum": [
              "schema_assistant.progress"
            ]
          },
          "correlationId": {
            "description": "The client-generated id of the turn still running, echoed so the client can match the heartbeat to the turn it is waiting on.",
            "type": "string"
          }
        }
      },
      "SchemaAssistantOutboundFrame": {
        "description": "Any server → client frame for a design turn.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/SchemaAssistantChunkFrame"
          },
          {
            "$ref": "#/components/schemas/SchemaAssistantProgressFrame"
          },
          {
            "$ref": "#/components/schemas/SchemaAssistantDoneFrame"
          },
          {
            "$ref": "#/components/schemas/SchemaAssistantErrorFrame"
          }
        ]
      },
      "SchemaAssistantPendingTurn": {
        "type": "object",
        "description": "An undelivered terminal frame for a schema-design turn.",
        "required": [
          "version",
          "correlationId",
          "settledAt",
          "frame"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "description": "Stored-shape version (ASSISTANT_PENDING_TURN_VERSION). A row whose version the client doesn't recognise is discarded, not guessed at."
          },
          "correlationId": {
            "type": "string",
            "description": "The turn this reply answers. The client only replays a row matching the turn it is waiting for — a reply to some older turn is stale."
          },
          "settledAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the turn finished, so the client can ignore an ancient row."
          },
          "frame": {
            "description": "The terminal frame itself, replayed verbatim by the client.",
            "$ref": "#/components/schemas/SchemaAssistantOutboundFrame"
          }
        }
      },
      "QueryAssistantProposedChart": {
        "type": "object",
        "description": "A chart the model proposed to visualise the drafted query. `config` reuses the saved-chart config shape so the proposal can be saved via POST /charts verbatim (backed by the saved query).",
        "required": [
          "chartType",
          "config"
        ],
        "properties": {
          "chartType": {
            "$ref": "#/components/schemas/ChartType"
          },
          "config": {
            "$ref": "#/components/schemas/ChartConfig"
          },
          "name": {
            "type": "string",
            "description": "Suggested chart name. Falls back to the query name."
          }
        }
      },
      "QueryAssistantProposedQuery": {
        "type": "object",
        "description": "A drafted SQL query that validated cleanly (parse + read-only EXPLAIN) against the workspace this turn. The user decides whether to run it (POST /query) and save it (POST /queries) — the assistant never executes it.",
        "required": [
          "sql",
          "name",
          "summary"
        ],
        "properties": {
          "sql": {
            "type": "string",
            "description": "The drafted single-SELECT SQL statement."
          },
          "name": {
            "type": "string",
            "description": "Suggested saved-query name."
          },
          "summary": {
            "type": "string",
            "description": "Plain-language description of what the query answers."
          },
          "chart": {
            "description": "Present when the user asked for a graph/visualisation, else null.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/QueryAssistantProposedChart"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "QueryAssistantInboundMessage": {
        "type": "object",
        "description": "Client → server. Carries the full prior conversation plus the latest user message for one drafting turn.",
        "required": [
          "type",
          "messages"
        ],
        "properties": {
          "type": {
            "description": "Discriminator of the message; always `query_assistant.message`.",
            "type": "string",
            "enum": [
              "query_assistant.message"
            ]
          },
          "correlationId": {
            "type": "string",
            "description": "Client-generated id echoed on every frame of this turn so the client can ignore frames from a superseded turn."
          },
          "messages": {
            "description": "The whole conversation so far in order, ending with the user's latest message. The server keeps no conversation state between turns, so the client resends it each time.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SchemaAssistantMessage"
            }
          }
        }
      },
      "QueryAssistantChunkFrame": {
        "type": "object",
        "description": "Server → client. A streamed fragment of the assistant's reply (repeated).",
        "required": [
          "type",
          "text"
        ],
        "properties": {
          "type": {
            "description": "Discriminator of the frame; always `query_assistant.chunk`.",
            "type": "string",
            "enum": [
              "query_assistant.chunk"
            ]
          },
          "correlationId": {
            "description": "The `correlationId` the client sent on the `query_assistant.message` that started this turn, so frames from a superseded turn can be ignored. Absent when the client sent none.",
            "type": "string"
          },
          "text": {
            "description": "The next fragment of the assistant's reply. Append the fragments in arrival order; the terminal `done` frame carries the full text.",
            "type": "string"
          }
        }
      },
      "QueryAssistantDoneFrame": {
        "type": "object",
        "description": "Server → client. Terminal frame for a turn — the settled reply plus any proposed query or interview questions.",
        "required": [
          "type",
          "text"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `query_assistant.done`.",
            "type": "string",
            "enum": [
              "query_assistant.done"
            ]
          },
          "correlationId": {
            "description": "Echo of the client-generated id from the inbound message of this turn, so frames from a superseded turn can be ignored.",
            "type": "string"
          },
          "text": {
            "description": "The assistant's complete reply for the turn, as markdown; the same text the streamed deltas added up to.",
            "type": "string"
          },
          "proposedQuery": {
            "description": "The validated query when the model produced one this turn, else null.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/QueryAssistantProposedQuery"
              },
              {
                "type": "null"
              }
            ]
          },
          "questions": {
            "type": [
              "array",
              "null"
            ],
            "description": "Structured interview questions when the model ended the turn via ask_user, else null.",
            "items": {
              "$ref": "#/components/schemas/SchemaAssistantQuestion"
            }
          }
        }
      },
      "QueryAssistantErrorFrame": {
        "type": "object",
        "description": "Server → client. Terminal frame when the turn failed.",
        "required": [
          "type",
          "error"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `query_assistant.error`.",
            "type": "string",
            "enum": [
              "query_assistant.error"
            ]
          },
          "correlationId": {
            "description": "The client-generated id of the turn that failed, echoed so the client can ignore an error from a superseded turn.",
            "type": "string"
          },
          "error": {
            "description": "Human-readable reason the turn failed, for display in the conversation.",
            "type": "string"
          }
        }
      },
      "QueryAssistantOutboundFrame": {
        "description": "Any server → client frame for a drafting turn.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/QueryAssistantChunkFrame"
          },
          {
            "$ref": "#/components/schemas/QueryAssistantDoneFrame"
          },
          {
            "$ref": "#/components/schemas/QueryAssistantErrorFrame"
          }
        ]
      },
      "QueryAssistantPendingTurn": {
        "type": "object",
        "description": "An undelivered terminal frame for a query-drafting turn. See SchemaAssistantPendingTurn for what these rows are and why they exist.",
        "required": [
          "version",
          "correlationId",
          "settledAt",
          "frame"
        ],
        "properties": {
          "version": {
            "description": "Stored-shape version of the row. A row whose version the client does not recognise is discarded, not guessed at.",
            "type": "integer"
          },
          "correlationId": {
            "description": "The query-drafting turn this frame answers. The client replays a row only when it matches the turn it is waiting for; a reply to an older turn is stale.",
            "type": "string"
          },
          "settledAt": {
            "description": "When the turn finished and the frame was stored, ISO-8601 UTC, so the client can ignore an ancient row.",
            "type": "string",
            "format": "date-time"
          },
          "frame": {
            "$ref": "#/components/schemas/QueryAssistantOutboundFrame"
          }
        }
      },
      "DashboardAssistantProposedPlan": {
        "type": "object",
        "description": "A validated dashboard plan the model settled on this turn — what the user confirms before apply. Reuses the shared dashboard-plan schemas so the assistant and the /dashboard-plans endpoints never diverge.",
        "required": [
          "plan",
          "stats",
          "issues",
          "summary"
        ],
        "properties": {
          "plan": {
            "description": "The raw plan document (version 1) the model validated. Sent back verbatim to POST /dashboard-plans/apply. Deliberately untyped — see DashboardPlanRequest."
          },
          "stats": {
            "$ref": "#/components/schemas/DashboardPlanStats"
          },
          "issues": {
            "type": "array",
            "description": "Warnings from the successful validation (errors would make it not proposed).",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "summary": {
            "type": "string",
            "description": "Human-readable confirmation view of the proposed changes."
          }
        }
      },
      "DashboardAssistantInboundMessage": {
        "type": "object",
        "description": "Client → server. Carries the full prior conversation plus the latest user message for one dashboard-design turn.",
        "required": [
          "type",
          "messages"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `dashboard_assistant.message`.",
            "type": "string",
            "enum": [
              "dashboard_assistant.message"
            ]
          },
          "correlationId": {
            "type": "string",
            "description": "Client-generated id echoed on every frame of this turn so the client can ignore frames from a superseded turn."
          },
          "messages": {
            "description": "The whole conversation so far, oldest first, ending with the user's new message. The server keeps no transcript, so the client must send it in full every turn.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SchemaAssistantMessage"
            }
          }
        }
      },
      "DashboardAssistantChunkFrame": {
        "type": "object",
        "description": "Server → client. A streamed fragment of the assistant's reply (repeated).",
        "required": [
          "type",
          "text"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `dashboard_assistant.chunk`.",
            "type": "string",
            "enum": [
              "dashboard_assistant.chunk"
            ]
          },
          "correlationId": {
            "description": "The `correlationId` the client sent on the `dashboard_assistant.message` that began this turn, echoed so the client can drop chunks from a superseded turn. Absent when the client sent none.",
            "type": "string"
          },
          "text": {
            "description": "The next fragment of the assistant's reply. Append it to the fragments already received for this turn; the terminal `done` frame carries the complete text.",
            "type": "string"
          }
        }
      },
      "DashboardAssistantProgressFrame": {
        "type": "object",
        "description": "Server → client. A lightweight heartbeat emitted while a turn is still running but nothing has streamed for a while (the model is thinking or drafting a large tool call), so the client can show a \"still working\" indicator instead of appearing frozen. Carries no content.",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `dashboard_assistant.progress`.",
            "type": "string",
            "enum": [
              "dashboard_assistant.progress"
            ]
          },
          "correlationId": {
            "description": "The client-generated id of the turn this heartbeat belongs to, echoed so the client can ignore progress from a superseded turn.",
            "type": "string"
          }
        }
      },
      "DashboardAssistantDoneFrame": {
        "type": "object",
        "description": "Server → client. Terminal frame for a turn — the settled reply plus any proposed plan or interview questions.",
        "required": [
          "type",
          "text"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `dashboard_assistant.done`.",
            "type": "string",
            "enum": [
              "dashboard_assistant.done"
            ]
          },
          "correlationId": {
            "description": "The client-generated id of the turn this frame ends, echoed from the message frame so a client can ignore the result of a superseded turn.",
            "type": "string"
          },
          "text": {
            "description": "The assistant's complete reply for the turn, as settled text (the concatenation of the streamed chunks).",
            "type": "string"
          },
          "proposedPlan": {
            "description": "The validated plan when the model produced one this turn, else null.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/DashboardAssistantProposedPlan"
              },
              {
                "type": "null"
              }
            ]
          },
          "questions": {
            "type": [
              "array",
              "null"
            ],
            "description": "Structured interview questions when the model ended the turn via ask_user, else null.",
            "items": {
              "$ref": "#/components/schemas/SchemaAssistantQuestion"
            }
          }
        }
      },
      "DashboardAssistantErrorFrame": {
        "type": "object",
        "description": "Server → client. Terminal frame when the turn failed.",
        "required": [
          "type",
          "error"
        ],
        "properties": {
          "type": {
            "description": "Frame discriminator; always `dashboard_assistant.error`.",
            "type": "string",
            "enum": [
              "dashboard_assistant.error"
            ]
          },
          "correlationId": {
            "description": "The `correlationId` the client sent with the turn, echoed so frames from a superseded turn can be ignored. Absent when the failure happened before the message was parsed.",
            "type": "string"
          },
          "error": {
            "description": "Human-readable reason the turn failed, suitable to show the user. No further frames follow for this turn.",
            "type": "string"
          }
        }
      },
      "DashboardAssistantOutboundFrame": {
        "description": "Any server → client frame for a dashboard-design turn.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/DashboardAssistantChunkFrame"
          },
          {
            "$ref": "#/components/schemas/DashboardAssistantProgressFrame"
          },
          {
            "$ref": "#/components/schemas/DashboardAssistantDoneFrame"
          },
          {
            "$ref": "#/components/schemas/DashboardAssistantErrorFrame"
          }
        ]
      },
      "DashboardAssistantPendingTurn": {
        "type": "object",
        "description": "An undelivered terminal frame for a dashboard-design turn. See SchemaAssistantPendingTurn for what these rows are and why they exist.",
        "required": [
          "version",
          "correlationId",
          "settledAt",
          "frame"
        ],
        "properties": {
          "version": {
            "description": "Stored-shape version of the row. A client discards a row whose version it does not recognise rather than guessing at it.",
            "type": "integer"
          },
          "correlationId": {
            "description": "The turn this reply answers. The client only replays a row matching the turn it is waiting for; a reply to an older turn is stale.",
            "type": "string"
          },
          "settledAt": {
            "description": "When the turn finished, ISO-8601 UTC, so the client can ignore an ancient row.",
            "type": "string",
            "format": "date-time"
          },
          "frame": {
            "$ref": "#/components/schemas/DashboardAssistantOutboundFrame"
          }
        }
      },
      "HttpAuditLogsResponse": {
        "description": "A page of the workspace's HTTP audit log (POST/PUT/PATCH/DELETE requests with redacted bodies). Response of `GET /audit/http-logs`.",
        "type": "object",
        "required": [
          "logs",
          "pagination"
        ],
        "properties": {
          "logs": {
            "description": "The matching audit entries, newest first, within the requested page.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventLog"
            }
          },
          "pagination": {
            "description": "The paging that produced `logs`, echoing the effective limit and offset so a client can page without tracking its own request.",
            "type": "object",
            "required": [
              "limit",
              "offset",
              "total"
            ],
            "properties": {
              "limit": {
                "description": "Page size actually applied: the requested `limit` clamped to 1–1000, defaulting to 100.",
                "type": "integer"
              },
              "offset": {
                "description": "Number of matching entries skipped before this page (the request's `offset`, floored at 0).",
                "type": "integer"
              },
              "total": {
                "description": "Total entries matching the filters across all pages; `offset + logs.length < total` means more remain.",
                "type": "integer"
              }
            }
          }
        }
      },
      "RegisterRequest": {
        "description": "Request body of `POST /auth/register`: the credentials and display name for a new public sign-up. Addresses not on the early-access allowlist create a pending account rather than a session.",
        "type": "object",
        "required": [
          "email",
          "password",
          "name"
        ],
        "properties": {
          "email": {
            "description": "Sign-in address of the new account; must not already be registered. At most 255 characters.",
            "type": "string",
            "format": "email",
            "maxLength": 255
          },
          "password": {
            "description": "The account password, 10–128 characters; checked against the platform's password rules.",
            "type": "string",
            "minLength": 10,
            "maxLength": 128
          },
          "name": {
            "description": "The user's display name as shown to other members (1–255 characters).",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "captchaToken": {
            "$ref": "#/components/schemas/CaptchaToken"
          }
        }
      },
      "LogoutRequest": {
        "description": "Request body of `POST /auth/logout`: the session (refresh) token to revoke. The token is the credential, so the call works even when the access token has expired.",
        "type": "object",
        "required": [
          "refreshToken"
        ],
        "properties": {
          "refreshToken": {
            "type": "string",
            "description": "The session (refresh) token to revoke"
          }
        }
      },
      "ChangePasswordRequest": {
        "description": "Request body of `PUT /auth/password`. The current password must be supplied to prove the caller is the account holder; on success every other session is revoked and a fresh one is issued to the caller.",
        "type": "object",
        "required": [
          "currentPassword",
          "newPassword"
        ],
        "properties": {
          "currentPassword": {
            "description": "The account's current password, proving the caller is the account holder rather than someone holding a stolen session. Wrong value: 400.",
            "type": "string"
          },
          "newPassword": {
            "description": "The replacement password, 10 to 128 characters. Takes effect immediately; every other session is revoked.",
            "type": "string",
            "minLength": 10,
            "maxLength": 128
          }
        }
      },
      "LoginRequest": {
        "description": "Email-and-password credentials. Request body of `POST /auth/login`.",
        "type": "object",
        "required": [
          "email",
          "password"
        ],
        "properties": {
          "email": {
            "description": "The account's email address, matched case-insensitively.",
            "type": "string",
            "format": "email"
          },
          "password": {
            "description": "The account password, in clear over TLS; never stored, only compared to the hash.",
            "type": "string"
          }
        }
      },
      "PasswordChangeRequiredRefusal": {
        "type": "object",
        "description": "Must-change-password refusal from an endpoint that cannot re-verify the current credential (/auth/mfa/verify, /auth/refresh, /auth/token, passkey sign-in). Deliberately carries NO passwordChangeToken: that token is the only thing /auth/set-password requires, so it is minted solely by /auth/login, after the admin-issued one-time password has been verified. The caller restarts sign-in.\n",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "description": "Human-readable reason for the 401 (\"Password change required\"). For display; branch on `code`.",
            "type": "string"
          },
          "code": {
            "description": "Always `PASSWORD_CHANGE_REQUIRED`: the account carries an admin-issued one-time password that must be replaced before any session is granted. The client restarts sign-in at `/auth/login`.",
            "type": "string",
            "enum": [
              "PASSWORD_CHANGE_REQUIRED"
            ]
          }
        }
      },
      "PasswordChangeRequiredResponse": {
        "type": "object",
        "description": "Returned by login when the account holds an admin-issued one-time password. The caller must set a new password via /auth/set-password (using the short-lived passwordChangeToken) before a session is issued. Only login returns this shape: it is the one path that verifies the current credential before minting the token. Endpoints that cannot do that use PasswordChangeRequiredRefusal instead.\n",
        "required": [
          "error",
          "code",
          "passwordChangeToken"
        ],
        "properties": {
          "error": {
            "description": "Human-readable message explaining that a new password must be set before signing in.",
            "type": "string"
          },
          "code": {
            "description": "Machine-readable discriminator, always `PASSWORD_CHANGE_REQUIRED`; branch on this rather than on `error`.",
            "type": "string",
            "enum": [
              "PASSWORD_CHANGE_REQUIRED"
            ]
          },
          "passwordChangeToken": {
            "type": "string",
            "description": "Short-lived token proving the one-time-password login; only accepted by /auth/set-password, never as a bearer token.\n"
          }
        }
      },
      "SetPasswordRequest": {
        "description": "Request body of `POST /auth/set-password`: completes an admin-initiated reset by exchanging the short-lived `passwordChangeToken` from login and a chosen password for a normal session.",
        "type": "object",
        "required": [
          "passwordChangeToken",
          "newPassword"
        ],
        "properties": {
          "passwordChangeToken": {
            "description": "The short-lived token the login response returned when the account held a one-time password; it proves identity in place of a session.",
            "type": "string"
          },
          "newPassword": {
            "description": "The password the user chose, 10 to 128 characters. Replaces the one-time password and clears the must-change flag.",
            "type": "string",
            "minLength": 10,
            "maxLength": 128
          }
        }
      },
      "HealthReadiness": {
        "type": "object",
        "description": "Readiness of the API's database dependencies, as reported by GET /health/ready. The same shape is returned with 200 (ready) and 503 (not ready). It carries no hostnames, connection strings or error messages — a failed check names only a short code.",
        "required": [
          "status",
          "checkedAt",
          "checks"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ready",
              "not_ready"
            ],
            "description": "`ready` when every check passed, `not_ready` when any failed."
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the checks ran. Results are cached in-process for about ten seconds, so this can trail the request time by up to that much."
          },
          "checks": {
            "type": "object",
            "description": "One entry per database the API depends on, keyed by shard name (and `<shard>:reader` for a shard's read replica, when it has one): `primary` is the control-plane database; any further keys are workspace database shards.",
            "additionalProperties": {
              "$ref": "#/components/schemas/HealthReadinessCheck"
            }
          }
        }
      },
      "HealthReadinessCheck": {
        "description": "The probe result for one database the API depends on, keyed by shard name inside `HealthReadiness.checks`. Carries only a pass/fail, a latency and a short error code, never connection details.",
        "type": "object",
        "required": [
          "ok",
          "latencyMs"
        ],
        "properties": {
          "ok": {
            "description": "True when the probe query answered within budget; false puts the whole readiness response at 503, with `error` naming the cause.",
            "type": "boolean"
          },
          "latencyMs": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Round-trip time of `SELECT 1`, or null when the check failed."
          },
          "error": {
            "type": "string",
            "enum": [
              "timeout",
              "unreachable"
            ],
            "description": "Present only on a failed check: `timeout` when the database did not answer within the probe's budget, `unreachable` for any other failure."
          }
        }
      },
      "AuthResponse": {
        "description": "A signed-in session: the access token to send as the bearer, the refresh token to renew it with, the user it belongs to and every workspace they may enter. Returned by register, login, set-password, refresh, password change and the social-login token exchange.",
        "type": "object",
        "required": [
          "token",
          "user",
          "workspaces"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "Short-lived access token (30 min) containing userId, workspaceId, role"
          },
          "refreshToken": {
            "type": "string",
            "description": "Long-lived refresh token (30 days) for obtaining new access tokens"
          },
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "workspaces": {
            "type": "array",
            "description": "All workspaces the user is a member of",
            "items": {
              "$ref": "#/components/schemas/WorkspaceSummary"
            }
          },
          "impersonation": {
            "$ref": "#/components/schemas/ImpersonationContext"
          }
        }
      },
      "WorkspaceEnvironment": {
        "type": "string",
        "enum": [
          "production",
          "sandbox"
        ],
        "description": "`production` (the default) or `sandbox`. Fixed at creation — there is no way to change it afterwards in either direction — because it is a licence to write history: only a sandbox accepts `occurredAt` on record writes and the stage-transition seed endpoint, so demo data can carry a believable timeline. Enforced on the write path, never only in a UI."
      },
      "WorkspaceInfo": {
        "type": "object",
        "description": "The workspace the caller's token is bound to.",
        "required": [
          "id",
          "name",
          "environment",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the workspace the token is bound to — the value other endpoints call `workspaceId`.",
            "type": "string"
          },
          "name": {
            "description": "The workspace's display name as set in its settings.",
            "type": "string"
          },
          "environment": {
            "$ref": "#/components/schemas/WorkspaceEnvironment"
          },
          "createdAt": {
            "description": "When the workspace was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WorkspaceSummary": {
        "description": "One workspace the user belongs to, as listed by sign-in and `GET /auth/me`: enough to show it in the switcher and enter it — identity, the user's role there, the owning organization and the environment kind.",
        "type": "object",
        "required": [
          "id",
          "name",
          "role",
          "organizationId",
          "organizationName",
          "environment"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the workspace; does not change when it is renamed.",
            "type": "string"
          },
          "name": {
            "description": "Display name of the workspace as shown in the switcher.",
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/WorkspaceRole"
          },
          "organizationId": {
            "type": "string",
            "description": "Organization that owns this workspace"
          },
          "organizationName": {
            "type": "string",
            "description": "Name of the owning organization"
          },
          "environment": {
            "$ref": "#/components/schemas/WorkspaceEnvironment"
          },
          "branding": {
            "$ref": "#/components/schemas/WorkspaceBranding"
          },
          "address": {
            "description": "The workspace's chosen address, when its admins have set one: the label of the workspace's own origin (`https://<address>.app.tessule.com`), unique across the platform. Absent when none is set; the workspace can still be opened on its own origin under its `id`. A client on a workspace origin matches its label against `id` or this value to find the workspace to enter.",
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
            "minLength": 3,
            "maxLength": 40
          }
        }
      },
      "WorkspaceAddressRequest": {
        "description": "The address a workspace claims for its own origin.",
        "type": "object",
        "required": [
          "address"
        ],
        "properties": {
          "address": {
            "description": "The address to claim, already normalised: lowercase letters and digits joined by single hyphens, 3–40 characters, not shaped like a workspace id, not a reserved name, and not ending in `-prv` or containing `-prv-` (reserved for hosted-site preview addresses, since the address also names the workspace's hosted site). Clients derive it from free text with the shared `normalizeWorkspaceAddress` rule.",
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
            "minLength": 3,
            "maxLength": 40
          }
        }
      },
      "WorkspaceAddress": {
        "description": "The address the workspace now holds.",
        "type": "object",
        "required": [
          "address"
        ],
        "properties": {
          "address": {
            "description": "The claimed address — the label of the workspace's own origin. Addresses the workspace held before stay reserved to it, so an installed app or bookmark at an old address never opens another tenant's workspace.",
            "type": "string"
          }
        }
      },
      "WorkspaceAddressTakenResponse": {
        "description": "The address is held by another workspace (its current address or one it held before). The body proposes a free alternative.",
        "type": "object",
        "required": [
          "error",
          "code",
          "suggestion"
        ],
        "properties": {
          "error": {
            "description": "Human-readable explanation, safe to show.",
            "type": "string"
          },
          "code": {
            "description": "Always `WORKSPACE_ADDRESS_TAKEN`.",
            "type": "string",
            "enum": [
              "WORKSPACE_ADDRESS_TAKEN"
            ]
          },
          "suggestion": {
            "description": "A free address built from the requested one plus a short random suffix; offer it, and claim it with another `PUT /workspace/address` if the user accepts.",
            "type": "string"
          }
        }
      },
      "WorkspaceBranding": {
        "type": "object",
        "description": "Presentation-only branding a workspace admin has configured for this workspace's UI. Absent fields mean the stock look: default theme colours, no logo, and the workspace's real name. displayName never renames the workspace entity — it only changes what the app chrome shows inside the workspace.",
        "properties": {
          "displayName": {
            "description": "Name the app chrome shows for this workspace in place of its real name. Presentation only: the workspace entity keeps its own name.",
            "type": "string",
            "maxLength": 255
          },
          "primaryColor": {
            "type": "string",
            "description": "Brand primary colour as '#rrggbb'"
          },
          "secondaryColor": {
            "type": "string",
            "description": "Brand secondary/accent colour as '#rrggbb'"
          },
          "logoUrl": {
            "type": "string",
            "description": "Short-lived presigned URL for the workspace logo. Server-computed on read; never a raw storage key. Re-fetch settings (or refresh auth) for a fresh URL when it expires."
          },
          "chartPalette": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "description": "The workspace's chart series colours as `#rrggbb`, in series order: the first series takes the first colour, and so on, wrapping. Charts, the chart editor's defaults and chart image downloads read it; absent, the app's stock palette applies."
          },
          "fontFamily": {
            "type": "string",
            "maxLength": 120,
            "description": "Font family name applied to the app's text, chart labels and exported workbooks (a name a browser or spreadsheet can resolve, such as `Inter` or `Georgia`). Absent, the app's stock type applies."
          }
        }
      },
      "WorkspaceSettings": {
        "description": "The workspace-wide settings an admin manages: branding, time zone, and the feature switches for field presence and sheet schema editing. Response of `GET` and `PUT /workspace/settings`.",
        "type": "object",
        "required": [
          "branding",
          "fieldPresenceEnabled",
          "sheetSchemaEditingEnabled",
          "timezone"
        ],
        "properties": {
          "branding": {
            "$ref": "#/components/schemas/WorkspaceBranding"
          },
          "timezone": {
            "type": "string",
            "description": "The workspace's IANA time zone (e.g. `Europe/London`), `UTC` when never set. Read-time computed columns render datetimes in it (`format_datetime(...)`); stored values are unaffected — a datetime is an instant, and this only decides how a computed label or column writes it out."
          },
          "logoKey": {
            "type": "string",
            "description": "Raw storage key of the configured logo (for admins to carry over unchanged in a subsequent PUT, or omit to clear)."
          },
          "fieldPresenceEnabled": {
            "type": "boolean",
            "description": "Whether live field-editing presence indicators (\"someone is editing this field\") are broadcast in this workspace. On by default; a workspace admin can turn the feature off entirely."
          },
          "sheetSchemaEditingEnabled": {
            "type": "boolean",
            "description": "Whether the sheet view offers inline column management (add, edit and delete table columns from the grid header) to users holding fields:manage. On by default — suits solo users and small teams; turn off for workspaces that want schema changes made deliberately, through Table Administration only. A UI affordance switch: the field endpoints themselves stay governed by permissions regardless of this setting."
          },
          "agentInstructions": {
            "type": "string",
            "maxLength": 4000,
            "description": "Standing instructions a workspace admin writes for the AI agents that connect over MCP — house rules such as the currency amounts are in, tables an integration feeds that nothing else should write, or \"ask before creating a table\". Every MCP connection receives them verbatim in its server instructions and in `describe_workspace`. Rules about how to act here, not a description of the workspace (that is derived from the schema). Absent when none are set."
          },
          "updatedAt": {
            "description": "When settings were last saved, ISO-8601 UTC. Absent when the workspace has never saved settings and the defaults apply.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "UpdateWorkspaceSettingsRequest": {
        "type": "object",
        "description": "Full-replace update of the workspace's settings: omitted BRANDING fields are cleared back to their defaults. `fieldPresenceEnabled` and `sheetSchemaEditingEnabled` are the deliberate exceptions — they are persistent feature switches rather than clearable branding, so omitting them leaves the current values unchanged (clients editing only branding cannot accidentally flip them).",
        "properties": {
          "fieldPresenceEnabled": {
            "type": "boolean",
            "description": "Turn live field-editing presence indicators on or off for the whole workspace. Omit to leave unchanged."
          },
          "sheetSchemaEditingEnabled": {
            "type": "boolean",
            "description": "Turn inline column management in the sheet view on or off for the whole workspace. Omit to leave unchanged."
          },
          "timezone": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "IANA time zone name (e.g. `Europe/Lisbon`). Persistent like the feature switches: omit to leave unchanged. Rejected (400) when not a zone this platform knows."
          },
          "agentInstructions": {
            "type": "string",
            "maxLength": 4000,
            "description": "Standing instructions for AI agents connected over MCP (see `WorkspaceSettings.agentInstructions`). Persistent like the feature switches: omit to leave unchanged; an empty string clears them. Up to 4,000 characters."
          },
          "displayName": {
            "description": "The workspace name shown in the app header and emails. Branding: omitting it resets to the default.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "primaryColor": {
            "description": "Brand colour as a 6-digit hex code (`#1a73e8`) used for the app's primary accent. Omitting it resets to the default.",
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$"
          },
          "secondaryColor": {
            "description": "Secondary brand colour as a 6-digit hex code. Omitting it resets to the default.",
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$"
          },
          "chartPalette": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "description": "Chart series colours as `#rrggbb` in series order (up to ten). Branding: omitting it resets charts to the stock palette."
          },
          "fontFamily": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "pattern": "^[A-Za-z0-9 ,'\"_.-]+$",
            "description": "Font family name for the app's text, chart labels and exported workbooks. Branding: omitting it resets to the stock type."
          },
          "logoKey": {
            "type": "string",
            "maxLength": 512,
            "description": "Storage key returned by POST /workspace/settings/logo for this workspace. Keys from other workspaces or namespaces are rejected."
          }
        }
      },
      "CustomizationTargetScope": {
        "type": "string",
        "description": "Which SHARED document of a single-document customization surface (the home page, a table's record layout, the navigation) a write or a delete is about.\n\n`workspace` is the default arrangement everyone inherits. `group` targets one group and wins over the workspace document for a member whose ACTIVE GROUP it is (see `/me/active-group`). Both are workspace configuration and need `customization:manage`.\n\nA caller's PERSONAL document is deliberately not addressable here. It is not a shared document and it is never written for somebody else, so it has its own endpoints (`/workspace/homepage/mine`, `/tables/{tableId}/record-layout/mine`) whose owner is the authenticated caller and cannot be named in a request at all. See `CustomizationResolvedScope` for the tier order.\n\nTargeting changes ARRANGEMENT ONLY. It never narrows or widens what data a caller can see: records, fields and their scopes are settled by the permission model on the record endpoints, and a member continues to see everything shared with every group they belong to whichever group is active.",
        "enum": [
          "workspace",
          "group"
        ]
      },
      "CustomizationResolvedScope": {
        "type": "string",
        "description": "Which tier answered a resolving read — reported so a reader can be told what they are looking at rather than left to guess.\n\nResolution is `user` > `group` > `workspace`: the caller's own document if they have made one, else the document written for their ACTIVE GROUP, else the workspace's. `user` is the extra value this carries over `CustomizationTargetScope`, because a personal arrangement can be RESOLVED for its owner but is never a shared document anyone addresses.\n\nA client that sees `user` should say so and offer a way back to the inherited arrangement: a personal setting that silently wins over a team's is the single most-repeated complaint in the competitor research this tier comes from (`docs/OPERATIVE_EXPERIENCE_RESEARCH.md` §5.8).",
        "enum": [
          "workspace",
          "group",
          "user"
        ]
      },
      "CustomizationTarget": {
        "type": "object",
        "description": "One configured document of a single-document customization surface.",
        "required": [
          "ownerScope"
        ],
        "properties": {
          "ownerScope": {
            "$ref": "#/components/schemas/CustomizationTargetScope"
          },
          "ownerGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The targeted group, set only when `ownerScope` is `group`."
          }
        }
      },
      "CustomizationTargetGroup": {
        "type": "object",
        "description": "A group a customization document can be targeted at.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "description": "Id of the group, as passed in a customization document's `ownerGroupId`.",
            "type": "string"
          },
          "name": {
            "description": "Display name of the group for the audience picker.",
            "type": "string"
          }
        }
      },
      "CustomizationTargets": {
        "type": "object",
        "description": "Which documents a single-document customization surface already has, and which groups can be targeted. Carries the group list itself so composing an audience needs `customization:manage` alone — `groups:read` is a separate grant an admin of the app's look need not hold.",
        "required": [
          "targets",
          "groups"
        ],
        "properties": {
          "targets": {
            "description": "The documents this surface already has, one per owner scope that has been configured (the workspace default and each targeted group). Lets the editor show which audiences are already customized.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomizationTarget"
            }
          },
          "groups": {
            "description": "Every group a new document could be targeted at, by id and name. Included here so composing an audience needs no separate `groups:read` call.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomizationTargetGroup"
            }
          }
        }
      },
      "MyActiveGroup": {
        "type": "object",
        "description": "The caller's active group in this workspace — which group's ARRANGEMENT (home page, record layouts, default list view) they see when more than one could apply, and the groups they could choose instead.\n\nThis is a presentation preference, not a session mode: it never changes which records or fields the caller can read, and it is not an authorization input anywhere on the server.",
        "required": [
          "groupId",
          "groups"
        ],
        "properties": {
          "groupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The EFFECTIVE active group: the caller's stored choice when they have made one and still belong to that group, otherwise their only group when they have exactly one (one candidate is not a tiebreak), otherwise null — meaning the workspace's own arrangement."
          },
          "groups": {
            "type": "array",
            "description": "The caller's own active groups, name-ordered. A workspace-wide group list is `GET /groups` and needs `groups:read`; this needs nothing, because it is a fact about the caller.",
            "items": {
              "$ref": "#/components/schemas/CustomizationTargetGroup"
            }
          }
        }
      },
      "SetActiveGroupRequest": {
        "description": "Request body of `PUT /me/active-group`: which of the caller's groups should drive the arrangement they see (home page, record layouts, default views). A presentation preference only, never an authorization input.",
        "type": "object",
        "required": [
          "groupId"
        ],
        "properties": {
          "groupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The group to make active, which must be one the caller belongs to. `null` pins the workspace's own arrangement explicitly — distinct from having chosen nothing, which lets a sole group apply by default."
          }
        }
      },
      "RecordLayoutSection": {
        "type": "object",
        "description": "A named group of fields on the record page. Fields render in the order listed; ids that no longer resolve are skipped.",
        "required": [
          "id",
          "title",
          "fieldIds"
        ],
        "properties": {
          "id": {
            "description": "Client-chosen identifier, unique within the layout; tabs refer to sections by it, so keep it stable across edits.",
            "type": "string",
            "maxLength": 64
          },
          "title": {
            "description": "Heading shown above the section's fields (1–120 characters).",
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "fieldIds": {
            "description": "The fields shown in this section, in render order, by id (up to 200): a field's id or a computed column's (`DerivedField.id`), never a name. A field named in no section falls into the automatic \"Details\" section; an id that no longer resolves is skipped.",
            "type": "array",
            "maxItems": 200,
            "items": {
              "type": "string",
              "maxLength": 64
            }
          },
          "collapsed": {
            "type": "boolean",
            "description": "Render collapsed by default."
          },
          "visibleWhen": {
            "$ref": "#/components/schemas/RecordCondition"
          },
          "foldLabel": {
            "type": "string",
            "maxLength": 80,
            "description": "What the folded section says beside its title when `visibleWhen` is false (default \"Not usually needed here\")."
          }
        }
      },
      "RecordCondition": {
        "description": "A `RecordFilter` evaluated against ONE record on the client, live, against the form as it is being edited — so a section reacts as the stage picklist changes, not at save. Same grammar and operator table as the records API filter; the server validates its shape and size only.\n\n**A condition folds, it never hides.** When it is false the section or block renders collapsed with its title and `foldLabel`, and expands on click: the reader loses the clutter and keeps the data, the admin cannot use a condition as a permission, and a field in a folded section is still on the page, still editable, still saved. A condition naming a field the viewer cannot read, or one this client cannot evaluate (a stage clock), is indeterminate and reads as visible.",
        "allOf": [
          {
            "$ref": "#/components/schemas/RecordFilter"
          }
        ]
      },
      "RecordActionKind": {
        "type": "string",
        "description": "The verbs a record page can offer in its header (M8.6 of\ndocs/WORKSPACE_UI_CUSTOMIZATION.md). A closed registry, like\n`RecordLayoutBlockKind`: a kind this client does not know is skipped,\nand one the server does not know is rejected on write. There are\ndeliberately no free-text URLs and no scripts — the escape hatch that\nmakes a competitor's operative pages unmaintainable is the thing this\nregistry exists to refuse.\n  createRelated   — open a child table's create form with the\n                    reference back to this record filled in\n  requestApproval — submit the edits on the form for approval instead\n                    of saving them directly\n  moveStage       — move the record to one named value of one stage\n                    field: the stage panel's button, in the header\n  runFlow         — run one manually-triggerable flow on this record\n",
        "enum": [
          "createRelated",
          "requestApproval",
          "moveStage",
          "runFlow"
        ]
      },
      "RecordAction": {
        "type": "object",
        "description": "One action button on the record page's header. Which keys apply depends on `kind`, the way `RecordLayoutBlock`'s do: `createRelated` needs `tableId` and `fieldName`, `moveStage` needs `stageField` and `toValue`, `runFlow` needs `flowId`, and `requestApproval` needs nothing further.\n\n**An action the viewer cannot reach is SKIPPED, never shown disabled** — a page composed for an audience should not advertise what that audience cannot do. Reachability is judged per kind at render time: the permission the action's endpoint requires, and whether the thing it names still resolves (a deleted child table, a flow that is disabled or unpublished, a stage move the record's machine or its per-transition actor gate does not allow). None of that is an authorization decision — every endpoint behind an action applies its own permission when pressed. It is presentation, and the server remains the one that refuses.\n\n**`visibleWhen` on an action HIDES it**, which is the opposite of what the same key does on a section or block. That is deliberate rather than inconsistent: the rule a layout can never break is that it must not hide DATA, and an action is not data — it is a verb, and an inapplicable verb is noise. A field stays on the page whatever its condition says; a \"Mark as won\" button does not have to.",
        "required": [
          "id",
          "kind"
        ],
        "properties": {
          "id": {
            "description": "Client-chosen key for the action, unique within the layout, up to 64 characters. Keep it stable across edits so the action keeps its identity when its label or settings change.",
            "type": "string",
            "maxLength": 64
          },
          "kind": {
            "$ref": "#/components/schemas/RecordActionKind"
          },
          "label": {
            "type": "string",
            "maxLength": 60,
            "description": "Button text. Each kind names itself when this is absent (\"Add Invoice\", \"Mark as won\"), so an admin sets it only to say something the default cannot."
          },
          "tableId": {
            "type": "string",
            "maxLength": 64,
            "description": "createRelated — the child table whose create form opens."
          },
          "fieldName": {
            "type": "string",
            "maxLength": 255,
            "description": "createRelated — the reference field on that child table holding the link back to this record, pre-filled with this record's id."
          },
          "stageField": {
            "type": "string",
            "maxLength": 255,
            "description": "moveStage — fieldName of the stage field to move."
          },
          "toValue": {
            "type": "string",
            "maxLength": 255,
            "description": "moveStage — the value to move to. Offered only when the record's stage machine (and its actor gate) allows that move from where the record is now, so the button is absent elsewhere in the process rather than failing when pressed."
          },
          "flowId": {
            "type": "string",
            "maxLength": 64,
            "description": "runFlow — the flow to run on this record. It must be enabled, published, and triggered by a record action; otherwise the button is skipped."
          },
          "visibleWhen": {
            "$ref": "#/components/schemas/RecordCondition"
          }
        }
      },
      "RecordLayoutBlockKind": {
        "type": "string",
        "description": "The panels a record page is composed of, beside its field sections\n(M8.1 of docs/WORKSPACE_UI_CUSTOMIZATION.md). A closed registry: a\nkind this client does not know is skipped, and one the server does\nnot know is rejected on write.\n  stageProgress — where the record is in its process and the legal\n                  next moves as buttons\n  relatedLists  — the child-record groups (ordered by `relatedLists`)\n  activities    — the record's tasks and logged activities\n  comments      — the discussion thread\n  history       — the change history (audit:read)\n  stageHistory  — where the record has been, and for how long\n  automations   — which flows touched this record\n  markdown      — admin-authored guidance text, usually with a\n                  `visibleWhen` so it appears at one stage\n  chart         — a saved chart drawn from a table's records,\n                  narrowed to this record (see `chart`)\n  extension     — an app extension of the workspace's hosted\n                  site, shown in an iframe (see `extension`)\n",
        "enum": [
          "stageProgress",
          "relatedLists",
          "activities",
          "comments",
          "history",
          "stageHistory",
          "automations",
          "markdown",
          "chart",
          "extension"
        ]
      },
      "RecordLayoutBlock": {
        "type": "object",
        "description": "One placeable panel. Turning a block off (leaving it out of `blocks`) decides whether the page ASKS for that panel; the endpoint behind it still applies its own permission and scoping, exactly as `showHistory` did. Every kind except `markdown`, `chart` and `extension` may appear at most once; a layout holds at most four `extension` blocks.",
        "required": [
          "id",
          "kind"
        ],
        "properties": {
          "id": {
            "description": "Client-chosen key for the block, unique within the layout (up to 64 characters), so the editor can track it across saves.",
            "type": "string",
            "maxLength": 64
          },
          "kind": {
            "$ref": "#/components/schemas/RecordLayoutBlockKind"
          },
          "title": {
            "type": "string",
            "maxLength": 120,
            "description": "Heading for a `markdown` block; other kinds title themselves."
          },
          "collapsed": {
            "type": "boolean",
            "description": "Render collapsed by default."
          },
          "markdown": {
            "type": "string",
            "maxLength": 4000,
            "description": "The text of a `markdown` block."
          },
          "chart": {
            "$ref": "#/components/schemas/RecordLayoutChartBlock"
          },
          "extension": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ExtensionPlacement"
              }
            ],
            "description": "Which app extension an `extension` block shows. Required when `kind` is `extension`, and refused with 400 on any other kind. The site is resolved server-side against the workspace's own sites."
          },
          "visibleWhen": {
            "$ref": "#/components/schemas/RecordCondition"
          },
          "foldLabel": {
            "description": "What the folded block says beside its title when `visibleWhen` is false (default \"Not usually needed here\").",
            "type": "string",
            "maxLength": 80
          }
        }
      },
      "RecordLayoutChartBlock": {
        "type": "object",
        "description": "What a `chart` block draws: a saved chart, named by id and never copied, so the chart the admin authored is the single source of truth for how it looks and what it measures.\n\nThe chart must be one drawn from a table's records (`ChartConfig.source`); a chart backed by SQL is not drawn here and the block says so instead. That is deliberate rather than a limitation: `POST /query` refuses viewers whose record visibility is restricted, which is most of the audience a curated record page is composed for, so a SQL chart on this page would be a panel that fails for the people meant to read it.\n\n`recordField` is how the chart is narrowed to THIS record: the fieldName on the chart's own table that points back at it (the reference field a related list would group by). The condition is AND-ed onto the chart's filter and then onto the viewer's row scope, exactly as a related list drawn as a saved view is. Left out, the chart is drawn unnarrowed — the same numbers it shows on a dashboard, as context beside the record.",
        "required": [
          "chartId"
        ],
        "properties": {
          "chartId": {
            "description": "Id of the saved chart to draw. The chart must be record-sourced (`ChartConfig.source`); a SQL-backed chart is not drawn and the block says so.",
            "type": "string",
            "maxLength": 64
          },
          "recordField": {
            "type": "string",
            "maxLength": 255,
            "description": "fieldName on the chart's table holding the reference to this record. A field that no longer resolves leaves the chart unnarrowed rather than silently wrong, and the page says so."
          }
        }
      },
      "RecordLayoutRelatedList": {
        "type": "object",
        "description": "One related-records group (child records pointing at this record through a reference field), identified by the child table.",
        "required": [
          "tableId"
        ],
        "properties": {
          "tableId": {
            "description": "The child table whose records point at this record; identifies the group within the layout.",
            "type": "string",
            "maxLength": 64
          },
          "title": {
            "description": "Heading shown above the group. Defaults to the child table's display name when absent.",
            "type": "string",
            "maxLength": 120
          },
          "hidden": {
            "type": "boolean",
            "description": "Configured off — the group is not rendered."
          },
          "savedViewId": {
            "type": "string",
            "maxLength": 64,
            "description": "Draw the related records as one of the child table's shared saved views — its columns, sort and kind (a gallery of site photos, a calendar of visits) — filtered to the records that point at this one. The rows come from `GET /tables/{tableId}/items`, so record scoping applies as on the records page. Absent, the group renders as a plain list of record titles. A soft reference, like every id here: a view that no longer resolves falls back to the plain list."
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 50,
            "description": "Rows to show before \"and N more\" (default 10)."
          },
          "allowCreate": {
            "type": "boolean",
            "description": "Offer an \"Add\" button that opens the child table's create form with the reference to this record pre-filled (default true; set false to take it off this group). Presentation only — the button is shown only to viewers who may create records, and the create endpoint still applies the caller's permissions."
          }
        }
      },
      "RecordLayoutTab": {
        "type": "object",
        "description": "One tab of a record page (M8.4). Tabs are a layer over sections and blocks: each names the section and block ids it shows, in order. The first tab is always present and holds the highlight strip; anything no tab names renders on it too, so a section added later is never lost. A tab whose `visibleWhen` is false renders last and folded — still reachable, never removed.",
        "required": [
          "id",
          "title"
        ],
        "properties": {
          "id": {
            "description": "Client-chosen identifier, unique within the layout, so a tab keeps its identity when retitled or reordered.",
            "type": "string",
            "maxLength": 64
          },
          "title": {
            "description": "The tab's label (1–60 characters).",
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "sectionIds": {
            "description": "Section ids shown on this tab, in order (up to 30). A section no tab names is rendered on the first tab.",
            "type": "array",
            "maxItems": 30,
            "items": {
              "type": "string",
              "maxLength": 64
            }
          },
          "blockIds": {
            "description": "Block (panel) ids shown on this tab, in order (up to 30). A block no tab names is rendered on the first tab.",
            "type": "array",
            "maxItems": 30,
            "items": {
              "type": "string",
              "maxLength": 64
            }
          },
          "visibleWhen": {
            "$ref": "#/components/schemas/RecordCondition"
          },
          "foldLabel": {
            "description": "What the folded tab says when its `visibleWhen` is false; the default wording is used when absent.",
            "type": "string",
            "maxLength": 80
          }
        }
      },
      "RecordLayout": {
        "type": "object",
        "description": "How a record page is composed. Everything is optional: an empty layout renders the default page. Field ids — a field's or a computed column's (`DerivedField.id`) — are resolved at render time, and fields not named anywhere fall into an auto-generated \"Details\" section, so a layout can never hide data from someone allowed to see it. A computed column appears on the page only where the layout places it.",
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "description": "Stored-shape version, stamped by the server on write."
          },
          "titleFieldId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Field whose value titles the record page."
          },
          "highlightFieldIds": {
            "type": "array",
            "maxItems": 8,
            "description": "Fields pinned to the header strip.",
            "items": {
              "type": "string",
              "maxLength": 64
            }
          },
          "sections": {
            "description": "Named groups of fields in page order, each listing the field ids it shows. Fields in no section fall into the auto-generated Details section; at most 30 sections.",
            "type": "array",
            "maxItems": 30,
            "items": {
              "$ref": "#/components/schemas/RecordLayoutSection"
            }
          },
          "relatedLists": {
            "description": "Settings for the child-record groups shown on the page, one per child table: title, whether hidden, the saved view to draw them with and the row limit. Child tables not listed render with defaults; at most 30 entries.",
            "type": "array",
            "maxItems": 30,
            "items": {
              "$ref": "#/components/schemas/RecordLayoutRelatedList"
            }
          },
          "showHistory": {
            "type": "boolean",
            "description": "Show the record's change history on the page (default true). The history endpoint still applies its own permission and scoping — this only decides whether the page asks for it. Superseded by a `history` block when `blocks` is present; kept so layouts written before blocks existed, and clients that predate them, keep their meaning."
          },
          "blocks": {
            "type": "array",
            "maxItems": 30,
            "description": "The page's panels in order, after the highlight strip and field sections. Absent means the built-in order with every panel on (history per `showHistory`); present means exactly these, in this order.",
            "items": {
              "$ref": "#/components/schemas/RecordLayoutBlock"
            }
          },
          "tabs": {
            "type": "array",
            "maxItems": 6,
            "description": "Tabs over the sections and blocks (M8.4). Absent or empty means a flat page.",
            "items": {
              "$ref": "#/components/schemas/RecordLayoutTab"
            }
          },
          "actions": {
            "type": "array",
            "maxItems": 6,
            "description": "Verbs offered in the page header (M8.6). Order is the order they are drawn; one the viewer cannot reach is skipped, so the row is what THIS reader can actually do.",
            "items": {
              "$ref": "#/components/schemas/RecordAction"
            }
          }
        }
      },
      "TableRecordLayout": {
        "description": "The record-page layout resolved for the caller on one table, returned by the record-layout endpoints: which customization document (workspace, group or personal) was picked, its arrangement, and who last saved it.",
        "type": "object",
        "required": [
          "configured",
          "layout"
        ],
        "properties": {
          "configured": {
            "type": "boolean",
            "description": "False when no admin has configured this table's record page; the client then renders its default layout."
          },
          "layout": {
            "$ref": "#/components/schemas/RecordLayout"
          },
          "ownerScope": {
            "$ref": "#/components/schemas/CustomizationResolvedScope"
          },
          "ownerGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The group this layout is written for, set only when `ownerScope` is `group`. Together with `ownerScope` this says WHICH document the resolver picked, so a reader can be told they are looking at their group's arrangement, their own, or the workspace's."
          },
          "updatedBy": {
            "description": "Id of the user who last saved the document that was picked; null when unknown or when `configured` is false.",
            "type": [
              "string",
              "null"
            ]
          },
          "updatedAt": {
            "description": "When the picked layout document was last saved, ISO-8601 UTC; absent when `configured` is false.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "UpdateMyRecordLayoutRequest": {
        "type": "object",
        "description": "A record layout written for the caller alone. Carries no targeting: the owner is the authenticated user and cannot be named in the request, so this body can never reach somebody else's layout or a shared one.\n\nEvery place a layout names a value — `titleFieldId`, `highlightFieldIds`, each section's `fieldIds` — takes an ID, never a name: a field's `id`, or a computed column's `id` (`DerivedField.id`, listed by the table's derived-fields operation and by the MCP `get_table_schema` tool under `computedColumns`). The write is refused with 400 `LAYOUT_UNKNOWN_FIELD_IDS` when an id is neither a field of the table nor a computed column the caller can see; ids already stored that stop resolving later are skipped on render, not refused.",
        "properties": {
          "titleFieldId": {
            "description": "Field whose value titles the record page; null to fall back to the table's default title field.",
            "type": [
              "string",
              "null"
            ]
          },
          "highlightFieldIds": {
            "description": "Fields pinned to the header strip, in order (up to 8).",
            "type": "array",
            "maxItems": 8,
            "items": {
              "type": "string",
              "maxLength": 64
            }
          },
          "sections": {
            "description": "The field sections of the page, in order (up to 30). Fields named in no section fall into an automatic \"Details\" section.",
            "type": "array",
            "maxItems": 30,
            "items": {
              "$ref": "#/components/schemas/RecordLayoutSection"
            }
          },
          "relatedLists": {
            "description": "The related-record lists shown on the page, in order (up to 30).",
            "type": "array",
            "maxItems": 30,
            "items": {
              "$ref": "#/components/schemas/RecordLayoutRelatedList"
            }
          },
          "showHistory": {
            "description": "Whether the page shows the record's change history (default true). Superseded by a `history` block when `blocks` is present.",
            "type": "boolean"
          },
          "blocks": {
            "description": "The page's panels in order after the sections (up to 30). Omit for the built-in panel order; present means exactly these.",
            "type": "array",
            "maxItems": 30,
            "items": {
              "$ref": "#/components/schemas/RecordLayoutBlock"
            }
          },
          "tabs": {
            "description": "Tabs over the sections and blocks (up to 6). Omit or send empty for a flat page.",
            "type": "array",
            "maxItems": 6,
            "items": {
              "$ref": "#/components/schemas/RecordLayoutTab"
            }
          },
          "actions": {
            "description": "Verbs offered in the page header, in order (up to 6); ones the viewer cannot perform are skipped at render time.",
            "type": "array",
            "maxItems": 6,
            "items": {
              "$ref": "#/components/schemas/RecordAction"
            }
          }
        }
      },
      "RecordLayoutRefusal": {
        "description": "Why a record layout was not stored. `error` says what is wrong; when the layout named ids that are not fields of the table or computed columns the caller can see, `code` is `LAYOUT_UNKNOWN_FIELD_IDS` and `unknownFieldIds` lists them. The usual cause is a field NAME where an id belongs: fix the listed entries by looking the ids up in the table's fields and computed columns.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ErrorResponse"
          },
          {
            "type": "object",
            "properties": {
              "unknownFieldIds": {
                "type": "array",
                "description": "The ids the layout named that resolve to nothing on this table, each once, in the order they first appeared. Present only with `LAYOUT_UNKNOWN_FIELD_IDS`.",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        ]
      },
      "UpdateRecordLayoutRequest": {
        "description": "Full-replace update of a SHARED record layout — the workspace's, or one group's. The layout itself is `UpdateMyRecordLayoutRequest`'s, so the two write paths can never describe a page differently; what this adds is which shared document to write.",
        "allOf": [
          {
            "$ref": "#/components/schemas/UpdateMyRecordLayoutRequest"
          },
          {
            "type": "object",
            "properties": {
              "ownerScope": {
                "$ref": "#/components/schemas/CustomizationTargetScope"
              },
              "ownerGroupId": {
                "type": "string",
                "minLength": 12,
                "maxLength": 12,
                "pattern": "^[0-9a-f]{12}$",
                "description": "Required when `ownerScope` is `group`; ignored otherwise."
              }
            }
          }
        ]
      },
      "SavedViewOwnerScope": {
        "type": "string",
        "description": "Who a saved view belongs to. `user` is private to its creator — only they can see, change or delete it. `workspace` is shared with everyone who can read the table, and creating or changing one requires `customization:manage`; reading a shared view needs only `customization:read`.\n\n`group` sits between the two: shared with one group's members and invisible to everyone else, so Sales and Finance can each keep their own arrangement of the same table without imposing it on the other. Writing one is workspace configuration like a shared view and needs `customization:manage`; the group must be an active group of this workspace, but the author need not belong to it — an admin composes for an audience they are not part of. A holder of `customization:manage` can therefore also SEE every group's views, or they could write one and lose sight of it.\n\nWhich of several applicable views a surface OPENS with is decided by the caller's active group (`/me/active-group`), so two groups' defaults never need a priority rule.",
        "enum": [
          "workspace",
          "group",
          "user"
        ]
      },
      "SavedViewSort": {
        "type": "object",
        "description": "The view's ordering, in the same vocabulary as the `sort`/`order` query parameters.",
        "required": [
          "field"
        ],
        "properties": {
          "field": {
            "description": "What to order by: a `fieldName` on the table, a system column (`id`, `createdAt`, `updatedAt`) or a stage clock (`<stageField>.enteredAt`, `<stageField>.activeSeconds`) — the same values the records endpoint's `sort` parameter accepts. A soft reference: a name that no longer resolves is ignored at render time.",
            "type": "string",
            "maxLength": 255
          },
          "order": {
            "type": "string",
            "description": "Sort direction; ascending when omitted.",
            "enum": [
              "asc",
              "desc"
            ]
          }
        }
      },
      "SavedViewColumn": {
        "type": "object",
        "description": "One column's presentation. `hidden` removes it from THIS VIEW's grid only — it is not a permission, and the record endpoints still return the field to anyone whose field permissions allow it.",
        "required": [
          "field"
        ],
        "properties": {
          "field": {
            "description": "Name of the field this column shows, matched against the table's field names (not its display name).",
            "type": "string",
            "maxLength": 255
          },
          "hidden": {
            "description": "True to leave the column out of this view's grid while keeping its position and width settings. Omitted means shown.",
            "type": "boolean"
          },
          "width": {
            "description": "Column width in CSS pixels, 40 to 2000. Omitted means the grid's default for the field type.",
            "type": "integer",
            "minimum": 40,
            "maximum": 2000
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "description": "Header text for this column in THIS VIEW, in place of the field's display name — \"Owner\" over a field called \"Account manager\" for a team that calls it that. Presentation only: it renames nothing, and every other surface (the record page, the API, exports) keeps the field's own name."
          }
        }
      },
      "CalendarFeedSource": {
        "type": "object",
        "description": "What a calendar feed publishes: the rows of one table or SQL view, read with the permissions of the member who owns the feed, each placed on a calendar from its own values. The feed is the same read the records list (`GET /tables/{tableId}/items`) makes: the owner's row scope and field masking apply, a SQL view is read only when the owner may read every table its definition names, and `filter` only ever narrows that. A resolved view (one row per stretch of time, say) publishes as easily as a table of bookings.\n\nOnly rows that overlap the window from `pastDays` before the fetch to `futureDays` after it are published. Field names are checked when the feed is created and again on every fetch; a field that has since been deleted, retyped or hidden from the owner makes the feed publish no events and report the reason in `CalendarFeed.problem`.",
        "required": [
          "tableId",
          "startField",
          "titleField"
        ],
        "properties": {
          "tableId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "description": "The table or SQL view whose rows become events."
          },
          "filter": {
            "$ref": "#/components/schemas/RecordFilter"
          },
          "startField": {
            "type": "string",
            "maxLength": 255,
            "description": "The `date` or `datetime` field an event starts at. A `date` field makes all-day events. On a feed with an `endField`, an empty start means \"open-ended\" and the event starts at the window's start; without one, a row with no start is left out."
          },
          "endField": {
            "type": "string",
            "maxLength": 255,
            "description": "Optional. The `date` or `datetime` field an event ends at, of the same type as `startField`. A `date` end is the last day the event covers (inclusive). An empty end means \"open-ended\" and the event runs to the window's end. Absent means every event lasts `defaultDurationMinutes` (a `datetime` start) or one day (a `date` start)."
          },
          "titleField": {
            "type": "string",
            "maxLength": 255,
            "description": "The field whose value is each event's title."
          },
          "descriptionField": {
            "type": "string",
            "maxLength": 255,
            "description": "Optional. The field whose value is each event's description, as plain text."
          },
          "locationField": {
            "type": "string",
            "maxLength": 255,
            "description": "Optional. A text or `address` field whose value is each event's location; an address is written out as its parts, comma-separated."
          },
          "identityFields": {
            "type": "array",
            "maxItems": 5,
            "description": "Optional, SQL views only: the columns that together say which row is \"the same event\" from one fetch to the next, so a calendar updates an event in place rather than replacing it. A table's record id always identifies its events and this must be absent. On a view with none given, the view's `id` column is used when it projects one; otherwise an event's identity is its row's values, so any change to a row publishes it as a new event.",
            "items": {
              "type": "string",
              "maxLength": 255
            }
          },
          "pastDays": {
            "type": "integer",
            "minimum": 0,
            "maximum": 366,
            "default": 30,
            "description": "How many days before the fetch the published window starts."
          },
          "futureDays": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1096,
            "default": 365,
            "description": "How many days after the fetch the published window ends."
          },
          "defaultDurationMinutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1440,
            "default": 60,
            "description": "How long an event with a `datetime` start lasts when the feed has no `endField`."
          }
        }
      },
      "CalendarFeed": {
        "type": "object",
        "description": "A calendar feed: a secret address a calendar app (Google Calendar, Outlook, Apple Calendar) subscribes to, serving the events its `source` describes as an iCalendar (RFC 5545) document. The app re-fetches the address on its own schedule, so the calendar follows the data without anyone pushing it; it is read-only on the calendar's side. A feed belongs to the member who created it and always reads with that member's current permissions. The address itself is shown only when the feed is created or its link is reset.",
        "required": [
          "id",
          "name",
          "source",
          "problem",
          "createdAt",
          "linkIssuedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The feed's identifier."
          },
          "name": {
            "type": "string",
            "description": "The calendar's name, as a calendar app shows it when subscribing."
          },
          "source": {
            "$ref": "#/components/schemas/CalendarFeedSource"
          },
          "problem": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the feed currently publishes no events (a field it names was deleted, retyped or hidden from you, or its table is gone), or null when it reads normally. Checked when the list is read."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the feed was created."
          },
          "linkIssuedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the feed's current address was issued: its creation, or the last time its link was reset. Addresses issued before this no longer work."
          }
        }
      },
      "CalendarFeedCreateRequest": {
        "type": "object",
        "description": "A new calendar feed of the caller's own.",
        "required": [
          "name",
          "source"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "The calendar's name, as a calendar app shows it when subscribing."
          },
          "source": {
            "$ref": "#/components/schemas/CalendarFeedSource"
          }
        }
      },
      "CalendarFeedLink": {
        "type": "object",
        "description": "A feed and its secret address, returned only when the feed is created or its link is reset. Anyone holding the address can read the events it publishes, so treat it like a password; resetting the link retires the old one.",
        "required": [
          "feed",
          "url"
        ],
        "properties": {
          "feed": {
            "$ref": "#/components/schemas/CalendarFeed"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The `https` address of the iCalendar document. Paste it into a calendar app's \"subscribe from URL\"; the same address with the `webcal` scheme opens the subscribe dialog of Apple Calendar and Outlook directly."
          }
        }
      },
      "SavedViewKind": {
        "type": "string",
        "description": "Which surface renders this view's rows. `grid` when absent, so every view saved before this field existed keeps working unchanged.\n\nThe kind decides only HOW the rows are drawn — the rows themselves are the same `GET /tables/{tableId}/items` result under the same filter, sort and permissions in every kind. A calendar is a grid whose rows are placed on a date; a map is a grid whose rows are placed on a coordinate; a board is a grid whose rows are laid out in lanes, one per value of a stage field.",
        "enum": [
          "grid",
          "gallery",
          "calendar",
          "map",
          "board"
        ],
        "default": "grid"
      },
      "SavedViewGalleryConfig": {
        "type": "object",
        "description": "Which fields a gallery card draws. Every one is optional: a card with none falls back to the table's own field order, and a field that no longer resolves is skipped rather than failing the view.",
        "properties": {
          "titleField": {
            "type": "string",
            "maxLength": 255,
            "description": "The field shown as the card's heading."
          },
          "imageField": {
            "type": "string",
            "maxLength": 255,
            "description": "An `attachment` field whose image is the card's media. A record whose attachment is missing or is not an image gets the neutral placeholder — never a broken image and never a hidden card."
          },
          "summaryFields": {
            "type": "array",
            "maxItems": 6,
            "description": "Fields listed under the title. A cap, not a permission: the rest of the record is still on the record page and still returned by the API.",
            "items": {
              "type": "string",
              "maxLength": 255
            }
          }
        }
      },
      "SavedViewCalendarConfig": {
        "type": "object",
        "description": "Which date a calendar places its records on. `dateField` is required when the view's kind is `calendar` — a calendar over nothing has no meaning, and defaulting to \"the first date field we find\" would silently change which records appear when a field is added.",
        "required": [
          "dateField"
        ],
        "properties": {
          "dateField": {
            "type": "string",
            "maxLength": 255,
            "description": "A `date` or `datetime` field, a `recurrence` field, or the `createdAt` / `updatedAt` record column. Records whose value is empty cannot be placed in a day cell and are excluded from the grid — the renderer says how many rather than dropping them silently. On a `recurrence` field the calendar draws one chip per occurrence in the weeks on screen (the field's `occurrences` operation), so one record appears on every day its series falls."
          },
          "colorField": {
            "type": "string",
            "maxLength": 255,
            "description": "Optional. A `picklist` field whose option colour tints each record's chip, so a calendar of jobs reads by status at a glance. A record whose value is empty, or names an option without a colour, gets the neutral chip. Absent means every chip is neutral."
          }
        }
      },
      "SavedViewMapConfig": {
        "type": "object",
        "description": "Which coordinate a map places its records on. Required when the view's kind is `map`, for the same reason a calendar needs its date.",
        "required": [
          "locationField"
        ],
        "properties": {
          "locationField": {
            "type": "string",
            "maxLength": 255,
            "description": "A `geolocation` field (`{ latitude, longitude }`). Records whose value is empty have no marker and are reported rather than dropped silently."
          },
          "dateField": {
            "type": "string",
            "maxLength": 255,
            "description": "Optional. A `date` or `datetime` field, or the `createdAt` / `updatedAt` record column, that puts the markers in an order: the map numbers them chronologically and joins consecutive ones, so a day's visits or a delivery run reads as a route. Records with a coordinate but no value here are still on the map, unnumbered and outside the route. Absent means markers carry no order."
          }
        }
      },
      "SavedViewBoardConfig": {
        "type": "object",
        "description": "Which stage field a board lays its records out by, and which number field, if any, each lane totals. `stageField` is required when the view's kind is `board`, for the same reason a calendar needs its date: defaulting to \"the first stage field we find\" would silently change the lanes when another stage field is designated. Every lane draws the view's records — its `filter`, in its `sort` order — and the lane's count (and total) is computed on the server over every record the filter selects, not just the cards drawn.",
        "required": [
          "stageField"
        ],
        "properties": {
          "stageField": {
            "type": "string",
            "maxLength": 255,
            "description": "A stage-designated `picklist` field. Each active stage is a lane; records whose value is retired, undeclared or empty land in catch-all lanes rather than being dropped."
          },
          "sumField": {
            "type": "string",
            "maxLength": 255,
            "description": "Optional. A `number` field summed per lane and shown beside the lane's count — a pipeline's value per stage. Absent means lanes show only their counts."
          }
        }
      },
      "SavedViewConfig": {
        "type": "object",
        "description": "What a saved view remembers: which rows (filter), in what order (sort), with which columns shown, ordered and sized — and, since schemaVersion 2, how those rows are drawn (`kind` plus that kind's settings).\n\n**A view can never hide data.** Columns it does not mention are appended in the table's own field order — including fields added after the view was saved — and `hidden` affects only this grid. Which fields exist for a caller at all is settled by field permissions on the record endpoints; the view only orders, filters and groups. Field names are soft references validated for shape, not existence: a view naming a since-deleted field still loads, and the renderer skips what it cannot resolve.\n\nThe same holds for `kind`: a gallery card showing three fields, or a calendar placing records on one date, is a statement about THIS rendering. It changes nothing about what the record endpoints return, and every kind draws the same rows the grid would.",
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "description": "Stored-shape version, stamped by the server on write."
          },
          "kind": {
            "$ref": "#/components/schemas/SavedViewKind"
          },
          "filter": {
            "$ref": "#/components/schemas/RecordFilter"
          },
          "sort": {
            "$ref": "#/components/schemas/SavedViewSort"
          },
          "thenBy": {
            "type": "array",
            "maxItems": 2,
            "description": "Further sort keys applied after `sort`, in order — \"by stage, then by amount\". Meaningless without `sort`, and refused with it absent; a key that repeats `sort` or another entry is refused too. Sent to the list endpoint as the extra comma-separated names of its `sort` parameter.",
            "items": {
              "$ref": "#/components/schemas/SavedViewSort"
            }
          },
          "columns": {
            "description": "Per-column presentation — order, width, visibility, header label — for the fields the view mentions, up to 200. Fields not listed are appended in the table's own order; a view can never hide data.",
            "type": "array",
            "maxItems": 200,
            "items": {
              "$ref": "#/components/schemas/SavedViewColumn"
            }
          },
          "frozenColumns": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5,
            "description": "How many of the leading SHOWN columns stay in place while the grid scrolls sideways — the name column pinned beside a hundred others. Counted over the columns as drawn (hidden ones and the grid's own chrome take no part), so hiding a column never changes which columns are frozen. Absent or 0 means none."
          },
          "rowHeight": {
            "description": "Row density of the grid: `compact` single-line rows, `standard` the default, `tall` taller rows that show more of long text.",
            "type": "string",
            "enum": [
              "compact",
              "standard",
              "tall"
            ]
          },
          "description": {
            "type": "string",
            "maxLength": 500,
            "description": "What this view is for, shown where the view is picked — \"Open deals owned by me, for the Monday stand-up\". Free text for people; nothing reads it."
          },
          "locked": {
            "type": "boolean",
            "description": "A locked view refuses changes to its `config` — filter, sort, columns, kind — until it is unlocked, so a shared view a whole team relies on is not rewritten by an accidental \"Update view\". A write that would change a locked view's config is refused with 409 `VIEW_LOCKED` unless that same write sets `locked` back to false. Renaming, re-describing and the default flag are not gated: they do not change what the view shows. Locking is not a permission — whoever may edit the view may unlock it; it exists to make overwriting a deliberate two-step act."
          },
          "lockMessage": {
            "type": "string",
            "maxLength": 200,
            "description": "Why the view is locked, shown to whoever tries to change it — \"Used by the weekly report; ask Dana before editing\". Kept when the view is unlocked so re-locking need not retype it."
          },
          "gallery": {
            "$ref": "#/components/schemas/SavedViewGalleryConfig"
          },
          "calendar": {
            "$ref": "#/components/schemas/SavedViewCalendarConfig"
          },
          "map": {
            "$ref": "#/components/schemas/SavedViewMapConfig"
          },
          "board": {
            "$ref": "#/components/schemas/SavedViewBoardConfig"
          },
          "grouping": {
            "$ref": "#/components/schemas/SavedViewGrouping"
          }
        }
      },
      "SavedViewGrouping": {
        "type": "object",
        "description": "How a grid view groups its rows (#1075): by one to three fields, outermost first, with a row per group at every level carrying the group's record count and the aggregates in `metrics`, computed on the server under the viewer's own row scope (`POST /tables/{tableId}/report`), and the group's records beneath it. Drawn by the grid kind only; the other kinds ignore it. Field names are soft references like every other name in the config: a field that no longer resolves is skipped by the renderer.",
        "required": [
          "fields"
        ],
        "properties": {
          "fields": {
            "type": "array",
            "minItems": 1,
            "maxItems": 3,
            "description": "The fields to group by, outermost first.",
            "items": {
              "type": "string",
              "maxLength": 255
            }
          },
          "metrics": {
            "type": "array",
            "maxItems": 5,
            "description": "Aggregates shown on each group row beside its record count.",
            "items": {
              "$ref": "#/components/schemas/RecordAggregateMetric"
            }
          }
        }
      },
      "SavedView": {
        "description": "A saved list view: a remembered filter, sort and column arrangement over a table's records, owned privately, by a group, or shared with the workspace. Returned by the `/tables/{tableId}/saved-views` endpoints and as each item of `SavedViewList`. Unrelated to SQL views.",
        "type": "object",
        "required": [
          "id",
          "tableId",
          "name",
          "ownerScope",
          "config",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the view, used in the `/tables/{tableId}/saved-views/{viewId}` endpoints and in record layouts and navigation that open it.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "tableId": {
            "description": "The table whose records this view arranges. Fixed at creation; a view cannot be moved to another table.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "name": {
            "description": "Title the view is listed under, 1–80 characters. Unique within its scope: the owner's private views, one group's views, or the workspace's shared views each form their own namespace.",
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "ownerScope": {
            "$ref": "#/components/schemas/SavedViewOwnerScope"
          },
          "ownerUserId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Set only for a `user`-scoped view — the one person who can see it."
          },
          "ownerGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Set only for a `group`-scoped view — the group it is shared with."
          },
          "ownerGroupName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The targeted group's display name, resolved server-side for a `group`-scoped view. Present so a picker can label whose view this is without the reader holding `groups:read`; null when the group has since been deleted, which is also when resolution stops returning the view."
          },
          "isDefault": {
            "type": "boolean",
            "description": "Is this the view a surface opens with when the caller has not picked one? At most one view per (table, kind) can hold it in each scope, so a table has at most one workspace default per kind, each group at most one, and each user at most one personal default.\n\nResolution is user default, then the caller's ACTIVE group's default (`/me/active-group`, so several groups' defaults need no priority rule), then the workspace default, then the table's own `displayOrder`. A workspace default is therefore an admin saying \"this is how this table looks here\", a group default says it for one team, and a personal default overrides both for one person without changing what anyone else sees — which is why marking a SHARED or GROUP view default requires `customization:manage` while marking a private one does not."
          },
          "config": {
            "$ref": "#/components/schemas/SavedViewConfig"
          },
          "watching": {
            "type": "boolean",
            "description": "Whether THE CALLER watches this view — is told, as a `record.viewMatched` notification, when a record enters it. Per caller, never a property of the view: the same shared view is watched by some people and not others. Set through `/tables/{tableId}/saved-views/{viewId}/watch`."
          },
          "createdBy": {
            "description": "User id of the person who created the view. Null when that account no longer exists.",
            "type": [
              "string",
              "null"
            ]
          },
          "updatedBy": {
            "description": "User id of the person who last changed the view's name, config or default flag. Null when that account no longer exists.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the view was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the view was last changed, ISO-8601 UTC; equals `createdAt` until the first edit. Toggling `watching` does not move it.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SavedViewList": {
        "description": "Response of `GET /tables/{tableId}/saved-views`: the list views on a table the caller may use — their own private views, workspace-shared views, and views targeted at a group they belong to.",
        "type": "object",
        "required": [
          "views"
        ],
        "properties": {
          "views": {
            "description": "The saved list views visible to the caller on this table.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SavedView"
            }
          }
        }
      },
      "SavedViewWatch": {
        "description": "Whether the caller is watching a saved view (to be notified when a record enters it). Response of `PUT`/`DELETE /tables/{tableId}/saved-views/{viewId}/watch`.",
        "type": "object",
        "required": [
          "watching"
        ],
        "properties": {
          "watching": {
            "description": "`true` after PUT and `false` after DELETE: whether the caller now receives `record.viewMatched` notifications for this view.",
            "type": "boolean"
          }
        }
      },
      "CreateSavedViewRequest": {
        "description": "Request body of `POST /tables/{tableId}/saved-views`: a new saved view of the table, private to the caller unless `ownerScope` says otherwise.",
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "description": "Display name of the view as it appears in the view switcher; up to 80 characters.",
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "ownerScope": {
            "$ref": "#/components/schemas/SavedViewOwnerScope"
          },
          "ownerGroupId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "Required when `ownerScope` is `group`; ignored otherwise."
          },
          "isDefault": {
            "type": "boolean",
            "description": "Make this the default view for its scope and kind, demoting whichever view held that in the same transaction. Defaults to false."
          },
          "config": {
            "$ref": "#/components/schemas/SavedViewConfig"
          }
        }
      },
      "UpdateSavedViewRequest": {
        "type": "object",
        "description": "Full replace of the mutable parts. `ownerScope` is deliberately absent: promoting a private view to a shared or group one (or back) changes who can see it, so it is a create-and-delete rather than a silent edit.",
        "properties": {
          "name": {
            "description": "New display name of the view; up to 80 characters.",
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "isDefault": {
            "type": "boolean",
            "description": "Set or clear the default for this view's scope and kind. Omitting it leaves the flag as it is, so an ordinary save (a column resized, a filter edited) never disturbs which view is default."
          },
          "config": {
            "$ref": "#/components/schemas/SavedViewConfig"
          }
        }
      },
      "RecordHistoryActor": {
        "type": "object",
        "description": "Who performed the change. `type` is the principal kind; `name` is resolved server-side where it can be (users and automations) and absent otherwise. `onBehalfOfUserId` carries the user whose write started an automation chain.",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "description": "Kind of principal that made the change: `user` a person, `api_token` a workspace API token, `automation` a flow, `system` the platform itself (for example applying an approved pending change).",
            "type": "string",
            "enum": [
              "user",
              "api_token",
              "automation",
              "system"
            ]
          },
          "id": {
            "description": "Id of the principal: the user id, the API token id, the flow id, or for `system` the id of the thing acting (such as the pending change); null when there is none.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "Display name of the principal where the server could resolve one (users and flows); null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "onBehalfOfUserId": {
            "description": "For an `automation` or `system` actor, the user whose write started the chain (the record change that fired the flow, or the requester of an approved change); null when not applicable.",
            "type": [
              "string",
              "null"
            ]
          },
          "onBehalfOfName": {
            "description": "Display name of `onBehalfOfUserId`, resolved server-side; null when there is no such user or the name could not be resolved.",
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "RecordHistorySource": {
        "type": "string",
        "description": "Which write surface produced the change. `rest` is the app or a direct API call, `mcp` an MCP tool under the connected user's identity, `automation` an automation rule or flow step, `approval` an approved pending change being applied, `import` an import job updating a record it matched. `unknown` is only for events written before the source was recorded.",
        "enum": [
          "rest",
          "mcp",
          "automation",
          "approval",
          "import",
          "unknown"
        ]
      },
      "RecordHistoryEntry": {
        "type": "object",
        "description": "One change to the record. `before`/`after` are the record's field values either side of the change, already masked to the fields the caller may read — a creation has no `before`, a deletion no `after`. `changedFields` lists the visible fields that actually differ, so a change that touched only fields the caller cannot see appears as an entry with no listed fields rather than vanishing from the timeline. `hiddenChangeCount` is how many changed fields were masked out (restricted for the caller, or no longer on the table), so a client can tell \"nothing visible changed\" from \"nothing changed\". `attemptedFields` are the visible fields the write named, whether or not their values moved — a write that stored the values the record already held is a real, audited write and shows up here with `attemptedFields` set and `changedFields` empty.",
        "required": [
          "id",
          "eventType",
          "createdAt",
          "actor",
          "changedFields",
          "hiddenChangeCount",
          "attemptedFields",
          "source"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the underlying audit event this entry renders; unique per entry and stable across reads.",
            "type": "string"
          },
          "eventType": {
            "description": "`ItemCreated` the record was created (no `before`), `ItemUpdated` fields were written, `ItemDeleted` it was deleted (no `after`). `CommentResolved` and `CommentReopened` are a discussion thread on the record being settled or taken up again (`commentId` names the thread's root, `anchor` the field it is on, if any; no field values either side). `MetadataChanged` is one request writing metadata about the record's fields (`metadataChange` says what). `Item` is the legacy wire name for record.",
            "type": "string",
            "enum": [
              "ItemCreated",
              "ItemUpdated",
              "ItemDeleted",
              "CommentResolved",
              "CommentReopened",
              "MetadataChanged"
            ]
          },
          "createdAt": {
            "description": "When the change happened, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "actor": {
            "$ref": "#/components/schemas/RecordHistoryActor"
          },
          "source": {
            "$ref": "#/components/schemas/RecordHistorySource"
          },
          "commentId": {
            "type": [
              "string",
              "null"
            ],
            "description": "For `CommentResolved` and `CommentReopened`: the root comment of the thread that was settled or reopened, so a client can link the entry to the discussion. Null otherwise."
          },
          "anchor": {
            "$ref": "#/components/schemas/CommentAnchor"
          },
          "metadataChange": {
            "$ref": "#/components/schemas/RecordMetadataChange"
          },
          "tool": {
            "type": [
              "string",
              "null"
            ],
            "description": "The MCP tool that made the write, when `source` is `mcp`."
          },
          "agent": {
            "description": "The agent the write was made through, when the actor's token was an agent's OAuth grant (spec section 5.8); the actor itself stays the member who owns it. Null for a person's own write.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/AgentSummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "before": {
            "description": "The record's field values before the change, keyed by field name and limited to fields the caller may read. Null for a creation.",
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "after": {
            "description": "The record's field values after the change, keyed by field name and limited to fields the caller may read. Null for a deletion.",
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "changedFields": {
            "description": "Names of the caller-visible fields whose values actually differ between `before` and `after`. Empty when nothing the caller can see changed.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "hiddenChangeCount": {
            "description": "How many changed fields were masked out of this entry because the caller may not read them or they no longer exist on the table. Non-zero alongside an empty `changedFields` means something changed that the caller cannot see.",
            "type": "integer",
            "minimum": 0
          },
          "attemptedFields": {
            "description": "Names of the caller-visible fields the write named, whether or not their values moved. A write that re-stored existing values has these set and `changedFields` empty.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "importMatch": {
            "$ref": "#/components/schemas/ImportMatchHistory"
          },
          "intake": {
            "$ref": "#/components/schemas/IntakeDeliveryVersion"
          }
        }
      },
      "RecordHistory": {
        "description": "Response of `GET /tables/{tableId}/items/{itemId}/history`: one window of a record's audit trail, newest first, with before/after states already masked to the fields the caller may read.",
        "type": "object",
        "required": [
          "entries",
          "hasMore"
        ],
        "properties": {
          "entries": {
            "description": "The change events for the record in this window, newest first, each with its masked before/after state. An entry's id can be replayed into a flow test run as `sampleEventId`.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecordHistoryEntry"
            }
          },
          "hasMore": {
            "type": "boolean",
            "description": "True when more entries exist beyond this window."
          }
        }
      },
      "RecordCommentAuthor": {
        "type": "object",
        "required": [
          "id"
        ],
        "description": "Who wrote a comment. `name` is null when the id no longer resolves to a workspace member — attribution is a fact about the past, so a departed author's comment stays and renders as an unknown user rather than vanishing.",
        "properties": {
          "id": {
            "description": "User id of the author, as it was when the comment was posted.",
            "type": "string"
          },
          "name": {
            "description": "The author's current display name; null when they are no longer a workspace member, in which case render an unknown user.",
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "RecordComment": {
        "type": "object",
        "description": "One comment. Deliberately does NOT repeat tableId/recordId: a thread is always fetched for a known record, and the WebSocket frame that carries a comment supplies them alongside it, so restating them here would be wire surface nothing reads.",
        "required": [
          "id",
          "author",
          "body",
          "createdAt",
          "deleted",
          "via"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the comment, used to edit or delete it.",
            "type": "string"
          },
          "parentId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The thread this comment replies to: the id of the thread's root comment, or null when this comment is itself a root. Threads are one level deep — a reply to a reply is stored under the same root — so a thread renders as its root followed by every comment whose `parentId` names it."
          },
          "author": {
            "$ref": "#/components/schemas/RecordCommentAuthor"
          },
          "body": {
            "type": [
              "string",
              "null"
            ],
            "description": "The comment text, in the markdown subset the in-app renderer supports. Mentions appear as opaque `@[user:<id>]` tokens, resolved to display names at render time so a rename can never orphan one. Null on a deleted comment — the text is gone from the database, not merely withheld."
          },
          "createdAt": {
            "description": "When the comment was posted, ISO-8601 UTC. Comments are listed in this order.",
            "type": "string",
            "format": "date-time"
          },
          "editedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the author last edited it; null if never. Rendered as \"(edited)\"."
          },
          "deleted": {
            "description": "True when the comment has been removed: `body` is null and only the tombstone is rendered, with `deletedKind` saying who removed it.",
            "type": "boolean"
          },
          "deletedKind": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who removed it — `author` or `moderator`. Null unless deleted. The reader renders these differently, and it is not reconstructable from the actor id alone.",
            "x-known-values": "KnownCommentDeletedKind"
          },
          "anchor": {
            "$ref": "#/components/schemas/CommentAnchor"
          },
          "resolvedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the thread this comment starts was resolved, ISO-8601 UTC; null while it is open. Only a thread's root carries it: a reply's thread is as open or resolved as its root. A resolved thread folds by default in the discussion."
          },
          "resolvedBy": {
            "$ref": "#/components/schemas/RecordCommentAuthor"
          },
          "via": {
            "description": "The OAuth client the current text was written through, when the author acted through one (an AI agent connected over MCP, posting or editing as them); null when the author wrote it in the app or through an API token. Render it beside the author (\"Henry via Claude\") so a reader can tell the person's own words from an agent's. Observed by the server from the verified token, never supplied by the caller. It describes the latest write: an edit through a client sets it, and an edit in the app clears it.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/CommentClient"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "CommentClient": {
        "type": "object",
        "required": [
          "clientId",
          "clientName"
        ],
        "description": "The OAuth client a comment was written through. A label beside the author, not an identity of its own: the comment is still the author's, and only the author may edit it.",
        "properties": {
          "clientId": {
            "type": "string",
            "description": "The OAuth client id the author's token was issued to, as it was when the comment was written."
          },
          "clientName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The client's registered name when the comment was written (for example \"Claude\"); null when it could not be resolved, in which case render a generic \"via an app\"."
          }
        }
      },
      "CommentAnchor": {
        "type": "object",
        "description": "Where on its subject a thread sits. On a record, `field` names one of the record's fields by `fieldId`, so the record page can mark the field that carries an open thread; on a chart, `tile` names the dashboard tile (`dashboardId`, `tileId`) the chart was being read on, so the thread can be opened from that tile again. Only a thread's root is anchored; replies sit under it. Absent on a comment about the subject as a whole.",
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "field",
              "tile"
            ],
            "description": "`field` for a field of the record (`fieldId` set), `tile` for a dashboard tile showing the chart (`dashboardId` and `tileId` set)."
          },
          "fieldId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "The field the thread is about, when `kind` is `field`. Must be a field of the record's table that the author may read."
          },
          "dashboardId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "The dashboard the tile belongs to, when `kind` is `tile`."
          },
          "tileId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "The tile's id within that dashboard, when `kind` is `tile`."
          }
        }
      },
      "CommentResolutionRequest": {
        "type": "object",
        "description": "Request body of the resolution endpoints: whether the thread is settled. `true` resolves it, `false` reopens it; either is idempotent.",
        "required": [
          "resolved"
        ],
        "properties": {
          "resolved": {
            "type": "boolean",
            "description": "True to resolve the thread, false to reopen it."
          }
        }
      },
      "KnownCommentDeletedKind": {
        "type": "string",
        "description": "How a comment came to be deleted.",
        "enum": [
          "author",
          "moderator"
        ]
      },
      "KnownSystemTableKey": {
        "type": "string",
        "description": "The table base types a table can be created with (`CreateDataTableRequest.baseType`). A base type is a contract in code: a named, typed core of fields with immutable properties (type, required, seed vocabulary) and the saved views provisioned with them, which platform code may rely on finding; the table stays an ordinary, fully extendable table. 'activities' provisions tasks and logged calls/meetings (subject, type, status, due date, assignee, description) with the \"My open tasks\" and \"Task calendar\" views, the record timeline and the task-assigned event. Open-enum on the read side: DataTable.systemKey is an open string on the wire so a new base type never breaks generated clients; this schema is the vocabulary current servers accept and emit.",
        "enum": [
          "activities"
        ]
      },
      "RecordCommentPage": {
        "description": "Response of `GET /tables/{tableId}/items/{itemId}/comments`: one window of a record's discussion plus a flag saying whether more comments lie beyond it.",
        "type": "object",
        "required": [
          "comments",
          "hasMore"
        ],
        "properties": {
          "comments": {
            "description": "The comments in this window, as the caller may see them.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecordComment"
            }
          },
          "hasMore": {
            "type": "boolean",
            "description": "True when more comments exist beyond this window."
          }
        }
      },
      "UndeliverableMention": {
        "type": "object",
        "required": [
          "userId",
          "reason"
        ],
        "description": "Someone the comment named who was not notified. Reported back to the author because the alternative — silently dropping it — leaves them waiting for a reply that is never coming.",
        "properties": {
          "userId": {
            "description": "The mentioned user's id, as written in the `@[user:<id>]` token.",
            "type": "string"
          },
          "reason": {
            "type": "string",
            "description": "`record_not_visible` — they cannot see the record this comment is on. `chart_not_visible` — the comment is on a chart and they lack `charts:read`. `not_a_member` — they are no longer an active workspace member.",
            "x-known-values": "KnownMentionSuppressedReason"
          }
        }
      },
      "KnownMentionSuppressedReason": {
        "type": "string",
        "description": "Why a mention was stored but not notified.",
        "enum": [
          "record_not_visible",
          "chart_not_visible",
          "not_a_member"
        ]
      },
      "CreateRecordCommentRequest": {
        "description": "Request body of `POST /tables/{tableId}/items/{itemId}/comments`: the text of a new comment on a record. Mentions are parsed server-side from the body.",
        "type": "object",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 8000,
            "description": "Markdown-subset text. Mentions are written as `@[user:<id>]` tokens; the server parses them and is the sole authority on the resulting mention rows."
          },
          "parentId": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "The thread to reply in: the id of any comment on the same subject. A reply to a reply is stored under that reply's root, so threads stay one level deep. Omit or send null to start a new thread. A reply cannot carry an `anchor`; it sits under its root's."
          },
          "anchor": {
            "$ref": "#/components/schemas/CommentAnchor"
          }
        }
      },
      "UpdateRecordCommentRequest": {
        "description": "Request body of `PATCH /tables/{tableId}/items/{itemId}/comments/{commentId}`: the replacement text of a comment on a record.",
        "type": "object",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "description": "The new comment text, replacing the previous body in full.",
            "type": "string",
            "minLength": 1,
            "maxLength": 8000
          }
        }
      },
      "CreateRecordCommentResponse": {
        "description": "Response of posting or editing a record comment: the stored comment, plus any @-mentions that were kept in the text but could not be notified (people outside the record's audience, or deactivated).",
        "type": "object",
        "required": [
          "comment"
        ],
        "properties": {
          "comment": {
            "$ref": "#/components/schemas/RecordComment"
          },
          "undeliverableMentions": {
            "type": "array",
            "description": "Mentions stored but not notified. Empty or absent when everyone named was reachable.",
            "items": {
              "$ref": "#/components/schemas/UndeliverableMention"
            }
          }
        }
      },
      "ActivityLink": {
        "type": "object",
        "description": "One attachment between an activity (a record of the built-in activities table) and a record it regards. Pure junction: the link itself carries no content, and it is shared state about the record rather than attributed speech — createdBy is provenance, not ownership, and detaching has no author-only rule.",
        "required": [
          "id",
          "createdBy",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of this attachment, used to detach it (`DELETE .../activities/{linkId}`). Distinct from the activity's own record id: the same activity attached to two records has two link ids.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "createdBy": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$",
            "description": "Who attached it. Provenance only — an id that no longer resolves renders as \"Unknown user\"."
          },
          "createdAt": {
            "description": "When the activity was attached to the record, ISO-8601 UTC. Not when the activity itself was created.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ActivityTimelineEntry": {
        "description": "One row of a record's activity timeline: the activity record itself (a row of the built-in activities table) together with the link that attaches it to the record being viewed. Item of `ActivityTimelinePage.entries`.",
        "type": "object",
        "required": [
          "link",
          "activity"
        ],
        "properties": {
          "link": {
            "$ref": "#/components/schemas/ActivityLink"
          },
          "activity": {
            "$ref": "#/components/schemas/TableItem"
          }
        }
      },
      "ActivityTimelinePage": {
        "description": "One page of a record's activity timeline, returned by `GET /tables/{tableId}/items/{itemId}/activities`: the linked activities the caller may read, newest first, plus whether another page exists.",
        "type": "object",
        "required": [
          "entries",
          "hasMore"
        ],
        "properties": {
          "entries": {
            "type": "array",
            "description": "Newest first. Linked activities the caller cannot read (the activities table's own row scope), binned ones, and dangling links are silently omitted, so a page may hold fewer entries than the requested limit.",
            "items": {
              "$ref": "#/components/schemas/ActivityTimelineEntry"
            }
          },
          "hasMore": {
            "description": "True when more linked activities exist beyond this page; request the next page with `offset` advanced by `limit`. Computed over the links before visibility filtering, so it can be true even when `entries` came back short or empty.",
            "type": "boolean"
          }
        }
      },
      "AttachActivityRequest": {
        "description": "Request body of `POST /tables/{tableId}/items/{itemId}/activities`: links an existing activity record to the record in the path, so it appears on that record's activity timeline.",
        "type": "object",
        "required": [
          "activityId"
        ],
        "properties": {
          "activityId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "A record id in the workspace's activities table."
          }
        }
      },
      "AttachActivityResponse": {
        "description": "The junction created by attaching an existing activity to a record. Response of `POST /tables/{tableId}/items/{itemId}/activities`.",
        "type": "object",
        "required": [
          "link"
        ],
        "properties": {
          "link": {
            "$ref": "#/components/schemas/ActivityLink"
          }
        }
      },
      "ActivityLinkTarget": {
        "type": "object",
        "description": "One record an activity regards. When the caller cannot read the target (its table's row scope, its bin state, or a dangling link), only the bare ids are present — the tombstone keeps the link visible so detaching it stays reachable, while the label never leaks.",
        "required": [
          "link",
          "tableId",
          "recordId"
        ],
        "properties": {
          "link": {
            "$ref": "#/components/schemas/ActivityLink"
          },
          "tableId": {
            "description": "Id of the table the linked record belongs to. Always present, even on a tombstone, so the link can still be detached.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "recordId": {
            "description": "Id of the linked record. Always present, even on a tombstone the caller cannot read.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "label": {
            "type": "string",
            "description": "The target's display value, resolved through the caller's readable fields. Absent on tombstones."
          },
          "tableDisplayName": {
            "type": "string",
            "description": "The target table's display name. Absent on tombstones."
          }
        }
      },
      "ActivityLinkTargetsResponse": {
        "description": "Response of `GET /tables/{tableId}/items/{itemId}/activity-links`: every record an activity is linked to, oldest link first.",
        "type": "object",
        "required": [
          "targets"
        ],
        "properties": {
          "targets": {
            "type": "array",
            "description": "Every link on the activity, oldest first — bounded by the 25-links-per-activity cap, so unpaginated.",
            "items": {
              "$ref": "#/components/schemas/ActivityLinkTarget"
            }
          }
        }
      },
      "HomepageTileKind": {
        "type": "string",
        "description": "What a home-page tile shows.\n  chart         — a saved chart (chartId)\n  table         — a saved query rendered as a table of rows (queryId)\n  quickLinks    — a fixed list of in-app links the admin curates\n  recentRecords — the newest records in one table (tableId)\n  myRecents     — the viewer's own recently visited items (no config;\n                  the list is per-user client state, not workspace data)\n  markdown      — a block of admin-authored text\n  savedView     — a table's saved view drawn by its own kind (tableId +\n                  savedViewId): a map, a gallery or a calendar of the\n                  records the view selects. Only workspace-shared views\n                  of those kinds can be placed.\n  extension     — an app extension of the workspace's hosted site that\n                  declares the `home.tile` target, shown in a frame\n                  (extension). A home page holds at most four.\n",
        "enum": [
          "chart",
          "table",
          "quickLinks",
          "recentRecords",
          "myRecents",
          "markdown",
          "savedView",
          "extension"
        ]
      },
      "HomepageQuickLinksMode": {
        "type": "string",
        "description": "Where a quickLinks tile gets its links.\n\n  curated — the author's own picks, from the tile's `links` (default)\n  builtIn — the same permission-aware set the built-in home page shows:\n            a link per data table, then the workspace's landing pages.\n            Recomputed per viewer from what the workspace currently\n            contains, so `links` is ignored and a table added later\n            appears on its own.\n",
        "enum": [
          "curated",
          "builtIn"
        ]
      },
      "HomepageQuickLinkTargetKind": {
        "type": "string",
        "description": "Which kind of workspace page a quick link points at. This is the closed\nset of destinations the app actually has routes for, so a quick link\nnames a real page rather than an arbitrary URL an author typed.\n\nKinds with no id address a singular page; the rest address one workspace\nobject:\n\n  home / sheets / dashboards / approvals\n                — the end-user surface's own landing pages\n  tableRecords  — a data table's record list      (tableId)\n  tableSheet    — a data table in the sheet grid  (tableId)\n  tableBoard    — a data table's board view       (tableId)\n  dashboard     — one saved dashboard             (dashboardId)\n  adminData / adminTables / adminImport /\n  adminQuery / adminCharts / adminAudit\n                — builder pages; only rendered for viewers holding\n                  `builder:access`\n  capture       — add a record from a photo (business card, leaflet);\n                  rendered for viewers who may create records\n  scan          — the Scan page: find records by a barcode or QR\n                  code, or count scanned items; rendered for\n                  viewers who may read records\n  tableCreate   — a data table's blank new-record form (tableId):\n                  the \"Add a contact\" button. Rendered for viewers\n                  who may create records, and never for a SQL view,\n                  which has no create form\n  page          — one of the workspace's published pages (pageId).\n                  The server resolves it to the page's link on read\n                  (`url`) and refuses a pageId that is not a page of\n                  the caller's workspace on write; a page deleted\n                  since is rendered as nothing. Carries its own\n                  `label`, since the page's title is not resolved at\n                  render\n  hostedSite    — the workspace's hosted site (its custom app), at an\n                  optional site-relative `path`. No id: a workspace\n                  has at most one site. The server resolves it to\n                  `https://<site>.<hosted-sites domain><path>` on read\n                  (`url`); a workspace with no site renders nothing\n  extensionPage — a full-page app extension of the workspace's hosted\n                  site (extension), at an optional path within it\n                  (`path`). The client derives the in-app route\n                  `/x/{siteId}/{extensionId}/...`; a link to an\n                  extension the site no longer declares is hidden,\n                  and its page shows admins a placeholder\n\nA kind a client does not recognize is skipped rather than guessed at,\nthe same way an unknown tile `kind` is.\n",
        "enum": [
          "home",
          "sheets",
          "dashboards",
          "approvals",
          "tableRecords",
          "tableSheet",
          "tableBoard",
          "dashboard",
          "adminData",
          "adminTables",
          "adminImport",
          "adminQuery",
          "adminCharts",
          "adminAudit",
          "capture",
          "tableView",
          "tableCreate",
          "page",
          "hostedSite",
          "extensionPage",
          "scan"
        ]
      },
      "HomepageQuickLinkTarget": {
        "type": "object",
        "description": "A selected in-app destination. The path is derived from the kind and id by the client, so a link cannot drift from the app's routing and can never point off-product. Two kinds name a destination the client cannot derive, a published page (`page`) and the workspace's hosted site (`hostedSite`): for those the server resolves `url` on every read, and leaves it absent when the destination no longer exists.",
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/HomepageQuickLinkTargetKind"
          },
          "tableId": {
            "type": "string",
            "maxLength": 64,
            "description": "Data table id (kind=tableRecords / tableSheet / tableBoard / tableView / tableCreate)"
          },
          "dashboardId": {
            "type": "string",
            "maxLength": 64,
            "description": "Saved dashboard id (kind=dashboard)"
          },
          "savedViewId": {
            "type": "string",
            "maxLength": 64,
            "description": "Saved view id within `tableId` (kind=tableView): the table's record list opened on that view — \"My visits\" rather than \"Visits\". The view's own filter (including a `currentUser` condition) is what makes the destination personal, so no per-user document is needed. The client derives `/records/{tableId}?view={savedViewId}`; the view's name is not resolved at render, so a `tableView` link carries its own `label`."
          },
          "pageId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "Published page id (kind=page). Must be a page of the caller's workspace: a write naming any other id is refused with 400. The page's title is not resolved at render, so a `page` link carries its own `label`."
          },
          "path": {
            "type": "string",
            "maxLength": 512,
            "pattern": "^/(?![/\\\\])[^\\s\\\\]*$",
            "description": "Site-relative path (kind=hostedSite or extensionPage), e.g. `/jobs`: on the workspace's hosted site for `hostedSite`, within the extension's own page for `extensionPage` (the extension reads it as its route). Starts with a single `/`, no scheme or host, no backslash, no `.` or `..` segment. For `extensionPage` the rest is a route inside the extension's folder: lowercase letters, digits, `.`, `_`, `-` and `/`, starting with a letter or digit, no query, at most 256 characters after the leading `/` (the same route rule as an `openModal` path; the 512 limit is a `hostedSite` path's). Refused with 400 on any other kind. Defaults to `/`."
          },
          "extension": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ExtensionPlacement"
              }
            ],
            "description": "Which app extension the link opens (kind=extensionPage); required for that kind and refused with 400 on any other. The site must be the workspace's own: a write naming any other is refused with 400 `EXTENSION_SITE_UNKNOWN`."
          },
          "url": {
            "type": "string",
            "readOnly": true,
            "description": "Where the link goes, resolved by the server on read for the `page` and `hostedSite` kinds only: the published page's link in the app, or `https://<site>.<hosted-sites domain><path>`. Absent when the page has since been deleted or the workspace has no hosted site, which a client renders as nothing. Never stored; a value sent on a write is ignored."
          }
        }
      },
      "HomepageQuickLink": {
        "type": "object",
        "description": "One curated link on a quickLinks tile.\n\nA link carries a `target` — a destination picked from the workspace's\nreal pages. `label`/`description` are optional overrides; without them\nthe link shows the destination's live name, so renaming a table renames\nthe link that points at it.\n\n`path` is the superseded free-text form, kept only so links written\nbefore targets existed keep working. Exactly one of `target` / `path`\nmust be present, and a `path`-only link needs a `label`; the server\nrejects anything else.\n",
        "properties": {
          "target": {
            "$ref": "#/components/schemas/HomepageQuickLinkTarget"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Link text. Optional when a target is set (defaults to the destination's current name); required for a legacy `path` link and for a `tableView` target, whose view name the client does not resolve at render."
          },
          "path": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "deprecated": true,
            "description": "Superseded by `target`. In-app path to navigate to, e.g. `/records/abc123456789`. Must be a root-relative path — absolute URLs and scheme-relative values are rejected, so a quick link can never point off-product.",
            "pattern": "^/[^/\\\\]"
          },
          "description": {
            "description": "Optional secondary line under the link text, up to 160 characters. Without it the tile shows only the label (or the destination's name).",
            "type": "string",
            "maxLength": 160
          }
        }
      },
      "HomepageTile": {
        "type": "object",
        "description": "One tile on the workspace home page. Tiles share the dashboard grid\ngeometry: `x`/`y` position (column / row units), `width` the span in\ncolumns of 12, `height` the span in row units (one unit ≈ 80px). Tiles\nwithout x/y are auto-placed left-to-right, top-to-bottom in array order.\n\nPer-kind configuration lives in the optional fields below; a field that\ndoes not apply to the tile's kind is ignored. A tile whose `kind` a\nclient does not recognize is skipped rather than rendered — the config\nis a closed registry keyed by this enum.\n",
        "required": [
          "id",
          "kind"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique id within the home page (client-generated)",
            "maxLength": 64
          },
          "kind": {
            "$ref": "#/components/schemas/HomepageTileKind"
          },
          "title": {
            "type": "string",
            "maxLength": 255,
            "description": "Heading override (defaults to the underlying resource's name)"
          },
          "extension": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ExtensionPlacement"
              }
            ],
            "description": "Which app extension an `extension` tile shows (kind=extension); required for that kind and refused on any other. The site is resolved server-side against the workspace's own sites (400 `EXTENSION_SITE_UNKNOWN` otherwise)."
          },
          "x": {
            "description": "Column the tile starts at, 0–11 on a 12-column grid. Omit `x` and `y` to have the tile auto-placed after the previous ones.",
            "type": "integer",
            "minimum": 0,
            "maximum": 11
          },
          "y": {
            "description": "Row unit the tile starts at, 0 at the top; one unit is about 80px. Omit with `x` for auto-placement.",
            "type": "integer",
            "minimum": 0
          },
          "width": {
            "description": "Columns the tile spans, 1–12 on the 12-column grid.",
            "type": "integer",
            "minimum": 1,
            "maximum": 12
          },
          "height": {
            "description": "Row units the tile spans (one unit is about 80px).",
            "type": "integer",
            "minimum": 1
          },
          "chartId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Saved chart id (kind=chart)"
          },
          "queryId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Saved query id (kind=table)"
          },
          "tableId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Data table id (kind=recentRecords, kind=savedView)"
          },
          "savedViewId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Saved view id within tableId (kind=savedView)"
          },
          "recordLink": {
            "$ref": "#/components/schemas/QueryTileRecordLink"
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 50,
            "description": "Rows to show (kind=recentRecords / myRecents; default 5). On a quickLinks tile with linksMode=builtIn, how many data tables get a link before the list stops (default 8)."
          },
          "linksMode": {
            "$ref": "#/components/schemas/HomepageQuickLinksMode"
          },
          "links": {
            "type": "array",
            "maxItems": 24,
            "description": "Curated links (kind=quickLinks, linksMode=curated)",
            "items": {
              "$ref": "#/components/schemas/HomepageQuickLink"
            }
          },
          "markdown": {
            "type": "string",
            "maxLength": 4000,
            "description": "Tile body as markdown (kind=markdown)"
          }
        }
      },
      "HomepageConfig": {
        "description": "The stored document behind a workspace home page: the tiles to render, with a server-stamped shape version. Carried as `Homepage.config`.",
        "type": "object",
        "required": [
          "tiles"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "description": "Stored-shape version, stamped by the server on write. Clients read tolerantly and should not depend on a particular value."
          },
          "tiles": {
            "description": "The home page's tiles with their grid positions, at most 40. Empty when the page is configured but blank, or when no page is configured at all.",
            "type": "array",
            "maxItems": 40,
            "items": {
              "$ref": "#/components/schemas/HomepageTile"
            }
          }
        }
      },
      "Homepage": {
        "description": "The home page the caller lands on, returned by `GET /workspace/homepage` and by the two writes. Resolved per caller: their personal page if one exists, else their active group's, else the workspace's; `ownerScope` says which answered.",
        "type": "object",
        "required": [
          "configured",
          "config",
          "url"
        ],
        "properties": {
          "configured": {
            "type": "boolean",
            "description": "False when no admin has configured this workspace's home page; the client then renders its built-in default. `config.tiles` is empty in that case, which is distinct from a configured-but-empty page."
          },
          "config": {
            "$ref": "#/components/schemas/HomepageConfig"
          },
          "url": {
            "description": "The link that opens this workspace's home page in the app, naming the workspace the way a published page's `url` does. The page resolves per viewer on open, so one link serves every audience; present whether or not a page is configured.",
            "type": "string",
            "format": "uri"
          },
          "ownerScope": {
            "$ref": "#/components/schemas/CustomizationResolvedScope"
          },
          "ownerGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The group this page is written for, set only when `ownerScope` is `group`. With `ownerScope` it says WHICH document was returned, so a reader can be told they landed on their group's home page — or, when `ownerScope` is `user`, on one they made for themselves."
          },
          "updatedBy": {
            "description": "Id of the user who last wrote the returned home page document. Null when the writer is no longer known, and absent when `configured` is false.",
            "type": [
              "string",
              "null"
            ]
          },
          "updatedAt": {
            "description": "When the returned home page document was last written, ISO-8601 UTC. Absent when `configured` is false.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "HomepageTilesBody": {
        "type": "object",
        "description": "The bare form of a home page write: the tile list at the top level.",
        "required": [
          "tiles"
        ],
        "properties": {
          "tiles": {
            "description": "The complete set of tiles for the page, at most 40; replaces what was there. An empty list clears the page.",
            "type": "array",
            "maxItems": 40,
            "items": {
              "$ref": "#/components/schemas/HomepageTile"
            }
          }
        }
      },
      "HomepageWrappedBody": {
        "type": "object",
        "description": "The wrapped form of a home page write: the `config` document exactly as `GET /workspace/homepage` returns it, so a read-modify-write can send the answer straight back. The other fields of that answer (`configured`, `updatedBy`, …) are ignored.",
        "required": [
          "config"
        ],
        "properties": {
          "config": {
            "$ref": "#/components/schemas/HomepageConfig"
          }
        }
      },
      "UpdateMyHomepageRequest": {
        "description": "A home page written for the caller alone. Carries no targeting: the owner is the authenticated user and cannot be named in the request, so this body can never reach somebody else's page or a shared one. Either the bare tile list or the wrapped `config` the GET returns; a body with both, or neither, is refused.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/HomepageTilesBody"
          },
          {
            "$ref": "#/components/schemas/HomepageWrappedBody"
          }
        ]
      },
      "HomepageWriteTarget": {
        "type": "object",
        "description": "Which SHARED home page a write addresses: the workspace's (the default) or one group's. Added to either body form of `UpdateMyHomepageRequest` by the two `UpdateHomepage*Request` schemas below.",
        "properties": {
          "ownerScope": {
            "$ref": "#/components/schemas/CustomizationTargetScope"
          },
          "ownerGroupId": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "Required when `ownerScope` is `group`; ignored otherwise. Null is the same as absent, so the GET's answer for the workspace's page can be sent back as it is."
          }
        }
      },
      "UpdateHomepageTilesRequest": {
        "description": "A shared home page written as the bare tile list plus its target.",
        "allOf": [
          {
            "$ref": "#/components/schemas/HomepageTilesBody"
          },
          {
            "$ref": "#/components/schemas/HomepageWriteTarget"
          }
        ]
      },
      "UpdateHomepageWrappedRequest": {
        "description": "A shared home page written as the wrapped `config` the GET returns, plus its target.",
        "allOf": [
          {
            "$ref": "#/components/schemas/HomepageWrappedBody"
          },
          {
            "$ref": "#/components/schemas/HomepageWriteTarget"
          }
        ]
      },
      "UpdateHomepageRequest": {
        "description": "A SHARED home page — the workspace's, or one group's. The two body forms are `UpdateMyHomepageRequest`'s (`HomepageTilesBody` and `HomepageWrappedBody`), so the two write paths can never describe a page differently; what this adds is which shared document to write. A body with both `tiles` and `config`, or neither, is refused.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/UpdateHomepageTilesRequest"
          },
          {
            "$ref": "#/components/schemas/UpdateHomepageWrappedRequest"
          }
        ]
      },
      "NavigationItem": {
        "type": "object",
        "description": "One entry in the curated workspace navigation. Like a quick link, it names a page through a typed `target` rather than a path: the client derives the route, skips a target that no longer resolves (a deleted table or dashboard, or a page the viewer's role cannot reach), and shows the destination's live name unless `label` overrides it. A `target` can never lead into `/admin` for someone without `builder:access`, because each kind declares the action it needs.",
        "required": [
          "id",
          "target"
        ],
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 64,
            "description": "Unique within the navigation (client-generated)."
          },
          "target": {
            "$ref": "#/components/schemas/HomepageQuickLinkTarget"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "Entry text. Optional (defaults to the destination's current name) except for a `tableView` target, which carries its own."
          }
        }
      },
      "NavigationConfig": {
        "type": "object",
        "description": "What an audience sees in the app's main navigation. `items` render in order; with `showBuiltIn` (default true) the built-in workspace entries — Sheets, Dashboards, My approvals, Automations — follow the curated list, minus any the list already names, so a curated nav starts as \"these first\" and \"only these\" is a deliberate second step. Home is always reachable from the brand mark and the built-in Build group is never part of this document: it stays gated on `builder:access`, which a navigation can neither grant nor remove.\n\nNavigation arranges; it never authorizes. Every page an entry leads to keeps its own permission, and hiding an entry hides nothing from the URL bar.",
        "required": [
          "items"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "description": "Stored-shape version, stamped by the server on write."
          },
          "items": {
            "description": "The curated navigation entries, rendered in array order ahead of any built-in entries `showBuiltIn` appends.",
            "type": "array",
            "maxItems": 24,
            "items": {
              "$ref": "#/components/schemas/NavigationItem"
            }
          },
          "showBuiltIn": {
            "type": "boolean",
            "description": "Append the built-in workspace entries after the curated list (default true)."
          }
        }
      },
      "Navigation": {
        "description": "The main-navigation document the caller sees, returned by `GET /workspace/navigation` and echoed by `PUT`: either an admin-configured item list for the workspace or the caller's active group, or `configured: false` with an empty list, meaning the client should render its built-in navigation.",
        "type": "object",
        "required": [
          "configured",
          "config"
        ],
        "properties": {
          "configured": {
            "type": "boolean",
            "description": "False when no admin has configured a navigation for this audience; the client then renders its built-in navigation. `config.items` is empty in that case."
          },
          "config": {
            "$ref": "#/components/schemas/NavigationConfig"
          },
          "ownerScope": {
            "$ref": "#/components/schemas/CustomizationTargetScope"
          },
          "ownerGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The group this navigation is written for, set only when `ownerScope` is `group` — so the shell can say which audience's arrangement it is showing."
          },
          "updatedBy": {
            "description": "User id of the admin who last wrote this navigation document. Null when the document was never configured or the author's account no longer exists.",
            "type": [
              "string",
              "null"
            ]
          },
          "updatedAt": {
            "description": "When the returned navigation document was last written, ISO-8601 UTC. Only meaningful when `configured` is true.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "UpdateNavigationRequest": {
        "description": "Request body of `PUT /workspace/navigation`: replace the curated navigation for one audience — the workspace, a group (`ownerGroupId`) or the caller's own — selected by `ownerScope`.",
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "description": "The curated entries in display order, up to 24. Replaces the previous list entirely.",
            "type": "array",
            "maxItems": 24,
            "items": {
              "$ref": "#/components/schemas/NavigationItem"
            }
          },
          "showBuiltIn": {
            "description": "Whether the built-in workspace entries follow the curated list (minus any it already names). Omitted means true.",
            "type": "boolean"
          },
          "ownerScope": {
            "$ref": "#/components/schemas/CustomizationTargetScope"
          },
          "ownerGroupId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "Required when `ownerScope` is `group`; ignored otherwise."
          }
        }
      },
      "WorkspaceLogoUploadRequest": {
        "description": "Request body of `POST /workspace/settings/logo`: the file the workspace logo will be uploaded from, so the server can presign a single-PUT upload for exactly that type and size.",
        "type": "object",
        "required": [
          "filename",
          "mimeType",
          "size"
        ],
        "properties": {
          "filename": {
            "description": "Original file name of the logo; used to name the stored object, not to decide its type.",
            "type": "string",
            "minLength": 1
          },
          "mimeType": {
            "description": "Image type the upload will be signed for; the PUT must send exactly this `Content-Type`. Only PNG, JPEG and WebP are accepted.",
            "type": "string",
            "enum": [
              "image/png",
              "image/jpeg",
              "image/webp"
            ]
          },
          "size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1048576,
            "description": "File size in bytes (max 1 MB)"
          }
        }
      },
      "WorkspaceLogoUpload": {
        "description": "Response of `POST /workspace/settings/logo`: where to PUT the logo file and the key to hand back to `PUT /workspace/settings` once the upload has completed.",
        "type": "object",
        "required": [
          "s3Key",
          "uploadUrl"
        ],
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "Storage key to pass as logoKey in PUT /workspace/settings once uploaded"
          },
          "uploadUrl": {
            "type": "string",
            "description": "Presigned URL — PUT the whole file to it"
          }
        }
      },
      "MeResponse": {
        "description": "Response of `GET /auth/me`: the signed-in user, every workspace they belong to, and, when an operator is impersonating them, the impersonation context.",
        "type": "object",
        "required": [
          "user",
          "workspaces"
        ],
        "properties": {
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "workspaces": {
            "type": "array",
            "description": "All workspaces the user is a member of",
            "items": {
              "$ref": "#/components/schemas/WorkspaceSummary"
            }
          },
          "impersonation": {
            "$ref": "#/components/schemas/ImpersonationContext"
          }
        }
      },
      "ImpersonationContext": {
        "type": "object",
        "description": "Present only when the caller's access token was minted by a platform administrator assuming this user's identity. Its presence is what the client uses to render the permanent \"you are being impersonated\" banner — a normal session never carries it.\n",
        "required": [
          "sessionId",
          "adminEmail",
          "expiresAt"
        ],
        "properties": {
          "sessionId": {
            "type": "string",
            "description": "impersonation_sessions row id — the handle the operator revokes"
          },
          "adminEmail": {
            "type": "string",
            "description": "Email of the administrator acting as this user"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the assumed session stops working. It cannot be renewed — there is no refresh token behind it.\n"
          }
        }
      },
      "ImpersonationTokenRequest": {
        "description": "Request body of `POST /auth/impersonation/token`: the single-use code an administrator received when assuming a user's identity, exchanged for a short-lived session as that user.",
        "type": "object",
        "required": [
          "code"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Single-use code from the impersonation callback fragment"
          }
        }
      },
      "RefreshTokenRequest": {
        "description": "Request body of `POST /auth/refresh`: exchanges an identity-only refresh token for a new access token scoped to a workspace, which is also how a client switches workspace.",
        "type": "object",
        "required": [
          "refreshToken"
        ],
        "properties": {
          "refreshToken": {
            "description": "The refresh token issued at login. Identity-only: it is not bound to a workspace, which is what lets `workspaceId` switch context.",
            "type": "string"
          },
          "workspaceId": {
            "type": "string",
            "description": "Target workspace for the new access token. Pass the current workspace to simply refresh, or a different workspace ID to switch context. Omit (or pass empty) to let the server choose the default workspace — or, for a user with no workspace memberships (e.g. an organization billing member, or a bare user with only pending invitations), to renew the workspace-less session."
          }
        }
      },
      "PasswordResetRequestRequest": {
        "description": "Request body of `POST /auth/password-reset/request`: the address to send a reset link to. The response never reveals whether an account exists.",
        "type": "object",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "description": "Email address to send a reset link to. The response is always 202 regardless of whether an account exists (enumeration-safe).\n"
          },
          "captchaToken": {
            "$ref": "#/components/schemas/CaptchaToken"
          }
        }
      },
      "PasswordResetConfirmRequest": {
        "description": "Request body of `POST /auth/password-reset/confirm`: redeems the token from a password-reset email and sets the new password. Other sessions are revoked and the user signs in again afresh.",
        "type": "object",
        "required": [
          "token",
          "newPassword"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "Single-use token from the emailed reset link"
          },
          "newPassword": {
            "description": "The replacement password, 10–128 characters. Checked against the password policy; rejected with 400 when it fails.",
            "type": "string",
            "minLength": 10,
            "maxLength": 128
          }
        }
      },
      "EmailVerificationConfirmRequest": {
        "description": "Request body of `POST /auth/email-verification/confirm`: the single-use token from the emailed verification link.",
        "type": "object",
        "required": [
          "token"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "Single-use token from the emailed verification link"
          }
        }
      },
      "OkResponse": {
        "description": "Generic success body for actions that return no data: always `{ ok: true }`. A failure is reported by a non-2xx status with an error body, never by `ok: false`.",
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "description": "Always `true`. A failure is reported by a non-2xx status and an error body, never by `ok: false`.",
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "MfaError": {
        "type": "object",
        "description": "Refusal from the MFA challenge and enrollment endpoints, written by a single mapper in the backend (`handleMfaError`) so every one of them speaks the same vocabulary. `code` is the machine-readable half: a client re-prompts for a bad code, but must restart sign-in when the challenge itself is gone, and those look identical if only `error` is read.\nCovers the 401 and 429 answers. The 400s that mapper can also write (NOT_ENROLLED, and a bare password refusal that carries no code) are not this shape and stay undeclared.\n",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "description": "Human-readable explanation of the refusal, safe to show to the user. Branch on `code`, not on this text.",
            "type": "string",
            "example": "This sign-in challenge is invalid or has expired. Sign in again."
          },
          "code": {
            "type": "string",
            "description": "`INVALID_CODE` — the code was wrong; the challenge is still live, so re-prompt. `INVALID_CHALLENGE` — the challenge is expired or unknown; re-prompting is pointless, restart sign-in. `TOO_MANY_ATTEMPTS` — this challenge is burned, restart sign-in. `ACCOUNT_LOCKED` — verification is locked out for a while; neither re-prompting nor restarting helps yet. `REAUTH_REQUIRED` — the account has no password and the session's sign-in is too old to prove a change to its sign-in factors; sign in again (e.g. with Google) and retry.\n",
            "enum": [
              "INVALID_CODE",
              "INVALID_CHALLENGE",
              "TOO_MANY_ATTEMPTS",
              "ACCOUNT_LOCKED",
              "REAUTH_REQUIRED"
            ]
          }
        }
      },
      "MfaChallengeResponse": {
        "type": "object",
        "description": "Returned by login when the account has a second factor enrolled. The password was correct but no session is issued until the challenge is completed via /auth/mfa/verify with a code.\n",
        "required": [
          "error",
          "code",
          "methods",
          "challengeToken"
        ],
        "properties": {
          "error": {
            "description": "Human-readable message explaining that a second factor is required; `code` is the value to dispatch on.",
            "type": "string"
          },
          "code": {
            "description": "Machine-readable discriminator, always `MFA_CHALLENGE`, telling a client to proceed to the MFA verify step instead of treating the 403 as a failed login.",
            "type": "string",
            "enum": [
              "MFA_CHALLENGE"
            ]
          },
          "methods": {
            "type": "array",
            "description": "Factors the user can complete now — 'totp' (authenticator app) and/or 'otp' (emailed code, request one via /auth/mfa/challenge/send-otp). Backup codes are always accepted.\n",
            "items": {
              "type": "string"
            }
          },
          "challengeToken": {
            "type": "string",
            "description": "Single-use, short-lived (10 minutes) challenge state. Only accepted by the /auth/mfa challenge endpoints, never as a bearer token.\n"
          }
        }
      },
      "EarlyAccessPendingResponse": {
        "type": "object",
        "description": "The account exists — credentials and all — but is awaiting early access: it was created through public sign-up while its address was not on the allowlist, and no session is issued until an operator admits it (the person is emailed when that happens). Returned by /auth/register the moment such an account is created, and by /auth/login, /auth/token and /auth/refresh whenever it is used before then; the auth middleware answers the same way to any token for it. Always after the credentials proved out, so it reveals nothing about an account to anyone but its owner.\n",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable explanation to show the user"
          },
          "code": {
            "description": "Machine-readable reason; always `EARLY_ACCESS_PENDING`. Clients branch on this, not on `error`.",
            "type": "string",
            "enum": [
              "EARLY_ACCESS_PENDING"
            ]
          }
        }
      },
      "CaptchaToken": {
        "type": "string",
        "maxLength": 4096,
        "description": "The single-use token the Cloudflare Turnstile widget produced for this submission. Required whenever the deployment has verification enabled (the page then renders the widget); ignored otherwise. A missing, expired or reused token is refused with 400 CAPTCHA_REQUIRED before any account, row or email is created.\n"
      },
      "VerificationUnavailableResponse": {
        "type": "object",
        "description": "A public sign-up endpoint could not verify the challenge token — Cloudflare was unreachable or the deployment's secret is wrong — and fails closed rather than skipping the check. Nothing was processed.\n",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable explanation to show the user"
          }
        }
      },
      "SignupRefusalResponse": {
        "type": "object",
        "description": "A public sign-up endpoint refused the request before doing any work. CAPTCHA_REQUIRED — no valid verification token (the client should reset the widget and ask again); DISPOSABLE_EMAIL — the address belongs to a known throwaway-mailbox provider.\n",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable explanation to show the user"
          },
          "code": {
            "description": "Machine-readable reason, for client branching: `CAPTCHA_REQUIRED` — no valid verification token, reset the widget and retry; `DISPOSABLE_EMAIL` — the address is from a known throwaway-mailbox provider.",
            "type": "string",
            "enum": [
              "CAPTCHA_REQUIRED",
              "DISPOSABLE_EMAIL"
            ]
          }
        }
      },
      "MfaRequiredResponse": {
        "type": "object",
        "description": "Returned when an organization the user belongs to requires MFA and the session does not satisfy it. The session itself stays valid so the user can enroll (via the refresh token) — only workspace access tokens for enforced organizations are refused.\n",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "description": "Human-readable explanation that MFA enrollment is required before workspace access, suitable to show the user.",
            "type": "string"
          },
          "code": {
            "description": "Machine-readable discriminator; always `MFA_REQUIRED`. Distinguishes this body from the other 403 login outcomes (`MFA_CHALLENGE`, `PASSWORD_CHANGE_REQUIRED`, `EARLY_ACCESS_PENDING`).",
            "type": "string",
            "enum": [
              "MFA_REQUIRED"
            ]
          },
          "mfaEnrolled": {
            "type": "boolean",
            "description": "Whether a second factor is already enrolled. False means \"enroll now\"; true can only occur on non-password sessions that predate enrollment — sign out and back in.\nOptional because the authorization middleware refuses without it: the sign-in and refresh paths hold the live session and can say, but the per-request org gate knows only that the access token lacks the `mfa` claim, which is not the same question. Answering it there would mean an identity lookup on a refusal path, so those responses omit the field rather than guess. Absent means \"unknown\", not false.\n"
          },
          "refreshToken": {
            "type": "string",
            "description": "The identity session token, present on the login path so the client can drive enrollment without a workspace access token.\n"
          },
          "organizationNames": {
            "type": "array",
            "description": "Names of the organizations enforcing MFA, for messaging",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "MfaVerifyRequest": {
        "description": "Request body of `POST /auth/mfa/verify`: the pending sign-in challenge plus a code from one of the user's factors. On success the challenge is consumed and a full session is issued.",
        "type": "object",
        "required": [
          "challengeToken",
          "method",
          "code"
        ],
        "properties": {
          "challengeToken": {
            "description": "The single-use, short-lived (10 minutes) challenge state returned by a login that answered `MFA_CHALLENGE`. Consumed on success; never usable as a bearer token.",
            "type": "string"
          },
          "method": {
            "type": "string",
            "enum": [
              "totp",
              "otp",
              "backup"
            ],
            "description": "Which factor the code is for — authenticator app, emailed code, or a backup recovery code.\n"
          },
          "code": {
            "description": "The one-time code for `method`: the 6-digit authenticator code, the emailed code, or a backup recovery code. Any format within 4–64 characters is accepted and checked server-side.",
            "type": "string",
            "minLength": 4,
            "maxLength": 64
          }
        }
      },
      "MfaChallengeSendOtpRequest": {
        "description": "Request body of `POST /auth/mfa/challenge/send-otp`: asks for a one-time code to be emailed for a pending sign-in challenge.",
        "type": "object",
        "required": [
          "challengeToken"
        ],
        "properties": {
          "challengeToken": {
            "description": "The `challengeToken` the login response returned for this pending sign-in; single-use and short-lived (10 minutes), accepted only by the `/auth/mfa` challenge endpoints.",
            "type": "string"
          }
        }
      },
      "SessionTokenRequest": {
        "type": "object",
        "description": "Body-credential request authenticated by the identity session (refresh) token, like /auth/logout — deliberately not bearer-authed so it works while org MFA policy blocks every workspace token.\n",
        "required": [
          "refreshToken"
        ],
        "properties": {
          "refreshToken": {
            "description": "The caller's identity session (refresh) token, proving who is asking in place of a bearer token — so the call works even while an organization MFA policy blocks every workspace token.",
            "type": "string"
          }
        }
      },
      "MfaStatusResponse": {
        "description": "Response of `POST /auth/mfa/status`: whether the caller has a verified second factor enrolled, and the passkeys registered on the account.",
        "type": "object",
        "required": [
          "enrolled",
          "hasPassword",
          "providerMfa",
          "passkeys"
        ],
        "properties": {
          "enrolled": {
            "type": "boolean",
            "description": "A verified second factor (TOTP / email code) is enrolled"
          },
          "hasPassword": {
            "type": "boolean",
            "description": "The account has a password. When false (an account that signs in only with a social provider or SSO), the security settings ask for no password: changes to the sign-in factors are proved by a recent sign-in instead, and an authenticator code guards nothing at sign-in, so a passkey is the second factor to offer."
          },
          "providerMfa": {
            "type": "boolean",
            "description": "The sign-in behind the calling session was a social sign-in (e.g. Continue with Google) whose provider asserted a second factor: its ID token's `amr` claim said the person completed multi-factor authentication, or used a security key or passkey. Such a session already meets an organization's multi-factor requirement, so the security settings say so instead of asking for a factor the person does not need."
          },
          "passkeys": {
            "description": "The passkeys registered on the account, for listing and removal in security settings. Empty when none are registered.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PasskeySummary"
            }
          }
        }
      },
      "MfaEnrollBeginRequest": {
        "description": "Starts two-factor enrollment for the session's user: identifies the session by its refresh token and re-proves the account password (or, for an account without one, a recent sign-in) before any MFA state is touched. Request body of `POST /auth/mfa/enroll`.",
        "type": "object",
        "required": [
          "refreshToken"
        ],
        "properties": {
          "refreshToken": {
            "description": "The current session's refresh token, identifying whose account is being enrolled.",
            "type": "string"
          },
          "password": {
            "description": "The account password, when the account has one — re-proved so a stolen session token alone cannot start enrolling a second factor. Omit it for an account without a password (`hasPassword` false on `POST /auth/mfa/status`): its proof is a sign-in within the last ten minutes instead, and a staler session is refused with `REAUTH_REQUIRED`.",
            "type": "string"
          }
        }
      },
      "MfaEnrollBeginResponse": {
        "description": "Response of `POST /auth/mfa/enroll`: the TOTP secret (as an otpauth URI to render as a QR code) and the one-time recovery codes for an enrolment in progress. Show both once; enrolment completes when the user confirms a code.",
        "type": "object",
        "required": [
          "totpUri",
          "backupCodes"
        ],
        "properties": {
          "totpUri": {
            "type": "string",
            "description": "otpauth:// URI to render as a QR code for authenticator apps"
          },
          "backupCodes": {
            "type": "array",
            "description": "One-time recovery codes — shown once, store safely",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "MfaEnrollConfirmRequest": {
        "description": "Request body of `POST /auth/mfa/enroll/confirm`: proves possession of the factor started by `POST /auth/mfa/enroll` and turns MFA on. The confirming session is rotated and all other sessions are revoked, so the client must adopt the returned token.",
        "type": "object",
        "required": [
          "refreshToken",
          "method",
          "code"
        ],
        "properties": {
          "refreshToken": {
            "description": "The session token of the enrollment started by `POST /auth/mfa/enroll`. It is rotated on success; keep the token the response returns instead.",
            "type": "string"
          },
          "method": {
            "description": "Which factor the code proves: `totp` for a code from the authenticator app set up with the enrollment's `totpUri`, `otp` for the code emailed by `POST /auth/mfa/enroll/send-otp`.",
            "type": "string",
            "enum": [
              "totp",
              "otp"
            ]
          },
          "code": {
            "description": "The one-time code produced by that method, 4 to 64 characters.",
            "type": "string",
            "minLength": 4,
            "maxLength": 64
          }
        }
      },
      "MfaSessionResponse": {
        "type": "object",
        "description": "The identity session token to use from now on. Enrollment/disable rotate the session server-side; the previous refresh token is dead.\n",
        "required": [
          "refreshToken"
        ],
        "properties": {
          "refreshToken": {
            "description": "The new refresh token for the rotated session. Replace the stored one: the previous refresh token no longer works.",
            "type": "string"
          }
        }
      },
      "MfaDisableRequest": {
        "description": "Request body of `POST /auth/mfa/disable`: turns the second factor off for the caller's account after re-proving the password (or, for an account without one, a recent sign-in).",
        "type": "object",
        "required": [
          "refreshToken"
        ],
        "properties": {
          "refreshToken": {
            "description": "The caller's current session (refresh) token; identifies the account and the session, and a new refresh token is issued in the response.",
            "type": "string"
          },
          "password": {
            "description": "The account password, when the account has one — re-proved so a stolen session token alone cannot switch the second factor off. Omit it for an account without a password (`hasPassword` false on `POST /auth/mfa/status`): its proof is a sign-in within the last ten minutes instead, and a staler session is refused with `REAUTH_REQUIRED`.",
            "type": "string"
          }
        }
      },
      "MfaBackupCodesRequest": {
        "description": "Request body of `POST /auth/mfa/backup-codes`, which replaces the caller's recovery codes with a fresh set. The session token and the step-up proof (the password, or a recent sign-in for an account without one) are both required, since the codes bypass the second factor.",
        "type": "object",
        "required": [
          "refreshToken"
        ],
        "properties": {
          "refreshToken": {
            "description": "The caller's current session (refresh) token, identifying the account whose codes are regenerated.",
            "type": "string"
          },
          "password": {
            "description": "The account password, when the account has one — re-proved so a stolen session token alone cannot issue codes that bypass the second factor. Omit it for an account without a password (`hasPassword` false on `POST /auth/mfa/status`): its proof is a sign-in within the last ten minutes instead, and a staler session is refused with `REAUTH_REQUIRED`.",
            "type": "string"
          }
        }
      },
      "MfaBackupCodesResponse": {
        "description": "Response of `POST /auth/mfa/backup-codes`: a fresh set of one-time recovery codes. The previous set is invalidated and these are shown once only.",
        "type": "object",
        "required": [
          "backupCodes"
        ],
        "properties": {
          "backupCodes": {
            "description": "The new single-use recovery codes, in plain text, shown this once only. Each code signs in once in place of a TOTP code; the previous set no longer works.",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "PasskeySummary": {
        "description": "One registered passkey (WebAuthn credential) on the account, without any secret material. Returned when registration is verified and listed in `MfaStatusResponse`.",
        "type": "object",
        "required": [
          "id",
          "createdAt",
          "deviceType",
          "backedUp"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the credential record, used to rename or remove the passkey. Not the WebAuthn credential id.",
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "User-chosen label for the credential"
          },
          "createdAt": {
            "description": "When the passkey was registered, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "deviceType": {
            "type": "string",
            "description": "singleDevice, or multiDevice for a synced credential"
          },
          "backedUp": {
            "type": "boolean",
            "description": "Whether the credential is backed up (e.g. in a cloud keychain)"
          }
        }
      },
      "WebAuthnOptionsResponse": {
        "type": "object",
        "description": "A WebAuthn ceremony start — options for the browser's navigator.credentials call plus opaque server challenge state to replay on the matching verify request.\n",
        "required": [
          "options",
          "challengeToken"
        ],
        "properties": {
          "options": {
            "type": "object",
            "description": "PublicKeyCredential creation/request options JSON",
            "additionalProperties": true
          },
          "challengeToken": {
            "description": "Opaque, single-use server state binding the ceremony's challenge; send it back unchanged, with the browser's credential response, on the matching verify request.",
            "type": "string"
          }
        }
      },
      "PasskeyRegisterOptionsRequest": {
        "type": "object",
        "description": "Begin passkey registration. Requires the same step-up as MFA enroll (the password, or a recent sign-in for an account without one) so a stolen session token alone cannot plant a durable passkey credential.\n",
        "required": [
          "refreshToken"
        ],
        "properties": {
          "refreshToken": {
            "description": "The caller's current session (refresh) token, identifying the account the passkey will be registered to.",
            "type": "string"
          },
          "password": {
            "description": "The account password, when the account has one — re-proved so a stolen session token alone cannot plant a passkey. Omit it for an account without a password (`hasPassword` false on `POST /auth/mfa/status`): its proof is a sign-in within the last ten minutes instead, and a staler session is refused with `REAUTH_REQUIRED`.",
            "type": "string"
          }
        }
      },
      "PasskeyRegisterVerifyRequest": {
        "description": "Request body of `POST /auth/passkeys/register/verify`: completes a passkey registration by handing back the browser's attested credential together with the step-up proof (the password, or a recent sign-in for an account without one), so a stolen session alone cannot add a passkey.",
        "type": "object",
        "required": [
          "refreshToken",
          "challengeToken",
          "credential"
        ],
        "properties": {
          "refreshToken": {
            "description": "The signed-in user's refresh token, identifying whose account the passkey is added to.",
            "type": "string"
          },
          "password": {
            "description": "The account password, when the account has one — re-proved so a stolen session token alone cannot store a passkey. Omit it for an account without a password (`hasPassword` false on `POST /auth/mfa/status`): its proof is a sign-in within the last ten minutes instead, and a staler session is refused with `REAUTH_REQUIRED`.",
            "type": "string"
          },
          "challengeToken": {
            "description": "Opaque token returned by the registration options step, binding this verification to the challenge the browser signed. Single-use and short-lived.",
            "type": "string"
          },
          "credential": {
            "type": "object",
            "description": "The browser's RegistrationResponseJSON",
            "additionalProperties": true
          },
          "name": {
            "type": "string",
            "maxLength": 255,
            "description": "Optional label (e.g. \"Work laptop\")"
          }
        }
      },
      "PasskeyDeleteRequest": {
        "description": "Request body of `POST /auth/passkeys/delete`: removes one of the caller's passkeys. Authenticated by the session token in the body (not a bearer token) and stepped up the same way registration is (the password, or a recent sign-in for an account without one).",
        "type": "object",
        "required": [
          "refreshToken",
          "passkeyId"
        ],
        "properties": {
          "refreshToken": {
            "description": "The caller's identity session (refresh) token, proving who is asking in place of a bearer token — so the call still works while an MFA policy blocks every workspace token.",
            "type": "string"
          },
          "password": {
            "description": "The account password, when the account has one — re-proved so a stolen session token alone cannot remove a passkey. Omit it for an account without a password (`hasPassword` false on `POST /auth/mfa/status`): its proof is a sign-in within the last ten minutes instead, and a staler session is refused with `REAUTH_REQUIRED`.",
            "type": "string"
          },
          "passkeyId": {
            "description": "Identifier of the passkey to remove, as listed by the caller's passkey endpoints. Must belong to the caller.",
            "type": "string"
          }
        }
      },
      "AccountDeleteRequest": {
        "description": "Request body of `POST /auth/account/delete`. Authenticated by the session token in the body (not a bearer token) and stepped up like a change to the account's sign-in factors.",
        "type": "object",
        "required": [
          "refreshToken",
          "confirmEmail"
        ],
        "properties": {
          "refreshToken": {
            "description": "The caller's identity session (refresh) token, proving who is asking in place of a bearer token.",
            "type": "string"
          },
          "password": {
            "description": "The account password, when the account has one — re-proved so a stolen session token alone cannot delete the account. Omit it for an account without a password (`hasPassword` false on `POST /auth/mfa/status`): its proof is a sign-in within the last ten minutes instead, and a staler session is refused with `REAUTH_REQUIRED`.",
            "type": "string"
          },
          "confirmEmail": {
            "description": "The account's email address, typed again. Compared without regard to letter case; a mismatch is refused with `CONFIRMATION_MISMATCH` and nothing is deleted.",
            "type": "string",
            "maxLength": 255
          }
        }
      },
      "AccountDeletionResponse": {
        "description": "The outcome of deleting an account: when it happened, the evidence record kept of it, and any organization scheduled for erasure because the account was its only member.",
        "type": "object",
        "required": [
          "deletedAt",
          "erasureRecordId",
          "scheduledErasures"
        ],
        "properties": {
          "deletedAt": {
            "description": "When the account was deleted.",
            "type": "string",
            "format": "date-time"
          },
          "erasureRecordId": {
            "description": "Identifier of the evidence record written for this deletion, which the platform keeps as proof of what was removed. Quote it when asking for confirmation that the deletion took place.",
            "type": "string"
          },
          "scheduledErasures": {
            "description": "Organizations the account owned alone, with no other members and no current subscription, now scheduled for erasure. Empty when there were none.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScheduledOrganizationErasure"
            }
          }
        }
      },
      "ScheduledOrganizationErasure": {
        "description": "An organization scheduled for erasure as part of deleting the account that was its only member. Its workspaces are unavailable from now on and are erased, with the organization, on `eraseAfter`.",
        "type": "object",
        "required": [
          "scheduledErasureId",
          "organizationId",
          "organizationName",
          "eraseAfter"
        ],
        "properties": {
          "scheduledErasureId": {
            "description": "Identifier of the scheduled erasure; support can cancel it by this id until `eraseAfter`.",
            "type": "string"
          },
          "organizationId": {
            "description": "Identifier of the organization being erased.",
            "type": "string"
          },
          "organizationName": {
            "description": "The organization's name.",
            "type": "string"
          },
          "eraseAfter": {
            "description": "When the erasure runs: 35 days after scheduling, the window in which the request can still be cancelled. The sweep then deletes the data together with the workspace and organization backups taken of it. The database's point-in-time backups are not edited: the copies they hold age out on their own 35-day retention window after the sweep.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AccountDeletionBlockedResponse": {
        "description": "Refusal of `POST /auth/account/delete` (and the operator deletion) while the account is the only owner of an organization other people still depend on. Nothing has been deleted.",
        "type": "object",
        "required": [
          "error",
          "code",
          "organizations"
        ],
        "properties": {
          "error": {
            "description": "Human-readable explanation of the refusal, safe to show to the user.",
            "type": "string"
          },
          "code": {
            "description": "Always `SOLE_OWNER`.",
            "type": "string",
            "enum": [
              "SOLE_OWNER"
            ]
          },
          "organizations": {
            "description": "Each organization blocking the deletion and why. Never empty.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountDeletionBlocker"
            }
          }
        }
      },
      "AccountDeletionBlocker": {
        "description": "One organization the account is the only owner of, which blocks deleting the account until ownership is transferred or the organization is deleted.",
        "type": "object",
        "required": [
          "organizationId",
          "organizationName",
          "reasons"
        ],
        "properties": {
          "organizationId": {
            "description": "Identifier of the organization; its settings page is where ownership is transferred.",
            "type": "string"
          },
          "organizationName": {
            "description": "The organization's name, to show the person.",
            "type": "string"
          },
          "reasons": {
            "description": "Why the organization cannot be left without an owner: `other_members` — other people are members of it; `active_subscription` — it has a current paid subscription.",
            "type": "array",
            "items": {
              "type": "string",
              "description": "One reason, from an open vocabulary: clients tolerate values they do not know and show the refusal's `error` text for them.",
              "x-known-values": "KnownAccountDeletionBlockReason"
            }
          }
        }
      },
      "KnownAccountDeletionBlockReason": {
        "description": "Reasons an organization blocks deleting its only owner's account.",
        "type": "string",
        "enum": [
          "other_members",
          "active_subscription"
        ]
      },
      "PasskeySignInVerifyRequest": {
        "description": "Request body of `POST /auth/passkeys/signin/verify`, the second half of a passkey sign-in: the browser's WebAuthn assertion together with the challenge state issued by `/auth/passkeys/signin/options`.",
        "type": "object",
        "required": [
          "challengeToken",
          "credential"
        ],
        "properties": {
          "challengeToken": {
            "description": "Opaque challenge state returned by `POST /auth/passkeys/signin/options`, replayed unchanged so the server can check the assertion against the challenge it issued. Single-use and short-lived.",
            "type": "string"
          },
          "credential": {
            "type": "object",
            "description": "The browser's AuthenticationResponseJSON",
            "additionalProperties": true
          }
        }
      },
      "SocialProvidersResponse": {
        "description": "Response of `GET /auth/social/providers`: the social sign-in providers this deployment is configured for, so the sign-in page renders only buttons that can complete.",
        "type": "object",
        "required": [
          "providers"
        ],
        "properties": {
          "providers": {
            "type": "array",
            "description": "Provider keys the server is configured for (e.g. \"google\")",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SocialTokenRequest": {
        "description": "Exchanges the single-use code the social-login callback placed in the URL fragment for a session. Request body of `POST /auth/token`.",
        "type": "object",
        "required": [
          "code"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Single-use code from the social-login callback fragment"
          }
        }
      },
      "LinkedAccount": {
        "description": "One external sign-in provider account linked to the caller's user, as listed by `GET /auth/identities`. Unlinking is `DELETE /auth/identities/{provider}`.",
        "type": "object",
        "required": [
          "provider",
          "accountId",
          "createdAt"
        ],
        "properties": {
          "provider": {
            "type": "string",
            "description": "Provider key, e.g. \"google\""
          },
          "accountId": {
            "type": "string",
            "description": "The provider's stable subject id for this user"
          },
          "createdAt": {
            "description": "When this provider account was linked to the user, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "LinkedAccountsResponse": {
        "description": "Response of `GET /auth/identities`: the social sign-in accounts linked to the calling user.",
        "type": "object",
        "required": [
          "identities"
        ],
        "properties": {
          "identities": {
            "description": "Each social provider account currently linked to the user, which may be used to sign in as them.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LinkedAccount"
            }
          }
        }
      },
      "SsoOrgRoleRule": {
        "description": "One rule of an SSO role mapping: when the IdP's group/role claim contains `match`, the signing-in user is granted `role` in the organization. Item of `SsoRoleMapping.orgRoleRules`.",
        "type": "object",
        "required": [
          "match",
          "role"
        ],
        "properties": {
          "match": {
            "type": "string",
            "description": "A group/role value from the IdP claim to match (case-insensitive)."
          },
          "role": {
            "$ref": "#/components/schemas/OrganizationRole"
          }
        }
      },
      "SsoWorkspaceRule": {
        "description": "One rule of an SSO role mapping: when the IdP's claim carries `match`, grant the signing-in user `role` in `workspaceId`. Every matching rule applies, additively, and the highest role per workspace wins.",
        "type": "object",
        "required": [
          "match",
          "workspaceId",
          "role"
        ],
        "properties": {
          "match": {
            "description": "A group or role value from the IdP claim. Compared trimmed and case-insensitively against every value the claim carries.",
            "type": "string"
          },
          "workspaceId": {
            "description": "The workspace to grant membership in. Must belong to the organization the SSO connection is configured on.",
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/WorkspaceRole"
          }
        }
      },
      "SsoWorkspaceGrant": {
        "description": "A workspace membership an SSO login grants: the workspace and the role to hold in it. Item of `SsoRoleMapping.defaultWorkspaceGrants` and of a workspace rule's grants; applied additively (never demotes an existing member).",
        "type": "object",
        "required": [
          "workspaceId",
          "role"
        ],
        "properties": {
          "workspaceId": {
            "description": "The workspace to grant membership in; must belong to the organization the SSO connection is configured for.",
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/WorkspaceRole"
          }
        }
      },
      "SsoRoleMapping": {
        "type": "object",
        "description": "Maps an IdP's group/role claim to org + workspace membership. Evaluated on every SSO login and applied additively (grants/upgrades only, never demotes). See identity/src/sso/roleMapping.ts.\n",
        "properties": {
          "claim": {
            "type": "string",
            "description": "The userinfo claim carrying group/role membership (default \"groups\")."
          },
          "orgRoleRules": {
            "description": "Claim value to organization role, first match wins; the matched role is granted or upgraded to, never demoted. `defaultOrgRole` applies when none matches.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SsoOrgRoleRule"
            }
          },
          "workspaceRules": {
            "description": "Claim value to a workspace membership and role; every matching rule applies, so one login can grant several workspaces.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SsoWorkspaceRule"
            }
          },
          "defaultOrgRole": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "owner",
              "admin",
              "billing",
              "member",
              null
            ],
            "description": "Org role when no orgRoleRule matches. Null/absent → no org membership."
          },
          "defaultWorkspaceGrants": {
            "description": "Workspace memberships every SSO user receives regardless of their claims, applied additively on each login.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SsoWorkspaceGrant"
            }
          }
        }
      },
      "SsoOidcConfigInput": {
        "description": "OIDC settings for an organization SSO connection: the identity provider's issuer and client credentials, plus optional discovery URL, scopes and PKCE switch. Carried as `oidc` in create and update requests; the client secret is write-only.",
        "type": "object",
        "required": [
          "issuer",
          "clientId"
        ],
        "properties": {
          "issuer": {
            "type": "string",
            "description": "OIDC issuer URL, e.g. https://acme.okta.com"
          },
          "clientId": {
            "description": "The OAuth client id the identity provider issued for this application. Only its last four characters are ever read back.",
            "type": "string"
          },
          "clientSecret": {
            "type": "string",
            "description": "Write-only. Required on create; omit on update to keep the current secret."
          },
          "discoveryEndpoint": {
            "type": "string",
            "description": "Defaults to {issuer}/.well-known/openid-configuration."
          },
          "scopes": {
            "description": "Scopes to request at sign-in. Omitted or empty means `openid profile email`; a non-empty list replaces that default, so include `openid` yourself.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "pkce": {
            "description": "Use PKCE on the authorization-code exchange. Leave on (the default) unless the provider does not support it.",
            "type": "boolean",
            "default": true
          }
        }
      },
      "SsoOidcConfigUpdate": {
        "type": "object",
        "description": "All fields optional — for partial updates. Omit clientSecret to keep the current one.",
        "properties": {
          "issuer": {
            "description": "New OIDC issuer URL, e.g. `https://acme.okta.com`.",
            "type": "string"
          },
          "clientId": {
            "description": "New OAuth client id registered with the identity provider.",
            "type": "string"
          },
          "clientSecret": {
            "description": "New client secret; write-only, never returned. Omit to keep the current one.",
            "type": "string"
          },
          "discoveryEndpoint": {
            "description": "New discovery document URL; defaults to `{issuer}/.well-known/openid-configuration` when not set.",
            "type": "string"
          },
          "scopes": {
            "description": "Replaces the OAuth scopes requested at sign-in.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "pkce": {
            "description": "Whether to use PKCE in the authorization code flow.",
            "type": "boolean"
          }
        }
      },
      "SsoConnection": {
        "type": "object",
        "description": "Secret-free view of an SSO connection.",
        "required": [
          "connectionId",
          "organizationId",
          "name",
          "issuer",
          "clientIdLast4",
          "scopes",
          "pkce",
          "hasClientSecret",
          "trustsEmailClaim",
          "enabled",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "connectionId": {
            "type": "string",
            "description": "Stable id used in the sign-in URL (/auth/sso/{connectionId}/start)."
          },
          "organizationId": {
            "description": "The organization the connection belongs to; echoes the path parameter.",
            "type": "string"
          },
          "name": {
            "description": "Admin-facing label for the connection, shown on the sign-in button and in the SSO list.",
            "type": "string"
          },
          "issuer": {
            "description": "The OIDC issuer URL the connection trusts, e.g. `https://acme.okta.com`.",
            "type": "string"
          },
          "domain": {
            "description": "Email domain this connection serves, used to route a sign-in by email address to it. Null when the connection is reached only by its explicit sign-in URL.",
            "type": [
              "string",
              "null"
            ]
          },
          "clientIdLast4": {
            "description": "Last four characters of the OIDC client id, enough to recognise which IdP app is configured without exposing the whole id.",
            "type": "string"
          },
          "discoveryEndpoint": {
            "description": "Explicit OIDC discovery URL when one was configured. Null when the default `{issuer}/.well-known/openid-configuration` is used.",
            "type": [
              "string",
              "null"
            ]
          },
          "scopes": {
            "description": "OIDC scopes requested at login, e.g. `openid`, `email`, `profile`, plus whatever carries the role-mapping claim.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "pkce": {
            "description": "Whether the authorization-code flow uses PKCE. Defaults to true at creation.",
            "type": "boolean"
          },
          "hasClientSecret": {
            "description": "Whether a client secret is stored for the connection. The secret itself is write-only and never returned.",
            "type": "boolean"
          },
          "roleMapping": {
            "description": "How the IdP's group claim translates into organization and workspace roles on each login. Null when logins grant no roles automatically.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/SsoRoleMapping"
              },
              {
                "type": "null"
              }
            ]
          },
          "trustsEmailClaim": {
            "description": "This identity provider is ours alone, and the email it reports for a member is that member's mailbox. Lets a connected app link or provision a person by the email in their token when the provider does not assert `email_verified`. Honoured only for a tenant-specific issuer. Only an organization owner may turn it on.",
            "type": "boolean"
          },
          "enabled": {
            "description": "Whether users can currently sign in through this connection. A disabled connection keeps its configuration but refuses logins.",
            "type": "boolean"
          },
          "createdAt": {
            "description": "When the connection was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the connection's configuration last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateSsoConnectionRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/sso-connections`: an OIDC single sign-on connection for the organization. The client secret is stored encrypted and never returned.",
        "type": "object",
        "required": [
          "name",
          "oidc"
        ],
        "properties": {
          "name": {
            "description": "Admin-facing label for the connection, e.g. \"Okta (acme.com)\", shown on the sign-in button and in the organization's SSO list.",
            "type": "string"
          },
          "domain": {
            "type": "string",
            "description": "Optional email domain this connection serves (used by domain routing)."
          },
          "oidc": {
            "$ref": "#/components/schemas/SsoOidcConfigInput"
          },
          "roleMapping": {
            "description": "How the IdP's group claim translates into organization and workspace roles on each login. Omit or pass null for no automatic role grants.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/SsoRoleMapping"
              },
              {
                "type": "null"
              }
            ]
          },
          "trustsEmailClaim": {
            "description": "This identity provider is ours alone, and the email it reports for a member is that member's mailbox. Lets a connected app link or provision a person by the email in their token when the provider does not assert `email_verified`. Honoured only for a tenant-specific issuer. Only an organization owner may turn it on. Defaults to false.",
            "type": "boolean",
            "default": false
          },
          "enabled": {
            "description": "Whether users can sign in through this connection immediately. Defaults to true; create it disabled to finish configuration first.",
            "type": "boolean",
            "default": true
          }
        }
      },
      "UpdateSsoConnectionRequest": {
        "type": "object",
        "description": "Partial update. Only provided fields change.",
        "properties": {
          "name": {
            "description": "Label for the connection shown to admins and on the sign-in button.",
            "type": "string"
          },
          "domain": {
            "description": "Email domain this connection serves, so sign-in by an address at that domain is routed to it. Null clears the routing; omit to leave it unchanged.",
            "type": [
              "string",
              "null"
            ]
          },
          "oidc": {
            "$ref": "#/components/schemas/SsoOidcConfigUpdate"
          },
          "roleMapping": {
            "description": "How an identity-provider claim maps onto organization and workspace roles, applied additively on every SSO sign-in. Null removes the mapping so sign-ins grant no roles automatically; omit to leave it unchanged. A mapping that grants an elevated organization role may only be set by an organization owner.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/SsoRoleMapping"
              },
              {
                "type": "null"
              }
            ]
          },
          "trustsEmailClaim": {
            "description": "This identity provider is ours alone, and the email it reports for a member is that member's mailbox. Lets a connected app link or provision a person by the email in their token when the provider does not assert `email_verified`. Honoured only for a tenant-specific issuer. Only an organization owner may turn it on. Omit to leave it unchanged.",
            "type": "boolean"
          },
          "enabled": {
            "description": "Whether sign-in through this connection is accepted. False disables it immediately without deleting the configuration.",
            "type": "boolean"
          }
        }
      },
      "ConnectedAppSubjectClaim": {
        "type": "string",
        "enum": [
          "sub",
          "oid"
        ],
        "description": "Which claim of the identity provider's token names the person. `sub` fits every provider except Microsoft Entra, whose `sub` is pairwise per app registration; there `oid` is the stable identifier. Whatever claim is chosen, the server refuses a token that lacks it."
      },
      "ConnectedApp": {
        "type": "object",
        "description": "A connected app: a frontend on the customer's own origin, signed in through the organization's identity provider, that exchanges that provider's `id_token` for a Tessule token capped to the app's scopes.",
        "required": [
          "id",
          "organizationId",
          "name",
          "ssoConnectionId",
          "tokenAudiences",
          "subjectClaim",
          "allowedOrigins",
          "allowedWorkspaceIds",
          "scopes",
          "accessTokenLifetime",
          "enabled",
          "policyVersion",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "The `client_id` the app sends when it exchanges a token: `app_` followed by 24 hexadecimal characters. Stable for the life of the registration.",
            "type": "string"
          },
          "organizationId": {
            "description": "The organization the app is registered in; echoes the path parameter.",
            "type": "string"
          },
          "name": {
            "description": "Admin-facing label for the app, shown in the organization's connected-app list.",
            "type": "string"
          },
          "ssoConnectionId": {
            "description": "The organization's SSO connection whose identity provider signs the `id_token` the app presents. Tokens from any other issuer are refused.",
            "type": "string"
          },
          "tokenAudiences": {
            "description": "The `aud` values the app's `id_token` may carry. A token whose audience is not in this list is refused.",
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 256
            }
          },
          "subjectClaim": {
            "$ref": "#/components/schemas/ConnectedAppSubjectClaim"
          },
          "allowedOrigins": {
            "description": "Browser origins (scheme, host and port) the app is served from. A token exchange from any other origin is refused.",
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 512
            }
          },
          "allowedWorkspaceIds": {
            "description": "Workspaces of the organization the app may act in. Empty means any workspace of the organization.",
            "type": "array",
            "maxItems": 100,
            "items": {
              "type": "string"
            }
          },
          "scopes": {
            "description": "The app's ceiling: workspace actions a token issued to the app may carry, each a workspace action such as `records:read`. A person's token through the app holds at most the intersection of these and what that person may do themselves.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "accessTokenLifetime": {
            "description": "How long a token issued to the app stays valid, in seconds. Between 60 and 1800.",
            "type": "integer",
            "minimum": 60,
            "maximum": 1800
          },
          "enabled": {
            "description": "Whether the app can currently exchange tokens. A disabled app keeps its registration but every exchange is refused.",
            "type": "boolean"
          },
          "policyVersion": {
            "description": "Counter that rises whenever a field governing what a token may do changes. Tokens issued under an earlier version are no longer honoured, so a client that holds one exchanges again.",
            "type": "integer"
          },
          "lastUsedAt": {
            "description": "When the app last exchanged a token, ISO-8601 UTC. Null when it has never been used.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "description": "When the app was registered, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the registration last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateConnectedAppRequest": {
        "type": "object",
        "description": "Request body of `POST /organizations/{organizationId}/connected-apps`: registers a connected app against one of the organization's SSO connections.",
        "required": [
          "name",
          "ssoConnectionId",
          "tokenAudiences",
          "allowedOrigins"
        ],
        "properties": {
          "name": {
            "description": "Admin-facing label for the app, 1 to 255 characters. The server refuses an empty or longer name.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "ssoConnectionId": {
            "description": "Id of an SSO connection of this organization whose identity provider signs the app's `id_token`. The server refuses a connection that does not exist or belongs to another organization.",
            "type": "string"
          },
          "tokenAudiences": {
            "description": "The `aud` values the app's `id_token` may carry, usually the client id the identity provider issued to the app. One to ten entries; the server refuses an empty list.",
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "items": {
              "type": "string",
              "maxLength": 256
            }
          },
          "subjectClaim": {
            "description": "Which token claim names the person. Defaults to `sub`; use `oid` for Microsoft Entra.",
            "allOf": [
              {
                "$ref": "#/components/schemas/ConnectedAppSubjectClaim"
              }
            ],
            "default": "sub"
          },
          "allowedOrigins": {
            "description": "Browser origins the app is served from, each scheme, host and optional port with no path. One to ten entries; the server refuses an empty list or a malformed origin.",
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "items": {
              "type": "string",
              "maxLength": 512
            }
          },
          "allowedWorkspaceIds": {
            "description": "Workspaces of the organization the app may act in. Defaults to empty, meaning any workspace of the organization. The server refuses an id outside the organization.",
            "type": "array",
            "maxItems": 100,
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "scopes": {
            "description": "The app's ceiling, as workspace actions. Defaults to every delegable action outside the Administration category. The server refuses an action that is unknown or not delegable.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "accessTokenLifetime": {
            "description": "Lifetime of issued tokens in seconds, 60 to 1800. Defaults to 1800; the server refuses a value outside that range.",
            "type": "integer",
            "minimum": 60,
            "maximum": 1800,
            "default": 1800
          },
          "enabled": {
            "description": "Whether the app can exchange tokens immediately. Defaults to true; register it disabled to finish configuration first.",
            "type": "boolean",
            "default": true
          }
        }
      },
      "UpdateConnectedAppRequest": {
        "type": "object",
        "description": "Partial update. Only provided fields change. Changing `ssoConnectionId`, `tokenAudiences`, `subjectClaim`, `allowedOrigins`, `allowedWorkspaceIds`, `scopes`, `accessTokenLifetime` or `enabled` bumps `policyVersion`; a name change does not.",
        "properties": {
          "name": {
            "description": "New admin-facing label, 1 to 255 characters. Does not change `policyVersion`.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "ssoConnectionId": {
            "description": "Id of another SSO connection of this organization to trust instead. The server refuses a connection that does not exist or belongs to another organization.",
            "type": "string"
          },
          "tokenAudiences": {
            "description": "Replacement list of accepted `aud` values, one to ten entries. Replaces the whole list.",
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "items": {
              "type": "string",
              "maxLength": 256
            }
          },
          "subjectClaim": {
            "description": "Which token claim names the person, `sub` or `oid`.",
            "allOf": [
              {
                "$ref": "#/components/schemas/ConnectedAppSubjectClaim"
              }
            ]
          },
          "allowedOrigins": {
            "description": "Replacement list of origins the app is served from, one to ten entries. Replaces the whole list; the server refuses a malformed origin.",
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "items": {
              "type": "string",
              "maxLength": 512
            }
          },
          "allowedWorkspaceIds": {
            "description": "Replacement list of workspaces the app may act in. An empty list means any workspace of the organization. The server refuses an id outside the organization.",
            "type": "array",
            "maxItems": 100,
            "items": {
              "type": "string"
            }
          },
          "scopes": {
            "description": "Replacement ceiling, as workspace actions. The server refuses an action that is unknown or not delegable.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "accessTokenLifetime": {
            "description": "Lifetime of issued tokens in seconds, 60 to 1800.",
            "type": "integer",
            "minimum": 60,
            "maximum": 1800
          },
          "enabled": {
            "description": "Whether the app can exchange tokens. False refuses every exchange without deleting the registration.",
            "type": "boolean"
          }
        }
      },
      "LoginMethods": {
        "type": "object",
        "description": "Login methods for an email, computed from domain policy only — plus whether sign-up for it is restricted to the early-access list.\n",
        "required": [
          "password",
          "social",
          "sso",
          "ssoRequired",
          "registrationRestricted"
        ],
        "properties": {
          "password": {
            "description": "Whether the password form should be offered. False when the email's domain requires SSO.",
            "type": "boolean"
          },
          "registrationRestricted": {
            "type": "boolean",
            "description": "True when sign-ups are restricted to the early-access allowlist and this address is not on it: an account created for it will be held pending until an operator admits it (see EarlyAccessPendingResponse), so the sign-up form can say so up front. Reveals allowlist membership only, never whether an account exists.\n"
          },
          "social": {
            "description": "Provider keys (e.g. `google`) of the social sign-in buttons to show. Empty when the domain requires SSO or no social provider is configured.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sso": {
            "description": "Enterprise SSO connections that apply to this email's domain, to render as sign-in options. Empty when the domain has none.",
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "connectionId",
                "name"
              ],
              "properties": {
                "connectionId": {
                  "description": "Identifier of the SSO connection, passed to the SSO start endpoint to begin that sign-in.",
                  "type": "string"
                },
                "name": {
                  "description": "Display name of the SSO connection, for the button label.",
                  "type": "string"
                }
              }
            }
          },
          "ssoRequired": {
            "description": "True when the domain's verified policy forces SSO: password and social sign-in are then refused for this address, not merely hidden.",
            "type": "boolean"
          }
        }
      },
      "OrgDomain": {
        "description": "An email domain an organization has claimed, returned by the organization domains endpoints. Verified by publishing a DNS TXT record; once verified it drives login policy for addresses on that domain (auto-join, capture of existing users, mandatory SSO).",
        "type": "object",
        "required": [
          "domainId",
          "organizationId",
          "domain",
          "status",
          "txtRecordName",
          "txtRecordValue",
          "failedChecks",
          "captureExisting",
          "enforceSso",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "domainId": {
            "description": "Stable identifier of the claim, used in the `/domains/{domainId}` endpoints.",
            "type": "string"
          },
          "organizationId": {
            "description": "The organization holding the claim; only one organization may hold a verified claim on a domain at a time.",
            "type": "string"
          },
          "domain": {
            "description": "The claimed email domain, lower-cased and punycoded (e.g. `acme.com`); the part after `@` of matching addresses.",
            "type": "string"
          },
          "status": {
            "description": "`pending` claimed but the TXT record has not been seen; `verified` the record was found and the login policy applies; `failed` a previously verified domain lost its record for three consecutive re-checks, so its policy no longer applies until re-verified.",
            "type": "string",
            "enum": [
              "pending",
              "verified",
              "failed"
            ]
          },
          "txtRecordName": {
            "type": "string",
            "description": "DNS record name to publish (e.g. _crm-domain-verify.acme.com)"
          },
          "txtRecordValue": {
            "type": "string",
            "description": "Exact TXT value to publish"
          },
          "verifiedAt": {
            "description": "When verification first succeeded, ISO-8601 UTC; null while never verified.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastCheckedAt": {
            "description": "When the DNS record was last looked up, by the verify endpoint or the scheduled re-check, ISO-8601 UTC; null if never checked.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "failedChecks": {
            "description": "Consecutive re-checks of a verified domain that did not find the TXT record; resets to 0 on success, and the third failure demotes the domain to `failed`.",
            "type": "integer"
          },
          "captureExisting": {
            "description": "Whether existing users whose email is on this domain are attached to the organization when they log in (only once the domain is verified and `autoJoinRole` is set).",
            "type": "boolean"
          },
          "autoJoinRole": {
            "description": "Organization role granted to users who sign up with, or are captured by, an address on this domain. Null switches auto-join and capture off.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/OrganizationRole"
              },
              {
                "type": "null"
              }
            ]
          },
          "enforceSso": {
            "description": "Whether users on this domain must sign in through the SSO connection in `ssoConnectionId` rather than with a password.",
            "type": "boolean"
          },
          "ssoConnectionId": {
            "description": "The SSO connection used for `enforceSso`; null when none is linked. Deleting the connection clears this and so relaxes enforcement rather than locking the domain out.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the domain was claimed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the claim or its login policy last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "UpdateOrgDomainRequest": {
        "type": "object",
        "description": "Partial update of a domain's login policy.",
        "properties": {
          "captureExisting": {
            "description": "Whether an existing user with a verified email on this domain is added to the organization, with `autoJoinRole`, the next time they sign in. Has no effect while `autoJoinRole` is null.",
            "type": "boolean"
          },
          "autoJoinRole": {
            "description": "Organization role granted automatically to someone who signs up with an email on this verified domain (and to captured existing users). Null switches auto-join off.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/OrganizationRole"
              },
              {
                "type": "null"
              }
            ]
          },
          "enforceSso": {
            "description": "When true, users with an email on this domain must sign in through the organization's SSO connection; other sign-in methods are refused with `SSO_REQUIRED`.",
            "type": "boolean"
          },
          "ssoConnectionId": {
            "description": "The SSO connection that serves sign-in for this domain and that `enforceSso` requires. Null detaches it.",
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "OrgDomainVerifyResult": {
        "description": "Response of `POST /organizations/{organizationId}/domains/{domainId}/verify`: whether the DNS check passed, with the domain's updated state.",
        "type": "object",
        "required": [
          "verified",
          "domain"
        ],
        "properties": {
          "verified": {
            "description": "True when the TXT record was found and the domain is now `verified`; false when the check failed and `domain.status` says where it stands.",
            "type": "boolean"
          },
          "domain": {
            "$ref": "#/components/schemas/OrgDomain"
          }
        }
      },
      "WorkspaceMember": {
        "description": "A person's membership of a workspace: who they are, their workspace role, whether the membership is active, and who brought them in. Returned by the `/workspaces/{workspaceId}/members` endpoints.",
        "type": "object",
        "required": [
          "userId",
          "email",
          "name",
          "role",
          "isActive",
          "joinedAt"
        ],
        "properties": {
          "userId": {
            "description": "User id of the member — the `{userId}` of the member endpoints and the value stored in `createdBy`-style fields across the workspace.",
            "type": "string"
          },
          "email": {
            "description": "The member's sign-in email address at the time of the read.",
            "type": "string",
            "format": "email"
          },
          "name": {
            "description": "The member's display name at the time of the read.",
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/WorkspaceRole"
          },
          "isActive": {
            "description": "True for a current member. False after a deactivation (`DELETE …/members/{userId}`): the person keeps appearing in history but cannot sign in to the workspace until reactivated. Inactive members are listed only when asked for.",
            "type": "boolean"
          },
          "joinedAt": {
            "description": "When the person was granted membership of the workspace, ISO-8601 UTC. Not reset by deactivation or reactivation.",
            "type": "string",
            "format": "date-time"
          },
          "invitedById": {
            "description": "User id of the member who granted them access. Null when the membership was created without an inviter (the workspace's founder) or the inviter's account no longer exists.",
            "type": [
              "string",
              "null"
            ]
          },
          "invitedByName": {
            "description": "Display name of the inviter, resolved for showing beside `invitedById`. Null whenever that id is null or no longer resolves.",
            "type": [
              "string",
              "null"
            ]
          },
          "deactivatedAt": {
            "description": "When the membership was deactivated, ISO-8601 UTC. Null while `isActive` is true, including after a reactivation.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "UpdateMemberRoleRequest": {
        "description": "Request body of `PATCH /workspaces/{workspaceId}/members/{userId}`: the member's new workspace role.",
        "type": "object",
        "required": [
          "role"
        ],
        "properties": {
          "role": {
            "$ref": "#/components/schemas/WorkspaceRole"
          }
        }
      },
      "AddWorkspaceMemberRequest": {
        "description": "Request body of `POST /workspaces/{workspaceId}/members`: grant an existing organization member access to this workspace with a workspace role. Organization membership is a precondition, not something this call creates.",
        "type": "object",
        "required": [
          "userId",
          "role"
        ],
        "properties": {
          "userId": {
            "type": "string",
            "description": "Id of the organization member to grant workspace access to"
          },
          "role": {
            "$ref": "#/components/schemas/WorkspaceRole"
          }
        }
      },
      "OrganizationSummary": {
        "description": "One organization the caller can see, with their role in it. Item of the `GET /organizations` list used to populate the organization switcher.",
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the organization; the `organizationId` of the organization endpoints.",
            "type": "string"
          },
          "name": {
            "description": "The organization's display name.",
            "type": "string"
          },
          "role": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/OrganizationRole"
              },
              {
                "type": "null"
              }
            ],
            "description": "Current user's organization role. Null when the org is only visible through a workspace membership."
          }
        }
      },
      "Organization": {
        "description": "The billing-and-ownership unit that workspaces belong to, as seen by the calling user: its name, the caller's role in it and how many workspaces it holds. Returned by organization create, get and update.",
        "type": "object",
        "required": [
          "id",
          "name",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the organization, used in every `/organizations/{organizationId}` path.",
            "type": "string"
          },
          "name": {
            "description": "Display name of the organization, as shown in the switcher and on invoices.",
            "type": "string"
          },
          "role": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/OrganizationRole"
              },
              {
                "type": "null"
              }
            ],
            "description": "Current user's organization role"
          },
          "workspaceCount": {
            "description": "How many workspaces the organization currently holds. 0 immediately after creation.",
            "type": "integer"
          },
          "createdAt": {
            "description": "When the organization was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the organization's own settings last changed, ISO-8601 UTC; workspace changes do not move it.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateOrganizationRequest": {
        "type": "object",
        "description": "`features` sets the new organization's feature toggles in the same transaction that creates it, exactly as a later PUT /features would. A toggle left out (or the whole object) keeps its default.\n",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "description": "Display name of the new organization, shown wherever its workspaces and members are listed.",
            "type": "string"
          },
          "features": {
            "$ref": "#/components/schemas/UpdateOrganizationFeaturesRequest"
          }
        }
      },
      "UpdateOrganizationRequest": {
        "description": "Request body of `PATCH /organizations/{organizationId}`: the organization's new name.",
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "description": "The organization's new display name.",
            "type": "string"
          }
        }
      },
      "LimitTier": {
        "type": "string",
        "description": "Which tier of the limit ladder supplied a value. T1 the resource's own configuration, T2 the organization's maximum, T3 the plan entitlement or an operator override, T4 the global hard cap.\n",
        "enum": [
          "T1",
          "T2",
          "T3",
          "T4"
        ]
      },
      "OrganizationLimitPolicy": {
        "description": "One measure in an organization's limit policy (`OrganizationLimitPolicies`): what the measure counts, the maxima the organization has chosen for its workspaces and resources, and the entitlement ceilings those maxima may not exceed.",
        "type": "object",
        "required": [
          "measure",
          "description",
          "unit",
          "resourceType",
          "resourceLabel",
          "entitlementPerWorkspace",
          "entitlementPerResource"
        ],
        "properties": {
          "measure": {
            "type": "string",
            "description": "Measure key, e.g. webhook.invocations."
          },
          "description": {
            "description": "Human-readable description of what the measure counts, for settings screens and documentation.",
            "type": "string"
          },
          "unit": {
            "description": "Display label for the measure's values, e.g. `invocations/day`.",
            "type": "string"
          },
          "resourceType": {
            "type": "string",
            "description": "The kind of resource the per-resource maximum applies to. Meaningful only when `resourceLabel` is not null."
          },
          "resourceLabel": {
            "type": [
              "string",
              "null"
            ],
            "description": "What one resource of `resourceType` is called on a settings screen, e.g. `inbound webhook`. Null when the measure is counted only per workspace: it then has no per-resource maximum, so a client offers only the per-workspace one, `maxPerResource` is always null, and `entitlementPerResource` (0) is not an allowance. Sending a `maxPerResource` for such a measure is refused."
          },
          "maxPerWorkspace": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The most any one workspace may hold as its total, or null when the organization sets none and the entitlement applies.\n"
          },
          "maxPerResource": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The most any single resource may be configured to, or null when the organization sets none (or the measure has no per-resource maximum).\n"
          },
          "entitlementPerWorkspace": {
            "type": "integer",
            "description": "The ceiling above the organization's own per-workspace maximum: what the plan (or an operator override) allows, in `unit`. A clear maximum falls back to this. 0 means the plan does not include the measure."
          },
          "entitlementPerResource": {
            "type": "integer",
            "description": "The ceiling above the organization's own per-resource maximum, in `unit`. Only meaningful when `resourceLabel` is not null; 0 then means the plan does not include it."
          }
        }
      },
      "OrganizationLimitPolicies": {
        "description": "The quota maxima an organization sets for its own workspaces, one entry per measure, each beside the entitlement ceiling above it. Response of `GET`/`PUT /organizations/{organizationId}/limit-policies`.",
        "type": "object",
        "required": [
          "policies"
        ],
        "properties": {
          "policies": {
            "description": "One entry per quota measure: the maximum the organization allows a workspace to configure, beside the entitlement ceiling it may not exceed.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrganizationLimitPolicy"
            }
          }
        }
      },
      "UpdateOrganizationLimitPolicyRequest": {
        "description": "Request body of `PUT /organizations/{organizationId}/limit-policies`: the organization's own maxima for one measure — the most a workspace may hold in total and the most one resource may be configured to. Null clears a maximum back to the entitlement above it.",
        "type": "object",
        "required": [
          "measure"
        ],
        "properties": {
          "measure": {
            "description": "Key of the measure to set, e.g. `webhook.invocations`, as listed by `GET /organizations/{organizationId}/limit-policies`.",
            "type": "string"
          },
          "maxPerWorkspace": {
            "description": "The most any one workspace may hold as its total for the measure; clamped to the entitlement. Null (or omitted) clears the organization's own maximum so the entitlement applies.",
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          },
          "maxPerResource": {
            "description": "The most any single resource (of the measure's `resourceType`) may be configured to; clamped to the entitlement. Null (or omitted) clears it. Refused for a measure whose `resourceLabel` is null, which has no per-resource maximum.",
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          }
        }
      },
      "ResourceLimitStatus": {
        "description": "Response of `GET`/`PUT /resource-limits/{measure}/{resourceType}/{resourceId}`: how a rate-limited measure resolves for one resource — the limit actually enforced, which tier bound it, the most an admin may configure, what is configured, and usage in the open window.",
        "type": "object",
        "required": [
          "measure",
          "resourceType",
          "resourceId",
          "unit",
          "window",
          "effectiveLimit",
          "boundBy",
          "maximum",
          "used",
          "windowEndsAt"
        ],
        "properties": {
          "measure": {
            "description": "Which counted thing this is — `webhook.invocations`, `query.executions`, `search.executions`, … — the `measure` path segment echoed back.",
            "type": "string"
          },
          "resourceType": {
            "description": "The kind of resource the counter keys on, e.g. `automation` (a flow) for webhook invocations; the `resourceType` path segment echoed back.",
            "type": "string"
          },
          "resourceId": {
            "description": "Id of that resource, in the id space `resourceType` names (a flow id for `automation`); the `resourceId` path segment echoed back.",
            "type": "string"
          },
          "unit": {
            "description": "Display label for what is counted, e.g. `invocations/day`. For presentation only.",
            "type": "string"
          },
          "window": {
            "type": "string",
            "description": "Window length the quota is counted over."
          },
          "effectiveLimit": {
            "type": "integer",
            "description": "The value actually enforced."
          },
          "boundBy": {
            "$ref": "#/components/schemas/LimitTier"
          },
          "maximum": {
            "type": "integer",
            "description": "The most a workspace admin may configure here. A configured value above this is clamped, never grandfathered.\n"
          },
          "configured": {
            "type": [
              "integer",
              "null"
            ],
            "description": "What is stored for this resource, present even when it exceeds the maximum and is therefore not the value in force.\n"
          },
          "used": {
            "type": "integer",
            "description": "Count so far in the open window."
          },
          "windowEndsAt": {
            "description": "When the current counting window closes and `used` starts again from zero, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "alertStops": {
            "type": [
              "array",
              "null"
            ],
            "description": "Configured alert stops, or null when the implicit 75%/100% defaults apply. Only customizations are stored.\n",
            "items": {
              "$ref": "#/components/schemas/LimitAlertStop"
            }
          }
        }
      },
      "WorkspaceLimitUsage": {
        "type": "object",
        "description": "Read-only usage snapshot. Organization figures are the SUM of their workspaces' rows — there is no counter above the workspace, so there is nothing here to aggregate across tenants.\n",
        "required": [
          "rows"
        ],
        "properties": {
          "rows": {
            "description": "One row per limited measure, with the current count, the applicable limit and headroom.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LimitUsageRow"
            }
          }
        }
      },
      "LimitUsageRow": {
        "description": "One quota counter in a workspace usage snapshot (`WorkspaceLimitUsage.rows`): a measure for one resource or for the workspace total, with the limit actually enforced, where that limit came from, and usage in the current window.",
        "type": "object",
        "required": [
          "measure",
          "scope",
          "resourceType",
          "resourceId",
          "unit",
          "used",
          "effectiveLimit",
          "boundBy",
          "maximum",
          "windowEndsAt"
        ],
        "properties": {
          "measure": {
            "description": "Measure key this row counts, e.g. `webhook.invocations` or `query.executions` (see `OrganizationLimitPolicy.measure`).",
            "type": "string"
          },
          "scope": {
            "type": "string",
            "description": "`resource` for one resource's own counter, `workspace` for the workspace total."
          },
          "resourceType": {
            "description": "`workspace` for the workspace-total row; otherwise the kind of resource the measure counts per resource, e.g. `automation` (a flow).",
            "type": "string"
          },
          "resourceId": {
            "description": "Id of the counted resource; the workspace id itself when `resourceType` is `workspace`.",
            "type": "string"
          },
          "resourceName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Best-effort display name; null when the resource has been deleted."
          },
          "unit": {
            "description": "Display label for the numbers in this row, e.g. `invocations/day`.",
            "type": "string"
          },
          "used": {
            "description": "Count consumed so far in the window that ends at `windowEndsAt`.",
            "type": "integer"
          },
          "effectiveLimit": {
            "description": "The limit actually enforced: the lowest value across the tiers of the ladder, `boundBy` naming the tier that supplied it.",
            "type": "integer"
          },
          "boundBy": {
            "$ref": "#/components/schemas/LimitTier"
          },
          "maximum": {
            "description": "The highest value a workspace admin may configure for this counter — the ceiling the tiers above the resource's own configuration impose.",
            "type": "integer"
          },
          "configured": {
            "description": "The value configured on the resource itself (tier T1), even when it is being clamped to `maximum`; null when nothing is configured and the maximum is inherited.",
            "type": [
              "integer",
              "null"
            ]
          },
          "windowEndsAt": {
            "description": "When the current counting window closes and `used` resets, ISO-8601 UTC; windows are per measure (for example daily).",
            "type": "string",
            "format": "date-time"
          },
          "alertStops": {
            "type": [
              "array",
              "null"
            ],
            "description": "The configured alert stops, or null when the implicit 75%/100% defaults are in force. Absence of configuration is the normal case — nothing backfills a row per resource.\n",
            "items": {
              "$ref": "#/components/schemas/LimitAlertStop"
            }
          }
        }
      },
      "LimitAlertStop": {
        "type": "object",
        "description": "One alert trigger, as a percentage of the effective ceiling or an absolute count. Absolutes matter to people who think in \"we've used 10 000 of our 12 000\". Exactly one of `pct`/`abs` is set.\n",
        "properties": {
          "pct": {
            "description": "Fire when usage reaches this percentage of the effective ceiling (1–100). Set instead of `abs`.",
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "abs": {
            "description": "Fire when usage reaches this absolute count in the limit's own unit. Set instead of `pct`; useful when the ceiling is large and people think in raw numbers.",
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "UpdateResourceLimitRequest": {
        "description": "Request body of `PUT /resource-limits/{measure}/{resourceType}/{resourceId}`: a workspace admin's own maximum for one resource's counter and/or its alert stops. Properties left out are left alone.",
        "type": "object",
        "properties": {
          "value": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Null clears the configuration so the maximum is inherited."
          },
          "alertStops": {
            "type": [
              "array",
              "null"
            ],
            "description": "Replaces this resource's alert stops. Omitted leaves them alone; an empty array disables alerting for this resource entirely.\n",
            "items": {
              "$ref": "#/components/schemas/LimitAlertStop"
            }
          },
          "clearAlertStops": {
            "type": "boolean",
            "description": "Clears any customization so the implicit 75%/100% defaults apply again. Distinct from an empty `alertStops`, which means \"never alert\".\n"
          }
        }
      },
      "Notification": {
        "type": "object",
        "description": "One notification as the calling user sees it. Rendered copy (title/body) is produced server-side from the stored payload at read time, so a copy change never needs a data migration and a client never has to know a kind's payload shape.\n\nVisibility is decided per row: each kind declares the permission ACTION required to see it, resolved against the caller's snapshot. Holding `notifications:read` only permits asking.\n",
        "required": [
          "id",
          "type",
          "lifecycle",
          "severity",
          "status",
          "title",
          "body",
          "read",
          "dismissible",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Server-assigned identifier of the notification; what the acknowledge endpoint takes.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "type": {
            "type": "string",
            "x-known-values": "KnownNotificationType",
            "description": "Notification kind. The values known to this version are enumerated by the KnownNotificationType schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed, and MUST render from title/body/severity rather than switching on this."
          },
          "lifecycle": {
            "type": "string",
            "x-known-values": "KnownNotificationLifecycle",
            "description": "`condition` is a state that is true until it isn't (it reconciles on re-raise and auto-resolves); `event` is a point-in-time fact that is appended and never resolves. Open by contract — clients MUST tolerate values not yet listed."
          },
          "severity": {
            "type": "string",
            "x-known-values": "KnownNotificationSeverity",
            "description": "Affects PROMINENCE ONLY. There is deliberately no severity above `critical`, and `critical` tops out at a dismissible banner — a notification explains a restriction, it is never the mechanism of one. Open by contract — clients MUST tolerate values not yet listed, and MUST treat an unknown severity as no louder than `warning`."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownNotificationStatus",
            "description": "`acknowledged` is SHARED for conditions: one admin acknowledging drops the banner to the badge for everyone, rather than five admins each dismissing the same true fact. Open by contract — clients MUST tolerate values not yet listed."
          },
          "workspaceId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Set for workspace-scoped notifications; null for org-scoped ones."
          },
          "resourceType": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional deep target's kind, e.g. `automation`."
          },
          "resourceId": {
            "description": "Id of the thing the notification is about, in the id space `resourceType` names (a flow id for `automation`). Null when the notification has no deep target.",
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "description": "One-line headline, rendered server-side from the stored payload in the kind's current copy. Display verbatim.",
            "type": "string"
          },
          "body": {
            "description": "Explanatory text under the title, rendered server-side as plain text. Display verbatim.",
            "type": "string"
          },
          "actionHref": {
            "type": [
              "string",
              "null"
            ],
            "description": "Root-relative link to where the state can be understood or fixed. Always root-relative — a notification can never point off-product.\n"
          },
          "actionLabel": {
            "description": "Button text for `actionHref`, e.g. a short verb phrase naming where the link goes. Null when there is no action link.",
            "type": [
              "string",
              "null"
            ]
          },
          "read": {
            "type": "boolean",
            "description": "Per-user read state. Absence of an interaction means unread."
          },
          "dismissible": {
            "type": "boolean",
            "description": "Whether the caller may dismiss it (POST /notifications/{notificationId}/dismiss), which hides it from their own list and badge only. True for an event and for a resolved condition, which can no longer change; false for a condition that is still open or acknowledged, because it is still true and drops out by itself once it resolves. A client offers a dismiss control only when this is true."
          },
          "createdAt": {
            "description": "When the notification was raised, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the row last changed — a re-raise, an acknowledgement or a resolution — ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "acknowledgedAt": {
            "description": "When an admin acknowledged it (status became `acknowledged`), ISO-8601 UTC; null until then. For a condition the acknowledgement is shared by everyone who can see it.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "resolvedAt": {
            "description": "For a `condition`, when the server observed it no longer held and resolved it, ISO-8601 UTC. Null while the condition holds, and always null for an `event`, which never resolves.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "NotificationList": {
        "description": "Response of `GET /notifications`: one page of the caller's visible notifications, conditions first and then events (newest first), with a flag saying whether another page should be requested.",
        "type": "object",
        "required": [
          "notifications",
          "hasMore"
        ],
        "properties": {
          "notifications": {
            "type": "array",
            "description": "Conditions first (they are claims about now), then events, newest first.",
            "items": {
              "$ref": "#/components/schemas/Notification"
            }
          },
          "hasMore": {
            "type": "boolean",
            "description": "True when the scan stopped at its bound rather than at the end of the caller's visible set. Visibility is decided per row after the query, so a page can under-fill; ask for the next offset rather than treating a short page as the end.\n"
          }
        }
      },
      "NotificationSummary": {
        "type": "object",
        "description": "Everything the nav badge and the app banner need, in one request: the two surfaces derive from (severity, lifecycle) rather than being chosen per kind, so one endpoint serves both.\n",
        "required": [
          "unreadCount",
          "openConditionCount",
          "banners"
        ],
        "properties": {
          "unreadCount": {
            "type": "integer",
            "description": "Unread events plus open conditions — so acknowledging a banner drops it to the badge rather than meaning \"forgotten\".\n"
          },
          "openConditionCount": {
            "description": "Conditions currently true and not yet resolved, acknowledged or not; a subset of what `unreadCount` counts.",
            "type": "integer"
          },
          "banners": {
            "type": "array",
            "description": "Open, unacknowledged CRITICAL conditions only, highest severity first. Never events (a banner is a claim about now, and an event cannot stop being true), and never more than the app should stack.\n",
            "items": {
              "$ref": "#/components/schemas/Notification"
            }
          }
        }
      },
      "OrganizationFeatures": {
        "type": "object",
        "description": "Organization-managed feature toggles. These are opt-in switches the organization decides for itself (org owner/admin), distinct from operator-managed entitlements.\n",
        "required": [
          "mcpRecordWritesEnabled",
          "mcpDestructiveSchemaEnabled",
          "captureEnabled",
          "importRuleProposerEnabled",
          "billingPaymentsEnabled",
          "publishedPagesEnabled",
          "warehouseExportEnabled",
          "warehouseExportAvailable",
          "calendarFeedsEnabled"
        ],
        "properties": {
          "calendarFeedsEnabled": {
            "type": "boolean",
            "description": "Whether members may create calendar feeds: secret addresses that publish a table's or view's records as a read-only calendar for Google Calendar, Outlook or Apple Calendar (docs/CALENDAR_FEEDS.md). On by default. Off, no feed can be created or have its link reset, and every existing feed's address answers 404; feeds are kept, so switching it back on restores them at the same addresses.\n"
          },
          "warehouseExportEnabled": {
            "type": "boolean",
            "description": "Whether the organization has switched warehouse export on: workspace admins may then send their workspace's records and stage history to an S3 bucket as Parquet files for Snowflake or another warehouse to load. Off by default. It takes effect only where warehouseExportAvailable is also true.\n"
          },
          "warehouseExportAvailable": {
            "type": "boolean",
            "readOnly": true,
            "description": "Whether the organization's plan includes warehouse export. READ-ONLY: the plan decides it, so it is absent from UpdateOrganizationFeaturesRequest. While it is false, switching warehouseExportEnabled on is stored but changes nothing until the plan includes the feature.\n"
          },
          "publishedPagesEnabled": {
            "type": "boolean",
            "description": "Whether members may publish static HTML pages (visualisations, models, presentations made in AI sessions) to their workspaces and share them by link (docs/PUBLISHED_PAGES.md). Off by default. A page's content is served sandboxed from a separate domain and never holds a credential; viewing one needs a sign-in as a member in its audience.\n"
          },
          "importRuleProposerEnabled": {
            "type": "boolean",
            "description": "Whether import analysis asks a language model to propose import rules for the columns it could only read as text (POST /imports/analyze). On by default wherever the deployment has a model key; each analysis is one model call metered against the organization's AI budget. Switching it off leaves imports whole — the analysis is simply the deterministic one.\n"
          },
          "captureEnabled": {
            "type": "boolean",
            "description": "Whether capture from image (photograph a business card, leaflet or sign into a record — POST /captures/extract) is offered in this organization's workspaces. On by default wherever the deployment has a model key; each read is still metered against the organization's AI budget and the workspace's daily capture quota.\n"
          },
          "mcpRecordWritesEnabled": {
            "type": "boolean",
            "description": "Whether connected MCP/AI clients get the record write tools (create_record / update_record) in this organization's workspaces. Off by default. Every write still runs under the individual user's own record permissions, validation, and audit logging — the flag only exposes the tools.\n"
          },
          "mcpDestructiveSchemaEnabled": {
            "type": "boolean",
            "description": "Whether connected MCP/AI clients get the tools that edit or delete EXISTING schema objects — fields, computed columns, constraints, stage rules, SQL views and saved queries — in this organization's workspaces. Off by default. Adding tables and fields (apply_schema_plan) is not behind this switch. Every change still requires the individual user's workspace admin role and is audit-logged — the flag only exposes the tools.\n"
          },
          "billingPaymentsEnabled": {
            "type": "boolean",
            "readOnly": true,
            "description": "Whether payment collection is active for this organization. READ-ONLY here: unlike mcpRecordWritesEnabled this is operator-managed and only an application administrator can change it, so it is absent from UpdateOrganizationFeaturesRequest. Exposed so the app can show or hide its billing surface from a server-provided fact rather than guessing. Off by default.\n"
          }
        }
      },
      "UpdateOrganizationFeaturesRequest": {
        "type": "object",
        "description": "The toggles to change; one or more. A toggle left out keeps its current value.",
        "minProperties": 1,
        "properties": {
          "mcpRecordWritesEnabled": {
            "description": "Whether connected MCP/AI clients get the record write tools (`create_record`, `update_record`) in this organization's workspaces. Writes still run under each user's own permissions.",
            "type": "boolean"
          },
          "mcpDestructiveSchemaEnabled": {
            "description": "Whether MCP/AI clients get the tools that edit or delete existing schema objects (fields, constraints, stage rules, views, saved queries). Adding tables and fields is not behind this switch.",
            "type": "boolean"
          },
          "captureEnabled": {
            "description": "Whether capture from image (`POST /captures/extract`) is offered in this organization's workspaces. Each read is still metered against the AI budget.",
            "type": "boolean"
          },
          "importRuleProposerEnabled": {
            "description": "Whether import analysis may ask a language model to propose import rules for columns it could only read as text. Off, the analysis is purely deterministic.",
            "type": "boolean"
          },
          "publishedPagesEnabled": {
            "description": "Whether members may publish static HTML pages to their workspaces and share them by link.",
            "type": "boolean"
          },
          "calendarFeedsEnabled": {
            "description": "Whether members may create calendar feeds, and whether existing feeds' addresses answer. Off keeps the feeds, so switching it back on restores them.",
            "type": "boolean"
          },
          "warehouseExportEnabled": {
            "description": "Whether workspace admins may send workspace data to a warehouse through S3. It takes effect only where the plan includes warehouse export (`warehouseExportAvailable`).",
            "type": "boolean"
          }
        }
      },
      "OrganizationSecurity": {
        "type": "object",
        "description": "Organization-managed security policy.",
        "required": [
          "requireMfa"
        ],
        "properties": {
          "requireMfa": {
            "type": "boolean",
            "description": "When true, every member must satisfy multi-factor authentication to obtain access tokens for this organization's workspaces or to call its organization endpoints. Enforced at token issuance and on org-scoped requests; existing access tokens age out within their 30-minute lifetime.\n"
          }
        }
      },
      "UpdateOrganizationSecurityRequest": {
        "description": "Request body of `PUT /organizations/{organizationId}/security`: the organization-wide security policy. Turning MFA on is refused unless the caller and every active owner already have a second factor.",
        "type": "object",
        "required": [
          "requireMfa"
        ],
        "properties": {
          "requireMfa": {
            "description": "Whether every member must have a second factor (verified TOTP/OTP or a registered passkey) to use the organization's workspaces. When true, workspace tokens are withheld from members without one until they enrol.",
            "type": "boolean"
          }
        }
      },
      "OrganizationSecurityBlockedResponse": {
        "type": "object",
        "description": "Returned (409) when require-MFA cannot be enabled: the caller and every active organization owner must be MFA-capable first (a verified second factor or a registered passkey), so the policy can never lock the organization's controllers out.\n",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "description": "Human-readable explanation to show the caller.",
            "type": "string"
          },
          "code": {
            "description": "Which precondition failed: `CALLER_MFA_REQUIRED` when the caller themselves has no verified second factor or passkey, `OWNERS_MFA_REQUIRED` when the caller is ready but one or more active owners are not (listed in `owners`).",
            "type": "string",
            "enum": [
              "CALLER_MFA_REQUIRED",
              "OWNERS_MFA_REQUIRED"
            ]
          },
          "owners": {
            "type": "array",
            "description": "Active owners not yet MFA-capable (OWNERS_MFA_REQUIRED)",
            "items": {
              "type": "object",
              "required": [
                "id",
                "name",
                "email"
              ],
              "properties": {
                "id": {
                  "description": "The owner's user id.",
                  "type": "string"
                },
                "name": {
                  "description": "The owner's display name, to show who still needs to enroll.",
                  "type": "string"
                },
                "email": {
                  "description": "The owner's email address, to reach them about enrolling.",
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "KnownUsageMeasureCategory": {
        "type": "string",
        "description": "The pricing axis a usage measure sits on — people (who can get in), footprint (what they store), activity (what they do). Grouping only; the server's measure catalog is the authority.\n",
        "enum": [
          "people",
          "footprint",
          "activity"
        ]
      },
      "OrganizationUsageMeasure": {
        "type": "object",
        "description": "One metered usage measure, for rendering usage tables.",
        "required": [
          "key",
          "label",
          "description",
          "unit",
          "kind",
          "category"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Measure key, e.g. db_storage_mb, ai_tokens"
          },
          "label": {
            "type": "string",
            "description": "Short human name for headers, e.g. \"Active users\""
          },
          "description": {
            "description": "One-sentence explanation of what the measure counts and how, for tooltips beside `label`.",
            "type": "string"
          },
          "unit": {
            "type": "string",
            "description": "Display unit, e.g. MB, tokens"
          },
          "kind": {
            "type": "string",
            "description": "gauge (point-in-time reading) or flow (accumulated over time)",
            "enum": [
              "gauge",
              "flow"
            ]
          },
          "category": {
            "type": "string",
            "description": "Pricing axis for grouping (people, footprint, activity). Clients tolerate unknown values.",
            "x-known-values": "KnownUsageMeasureCategory"
          }
        }
      },
      "OrganizationUsageValues": {
        "type": "object",
        "description": "Sparse per-measure numeric map keyed by measure key (missing key = 0).",
        "additionalProperties": {
          "type": "number"
        }
      },
      "OrganizationMonthlyUsage": {
        "type": "object",
        "description": "One calendar month's usage per measure (flows summed, gauges at their monthly peak).",
        "required": [
          "month",
          "values"
        ],
        "properties": {
          "month": {
            "type": "string",
            "description": "Calendar month, YYYY-MM (UTC)"
          },
          "values": {
            "$ref": "#/components/schemas/OrganizationUsageValues"
          }
        }
      },
      "BillingPaymentMethodSummary": {
        "type": "object",
        "description": "A stored card, described only well enough to recognise it. Never carries a full card number, a security code, or anything else that would put card data on this wire — the provider holds the card, we hold a reference.\n",
        "required": [
          "id",
          "isDefault"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the stored payment method, used to select or remove it through the billing endpoints. Opaque; it is not the provider's card token.",
            "type": "string"
          },
          "brand": {
            "type": [
              "string",
              "null"
            ],
            "description": "e.g. 'visa'. Null when the provider does not say."
          },
          "last4": {
            "description": "Final four digits of the card number, for display (\"•••• 4242\"). Null when the provider did not supply them.",
            "type": [
              "string",
              "null"
            ]
          },
          "expMonth": {
            "description": "Card expiry month, 1–12. Null when the provider did not supply it.",
            "type": [
              "integer",
              "null"
            ]
          },
          "expYear": {
            "description": "Card expiry year, four digits. Null when the provider did not supply it.",
            "type": [
              "integer",
              "null"
            ]
          },
          "isDefault": {
            "type": "boolean",
            "description": "Whether this is the method collection will charge."
          },
          "addedAt": {
            "description": "When the card was saved to the organization's billing account, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BillingSubscriptionSummary": {
        "description": "The organization's subscription lifecycle as carried on `BillingAccountResponse`: its status, the current billing period, and the trial, past-due and suspension timestamps a billing page shows.",
        "type": "object",
        "required": [
          "status",
          "currentPeriodStart",
          "currentPeriodEnd"
        ],
        "properties": {
          "status": {
            "type": "string",
            "x-known-values": "KnownSubscriptionStatus",
            "description": "Open by contract — clients MUST tolerate unknown values. 'past_due' means collection failed and a grace period is running; 'suspended' means that grace period expired and writes are now blocked (reads and exports still work).\n"
          },
          "currentPeriodStart": {
            "description": "Start of the billing period now running, ISO-8601 UTC. Billing periods are calendar months, so this is midnight UTC on the 1st of the current month — the same `periodStart` the invoice for this period will carry.",
            "type": "string",
            "format": "date-time"
          },
          "currentPeriodEnd": {
            "description": "End of the billing period now running, ISO-8601 UTC and exclusive: midnight UTC on the 1st of next month, which is when this period's invoice is issued (a £0 statement on a free plan). A plan change requested now takes effect here.",
            "type": "string",
            "format": "date-time"
          },
          "trialEndsAt": {
            "description": "When the free trial ends (or ended), ISO-8601 UTC. Null when the subscription has no trial.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "pastDueSince": {
            "description": "When payment collection first failed and the grace period began, ISO-8601 UTC. Null unless the subscription is past due or suspended.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "suspendedAt": {
            "description": "When the grace period expired and writes were blocked, ISO-8601 UTC. Null unless `status` is `suspended`.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "suspendsAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the grace period expires and writes will be blocked. Set only while past due and not yet suspended — the deadline is the single most useful thing to show someone whose payment has failed.\n"
          }
        }
      },
      "BillingPlanSummary": {
        "description": "A subscription tier as offered to the organization: its key, display name, base price in the organization's billing currency and the limits and allowances that come with it. Returned as the current plan in `BillingAccountResponse` and as each entry of `BillingPlansResponse`.",
        "type": "object",
        "required": [
          "id",
          "planKey",
          "displayName",
          "baseMonthlyPricePence",
          "currency"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the plan row, the value to send as `planId` when the organization changes plan. Stable; plans are seed data and are never deleted.",
            "type": "string"
          },
          "planKey": {
            "description": "Stable machine key of the tier — `free`, `standard` or `power` (`trial` exists but is granted on sign-up and never offered). Use it to key feature or copy decisions; `displayName` is for showing.",
            "type": "string"
          },
          "displayName": {
            "description": "Human-readable name of the tier as marketed, for display. May be reworded without the `planKey` changing.",
            "type": "string"
          },
          "baseMonthlyPricePence": {
            "description": "The tier's fixed monthly fee in minor units of `currency` (so 1999 is £19.99); 0 for a free tier. Metered overage is charged on top.",
            "type": "integer"
          },
          "currency": {
            "description": "ISO 4217 code (`GBP`, `EUR` or `USD`) the price is quoted in — the organization's billing currency, not a conversion of a sterling price.",
            "type": "string"
          },
          "maxUsers": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Null means unlimited."
          },
          "includedAllowances": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {
              "type": "integer"
            },
            "description": "Included quantity per usage measure before metered charges apply, as a sparse { measureKey: quantity } map.\n"
          }
        }
      },
      "BillingAccountResponse": {
        "type": "object",
        "description": "Everything the billing settings surface needs in one read: plan, subscription state, the card on file, and what is outstanding.\n",
        "required": [
          "organizationId",
          "currency",
          "paymentMethods",
          "outstandingInvoiceCount",
          "outstandingTotalPence"
        ],
        "properties": {
          "organizationId": {
            "description": "The organization this billing account belongs to; echoes the path parameter.",
            "type": "string"
          },
          "currency": {
            "description": "ISO 4217 code the organization is billed in. Amounts on this account, including `outstandingTotalPence`, are in this currency's minor unit.",
            "type": "string"
          },
          "billingEmail": {
            "description": "Address the payment provider sends receipts and payment notices to. Null when none has been recorded with the provider; the invoice recipients proper are `BillingProfileResponse.billingEmails`.",
            "type": [
              "string",
              "null"
            ]
          },
          "plan": {
            "$ref": "#/components/schemas/BillingPlanSummary"
          },
          "subscription": {
            "$ref": "#/components/schemas/BillingSubscriptionSummary"
          },
          "pendingPlanChange": {
            "$ref": "#/components/schemas/BillingPendingPlanChange"
          },
          "paymentMethods": {
            "description": "Cards on file with the payment provider; `isDefault` marks the one charged automatically. Empty when none has been added.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingPaymentMethodSummary"
            }
          },
          "outstandingInvoiceCount": {
            "description": "Number of issued invoices not yet fully paid.",
            "type": "integer"
          },
          "outstandingTotalPence": {
            "description": "Sum still owed across the outstanding invoices (each invoice's total less what has been paid), in the minor unit of `currency` — pence for GBP, cents for USD or EUR.",
            "type": "integer"
          },
          "providerMode": {
            "type": [
              "string",
              "null"
            ],
            "description": "'live' or 'mock' for the payment provider bound RIGHT NOW, not the one that created this billing account. Present so a non-production environment can say plainly that no real money is involved — which makes it a question about the current environment, so an environment promoted from the mock to real Stripe reports 'live' immediately rather than when some later write happens to refresh a stored row. Null when no provider is configured.\n"
          }
        }
      },
      "BillingPendingPlanChange": {
        "type": "object",
        "description": "A plan change the organization has chosen that has not started yet — a downgrade, or a move to a plan of the same price. Absent from `BillingAccountResponse` when nothing is scheduled. It takes effect at the start of the next billing period: the current period is billed, and its limits apply, on the current plan. Choosing the current plan again, or upgrading, cancels it.\n",
        "required": [
          "plan",
          "effectiveFrom"
        ],
        "properties": {
          "plan": {
            "$ref": "#/components/schemas/BillingPlanSummary"
          },
          "effectiveFrom": {
            "description": "When the new plan starts: the first instant (UTC) of the next billing period. Show it as the date the change happens.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BillingProfileResponse": {
        "type": "object",
        "description": "The organization's billing identity — the \"bill to\" party on every invoice — and the tax numbers it has registered with us.\nDistinct from the billing ACCOUNT (BillingAccountResponse), which is the relationship with the payment provider. A customer paying by bank transfer on terms has a profile and may never have an account.\n",
        "required": [
          "organizationId",
          "customerType",
          "currency",
          "collectionMethod",
          "paymentTermsDays",
          "billingEmails",
          "taxIds"
        ],
        "properties": {
          "organizationId": {
            "description": "The organization this billing profile belongs to; echoes the path parameter.",
            "type": "string"
          },
          "legalName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The name printed on the invoice. A company name, or a person's name for a sole trader or individual — do not assume it is a registered company.\n"
          },
          "addressLine1": {
            "description": "First line of the postal address printed on invoices as the bill-to address. Null until set.",
            "type": [
              "string",
              "null"
            ]
          },
          "addressLine2": {
            "description": "Second address line (building, suite, department), when the address needs one. Null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "city": {
            "description": "City or town of the bill-to address. Null until set.",
            "type": [
              "string",
              "null"
            ]
          },
          "region": {
            "description": "State, province or county of the bill-to address, where the country uses one. Null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "postcode": {
            "description": "Postal or ZIP code of the bill-to address. Null until set.",
            "type": [
              "string",
              "null"
            ]
          },
          "countryCode": {
            "type": [
              "string",
              "null"
            ],
            "description": "ISO 3166-1 alpha-2. For electronically supplied services the place of supply is the CUSTOMER's country, so this field — not the seller's — decides the VAT treatment and rate.\n"
          },
          "customerType": {
            "type": "string",
            "x-known-values": "KnownBillingCustomerType",
            "description": "Whether the customer is trading or is a private individual. Open by contract — clients MUST tolerate unknown values.\nNot the same question as \"do they have a VAT number\": a sole trader below the registration threshold is a business with no VAT number, and the EU B2B reverse charge requires both facts to be true.\n"
          },
          "currency": {
            "type": "string",
            "x-known-values": "KnownBillingCurrency",
            "description": "ISO 4217 code the organization's invoices are denominated in. Each currency has its own price list; amounts are never FX-converted.\n"
          },
          "collectionMethod": {
            "description": "How invoices are collected: charged automatically to the card on file, or sent for payment by bank transfer within `paymentTermsDays`. Values are enumerated by `KnownBillingCollectionMethod`; open by contract, so clients must tolerate unknown values.",
            "type": "string",
            "x-known-values": "KnownBillingCollectionMethod"
          },
          "paymentTermsDays": {
            "type": "integer",
            "description": "Net-N. 0 means due on issue, which is what auto_charge implies."
          },
          "poNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "Default purchase-order reference printed on every invoice. Many accounts-payable systems reject an invoice without a matching PO.\n"
          },
          "billingEmails": {
            "type": "array",
            "description": "Accounts-payable recipients. A list because AP is typically a shared mailbox plus a named person, and because the finance contact routinely differs from the organization owner.\n",
            "items": {
              "type": "string"
            }
          },
          "taxIds": {
            "description": "Tax registration numbers (VAT, GST, …) the organization has registered with us, printed on invoices and used to decide reverse-charge treatment. Replaced as a whole via `PUT .../billing/tax-ids`.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingTaxIdSummary"
            }
          }
        }
      },
      "BillingTaxIdSummary": {
        "type": "object",
        "description": "A tax identifier the customer has given us, and the issuing authority's verdict.",
        "required": [
          "countryCode",
          "taxNumber",
          "status"
        ],
        "properties": {
          "countryCode": {
            "type": "string",
            "description": "ISO 3166-1 alpha-2 of the issuing authority."
          },
          "taxNumber": {
            "type": "string",
            "description": "Stored normalised — upper-cased, punctuation stripped, country prefix removed."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownTaxIdStatus",
            "description": "'unavailable' is NOT a rejection: it means the national registry could not be reached, and the previously stored verdict still stands.\n"
          },
          "registeredName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The name the authority holds for the number, where it discloses one. A mismatch against legalName is worth a second look.\n"
          },
          "validatedAt": {
            "description": "When the issuing authority last returned a definite verdict (`valid` or `invalid`), ISO-8601 UTC. Null while the number is still `unvalidated`; an `unavailable` check does not move it, since an outage is not a verdict.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "nextCheckAt": {
            "description": "When the scheduled revalidation pass will check this number again, ISO-8601 UTC: about 90 days after a `valid` verdict, 30 days after `invalid`, 6 hours after an unreachable registry, and immediately for a newly stored number. Null is treated as due now.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "UpdateBillingProfileRequest": {
        "type": "object",
        "description": "Partial update — fields omitted keep their stored value, so a form that renders half the profile cannot blank the other half. An explicit null clears a field.\n",
        "properties": {
          "legalName": {
            "description": "The name printed on the invoice — a company, or a person for a sole trader or individual. Null clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "addressLine1": {
            "description": "First line of the billing address printed on invoices. Null clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "addressLine2": {
            "description": "Second line of the billing address. Null clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "city": {
            "description": "City or town of the billing address. Null clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "region": {
            "description": "State, county or province of the billing address. Null clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "postcode": {
            "description": "Postal code of the billing address. Null clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "countryCode": {
            "description": "ISO 3166-1 alpha-2 country of the customer, which decides the VAT treatment and rate. Null clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "customerType": {
            "description": "`business` for a trading customer (not the same as holding a VAT number), `individual` for a private person.",
            "type": "string",
            "enum": [
              "business",
              "individual"
            ]
          },
          "currency": {
            "description": "ISO 4217 currency invoices are denominated in; each has its own price list and amounts are never converted.",
            "type": "string",
            "enum": [
              "GBP",
              "EUR",
              "USD"
            ]
          },
          "collectionMethod": {
            "description": "`auto_charge` charges the stored payment method when an invoice issues; `send_invoice` emails the invoice for payment on terms.",
            "type": "string",
            "enum": [
              "auto_charge",
              "send_invoice"
            ]
          },
          "paymentTermsDays": {
            "description": "Net-N payment terms, 0–180 days; 0 means due on issue, which is what `auto_charge` implies.",
            "type": "integer",
            "minimum": 0,
            "maximum": 180
          },
          "poNumber": {
            "description": "Default purchase-order reference printed on every invoice. Null clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "billingEmails": {
            "description": "Replaces the accounts-payable recipients (up to 10). Null clears the list.",
            "type": [
              "array",
              "null"
            ],
            "maxItems": 10,
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SetBillingTaxIdRequest": {
        "description": "Request body of `PUT /organizations/{organizationId}/billing/tax-ids`: records the organization's VAT or tax registration for one country. The number is stored unvalidated and checked asynchronously; until it validates, tax is charged.",
        "type": "object",
        "required": [
          "countryCode",
          "taxNumber"
        ],
        "properties": {
          "countryCode": {
            "type": "string",
            "description": "ISO 3166-1 alpha-2 of the issuing authority."
          },
          "taxNumber": {
            "type": "string",
            "description": "Accepted with or without the country prefix, spaces and punctuation.\nValidation is asynchronous: the number is stored 'unvalidated' and a scheduled job checks it against VIES or HMRC. Until a check succeeds the number has no effect on what is charged, because 'unvalidated' charges VAT — the safe direction.\n"
          }
        }
      },
      "BillingPlansResponse": {
        "description": "Response of `GET /organizations/{organizationId}/billing/plans`: the plans the organization may move to and which of them it is on now. The `trial` plan is never offered here, because it is granted on creation and cannot be re-selected.",
        "type": "object",
        "required": [
          "plans"
        ],
        "properties": {
          "plans": {
            "description": "Active plans the organization may select, cheapest first by base monthly price. Never includes the `trial` plan.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingPlanSummary"
            }
          },
          "currentPlanId": {
            "description": "The `id` of the plan the organization is subscribed to now, so the UI can mark it; null when the organization has no subscription row. It may name a plan that is not in `plans` (for example the trial).",
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ChangeBillingPlanRequest": {
        "description": "Request body of `PUT /organizations/{organizationId}/billing/plan`: the plan the organization moves to at its next billing-period boundary.",
        "type": "object",
        "required": [
          "planId"
        ],
        "properties": {
          "planId": {
            "description": "Id of the plan to move to, one of the plans listed for the organization's currency. An unknown or unavailable plan is refused with 400.",
            "type": "string"
          }
        }
      },
      "StartPaymentMethodSetupRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/billing/payment-method-session`: where the payment provider's hosted capture page should send the browser back to afterwards.",
        "type": "object",
        "required": [
          "returnUrl",
          "cancelUrl"
        ],
        "properties": {
          "returnUrl": {
            "type": "string",
            "description": "Where the provider returns the browser after capture. Must be an absolute URL on this deployment's own frontend origin — an unvalidated value here would be an open redirect.\n"
          },
          "cancelUrl": {
            "type": "string",
            "description": "Where the provider returns the browser if the customer abandons."
          }
        }
      },
      "PaymentMethodSetupSession": {
        "description": "A provider-hosted session for capturing a payment method. Response of `POST /organizations/{organizationId}/billing/payment-method-session`; the client redirects the browser to `redirectUrl` and polls the billing resource afterwards.",
        "type": "object",
        "required": [
          "sessionId",
          "redirectUrl"
        ],
        "properties": {
          "sessionId": {
            "description": "The payment provider's identifier of the hosted session, for support and reconciliation; the browser flow needs only `redirectUrl`.",
            "type": "string"
          },
          "redirectUrl": {
            "type": "string",
            "description": "Send the browser here. Card details never touch this API."
          }
        }
      },
      "BillingInvoiceLineEntry": {
        "type": "object",
        "description": "One line of a bill. `kind` says what sort of charge it is; metered lines carry a measure and the used/included/billable quantity triple, which is what makes a £0 bill documentary rather than empty. `amountPence` may be negative (a discount or credit).\n",
        "required": [
          "id",
          "kind",
          "usedQty",
          "includedQty",
          "billableQty",
          "unitPricePence",
          "amountPence"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of this invoice line within the bill.",
            "type": "string"
          },
          "kind": {
            "type": "string",
            "x-known-values": "KnownChargeComponentKind",
            "description": "Open by contract — clients MUST tolerate unknown values."
          },
          "description": {
            "description": "Human-readable label of the charge as printed on the bill, for example `Pro — plan fee` or the metered measure's description. Null when the line was stored without one.",
            "type": [
              "string",
              "null"
            ]
          },
          "measureKey": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null on non-metered lines (fees, discounts, credits)."
          },
          "unit": {
            "description": "Display unit of the metered quantity, from the measure catalog (for example `records`, `GB`); null on non-metered lines (fees, discounts, credits).",
            "type": [
              "string",
              "null"
            ]
          },
          "usedQty": {
            "description": "Quantity consumed in the period, in `unit`. A fee line records `1`.",
            "type": "integer"
          },
          "includedQty": {
            "description": "How much of `usedQty` the plan's allowance absorbed at no charge. `0` on fee lines.",
            "type": "integer"
          },
          "billableQty": {
            "description": "The quantity actually charged: `usedQty` less `includedQty`, floored at zero. A fee line records `1`.",
            "type": "integer"
          },
          "unitPricePence": {
            "description": "Price per unit in the invoice currency's minor unit (pence, cents), rounded to a whole number. For a fee line it is the fee itself.",
            "type": "integer"
          },
          "amountPence": {
            "description": "Line total in the invoice currency's minor unit: `billableQty × unitPricePence`, rounded. Negative on a discount or credit line.",
            "type": "integer"
          }
        }
      },
      "BillingInvoiceSummary": {
        "description": "Header of one billing invoice for an organization: the period it covers, its collection status and the money involved, without line items. Item of the invoice list and the base of `BillingInvoiceDetail`; all amounts are integers in the minor unit of `currency`.",
        "type": "object",
        "required": [
          "id",
          "periodStart",
          "periodEnd",
          "status",
          "currency",
          "totalPence",
          "amountPaidPence"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the invoice, used in the invoice detail and pay endpoints. One invoice exists per organization and billing period.",
            "type": "string"
          },
          "periodStart": {
            "description": "First day of the usage period this invoice bills, as a UTC calendar date (inclusive).",
            "type": "string",
            "format": "date"
          },
          "periodEnd": {
            "description": "The day after the last day of the billed period, as a UTC calendar date — the period is half-open, [periodStart, periodEnd).",
            "type": "string",
            "format": "date"
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownInvoiceStatus",
            "description": "Open by contract — clients MUST tolerate unknown values."
          },
          "currency": {
            "description": "ISO 4217 code (`GBP`, `EUR` or `USD`) of the organization's billing currency; every `*Pence` amount on the invoice is in this currency's minor unit.",
            "type": "string"
          },
          "baseFeePence": {
            "description": "The subscription plan's base fee for the period, in minor units of `currency` — the roll-up of the `plan_fee` lines. Absent on an invoice with no plan fee.",
            "type": "integer"
          },
          "meteredSubtotalPence": {
            "description": "Total of all usage charges beyond the plan's included allowances, in minor units of `currency` — the roll-up of the `metered_overage` lines.",
            "type": "integer"
          },
          "totalPence": {
            "description": "Amount due for the invoice, in minor units of `currency`: the sum of every line. Zero-total invoices are never collected.",
            "type": "integer"
          },
          "amountPaidPence": {
            "description": "How much of `totalPence` has been settled so far, in minor units of `currency`. Equals the total once `status` is `paid`.",
            "type": "integer"
          },
          "dueAt": {
            "description": "When payment falls due and automatic collection first runs, ISO-8601 UTC. Null for a draft that has not been issued.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "paidAt": {
            "description": "When the invoice was settled in full, ISO-8601 UTC. Null until then.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "attemptCount": {
            "description": "Number of collection attempts made so far. Each failure increments it and moves the invoice to `payment_failed`; once the retry ladder is exhausted the invoice becomes `uncollectible` and `nextAttemptAt` is null.",
            "type": "integer"
          },
          "nextAttemptAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When collection will next be attempted. Null when nothing further is scheduled — because it is settled, or because the retry ladder is done and a person needs to act.\n"
          }
        }
      },
      "BillingInvoiceListResponse": {
        "description": "Response of `GET /organizations/{organizationId}/billing/invoices`: the organization's invoices, newest billing period first.",
        "type": "object",
        "required": [
          "invoices"
        ],
        "properties": {
          "invoices": {
            "description": "The organization's invoices, newest billing period first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingInvoiceSummary"
            }
          }
        }
      },
      "BillingPaymentAttemptEntry": {
        "description": "One charge attempt against an invoice, as listed in `BillingInvoiceDetail.attempts`; the collection ladder makes successive attempts until one settles, a hard decline stops it, or the attempt cap is reached.",
        "type": "object",
        "required": [
          "id",
          "attemptNumber",
          "status",
          "amountMinor",
          "currency",
          "attemptedAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of this attempt.",
            "type": "string"
          },
          "attemptNumber": {
            "description": "1-based position in the invoice's collection ladder; the ladder stops after the configured maximum.",
            "type": "integer"
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownPaymentAttemptStatus",
            "description": "Open by contract — clients MUST tolerate unknown values."
          },
          "amountMinor": {
            "description": "Amount charged, in the minor unit of `currency` (pence, cents), so 1250 GBP-minor is £12.50.",
            "type": "integer"
          },
          "currency": {
            "description": "ISO 4217 code of the amount; the invoice's currency.",
            "type": "string"
          },
          "declineCode": {
            "type": [
              "string",
              "null"
            ],
            "description": "The issuer's reason, e.g. 'insufficient_funds'. Determines whether the attempt is retried at all — a hard decline stops the ladder.\n"
          },
          "failureMessage": {
            "description": "Human-readable failure text from the payment provider or the charging code; null when the attempt did not fail.",
            "type": [
              "string",
              "null"
            ]
          },
          "attemptedAt": {
            "description": "When the charge was submitted, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "settledAt": {
            "description": "When the attempt reached a final outcome (succeeded, or failed with no retry pending), ISO-8601 UTC; null while it is still pending or processing.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "BillingInvoiceDetail": {
        "description": "One invoice in full: its summary, the itemized charge lines and every payment attempt made against it. Response of `GET /organizations/{organizationId}/billing/invoices/{invoiceId}`.",
        "type": "object",
        "required": [
          "invoice",
          "lines",
          "attempts"
        ],
        "properties": {
          "invoice": {
            "$ref": "#/components/schemas/BillingInvoiceSummary"
          },
          "lines": {
            "description": "The invoice's charge lines (plan fee, metered overage, discounts), in presentation order. Present even when the total is zero.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingInvoiceLineEntry"
            }
          },
          "attempts": {
            "description": "Every payment attempt made against the invoice, including failed and abandoned ones, so the collection history is visible.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BillingPaymentAttemptEntry"
            }
          }
        }
      },
      "PayInvoiceResponse": {
        "description": "Response of `POST /organizations/{organizationId}/billing/invoices/{invoiceId}/pay`: what the immediate collection attempt did, an optional provider detail, and the invoice as it stands afterwards.",
        "type": "object",
        "required": [
          "outcome",
          "invoice"
        ],
        "properties": {
          "outcome": {
            "type": "string",
            "description": "What the attempt did. 'paid' settled it; 'retry_scheduled' failed recoverably; 'uncollectible' exhausted the ladder or hit a hard decline; 'no_payment_method' means nothing is on file; 'paid_zero' means there was nothing to charge.\n"
          },
          "detail": {
            "description": "Provider-level detail behind `outcome` when there is one, such as the card's decline code or `awaiting settlement`; null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "invoice": {
            "$ref": "#/components/schemas/BillingInvoiceSummary"
          }
        }
      },
      "BillingWebhookAck": {
        "description": "Acknowledgement returned to the billing provider for a signed webhook delivery. Always a 200 once the signature verifies, whatever happened to the event, so the provider stops retrying; `outcome` says what was done with it.",
        "type": "object",
        "required": [
          "received"
        ],
        "properties": {
          "received": {
            "description": "Always `true`: the delivery was verified and recorded. Whether it changed anything is in `outcome`.",
            "type": "boolean"
          },
          "outcome": {
            "type": "string",
            "description": "'processed', 'ignored' (verified but not actionable), 'duplicate' (already seen — delivery is at-least-once), or 'failed' (recorded for a human; still acknowledged so the provider stops retrying).\n"
          }
        }
      },
      "OrganizationUsageResponse": {
        "type": "object",
        "description": "The organization's resource usage: a live current reading plus the persisted month-by-month history. Usage figures only — no pricing.\n",
        "required": [
          "organizationId",
          "measures",
          "current",
          "months"
        ],
        "properties": {
          "organizationId": {
            "description": "The organization whose usage is reported; echoes the path parameter.",
            "type": "string"
          },
          "measures": {
            "description": "The catalog of measures the figures are keyed by, with their labels, units and kinds. Render `current` and `months` through this list rather than hard-coding measure keys.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrganizationUsageMeasure"
            }
          },
          "current": {
            "allOf": [
              {
                "$ref": "#/components/schemas/OrganizationUsageValues"
              }
            ],
            "description": "Live reading: gauge measures as they stand right now, flow measures accumulated month-to-date (UTC) — consistent with the monthly rows.\n"
          },
          "months": {
            "type": "array",
            "description": "Monthly history, newest first. The current (partial) month's row is reconciled with the live `current` reading, so the two never disagree; completed months come from the persisted daily store.\n",
            "items": {
              "$ref": "#/components/schemas/OrganizationMonthlyUsage"
            }
          }
        }
      },
      "OrganizationMember": {
        "description": "One member of an organization, as listed by `GET /organizations/{organizationId}/members` and returned by the member update and reactivate endpoints. Organization membership is distinct from membership of the organization's workspaces.",
        "type": "object",
        "required": [
          "userId",
          "email",
          "name",
          "role",
          "isActive",
          "joinedAt"
        ],
        "properties": {
          "userId": {
            "description": "The member's user id, shared with their workspace memberships; the key for the update and reactivate endpoints.",
            "type": "string"
          },
          "email": {
            "description": "The member's sign-in email address.",
            "type": "string",
            "format": "email"
          },
          "name": {
            "description": "The member's display name, as shown in member lists.",
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/OrganizationRole"
          },
          "isActive": {
            "description": "False once the membership has been deactivated: the user can no longer act in the organization until reactivated. Deactivation also deactivated their workspace memberships, which reactivation does not restore.",
            "type": "boolean"
          },
          "joinedAt": {
            "description": "When the user became a member of the organization (accepted the invite or was added), ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "invitedById": {
            "description": "Id of the user who invited this member. Null when the membership did not come from an invitation (for example the founding owner).",
            "type": [
              "string",
              "null"
            ]
          },
          "invitedByName": {
            "description": "Display name of the inviter, resolved for convenience; null when `invitedById` is null or the inviter is no longer known.",
            "type": [
              "string",
              "null"
            ]
          },
          "deactivatedAt": {
            "description": "When the membership was deactivated, ISO-8601 UTC. Null while the member is active.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "UpdateOrganizationMemberRoleRequest": {
        "description": "Request body of `PATCH /organizations/{organizationId}/members/{userId}`: the organization role the member moves to. Only owners may grant owner or admin, and the last active owner cannot be demoted.",
        "type": "object",
        "required": [
          "role"
        ],
        "properties": {
          "role": {
            "$ref": "#/components/schemas/OrganizationRole"
          }
        }
      },
      "OrganizationInvite": {
        "description": "An invitation for an email address to join an organization with a given role and optional workspace grants. Returned by the organization's invite endpoints and by `GET /org-invites/pending` for the invitee; the shareable `token` appears only on create and resend.",
        "type": "object",
        "required": [
          "id",
          "organizationId",
          "email",
          "role",
          "invitedBy",
          "expiresAt",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Server-assigned identifier of the invitation; the `inviteId` the patch and resend endpoints take.",
            "type": "string"
          },
          "organizationId": {
            "description": "The organization the invitee is being asked to join.",
            "type": "string"
          },
          "organizationName": {
            "description": "Current display name of that organization, for showing the invitee what they are joining.",
            "type": "string"
          },
          "email": {
            "description": "The address the invitation was sent to. Accepting requires signing in with this address.",
            "type": "string",
            "format": "email"
          },
          "role": {
            "$ref": "#/components/schemas/OrganizationRole"
          },
          "workspaceGrants": {
            "type": "array",
            "description": "Workspace access applied when the invitation is accepted. Every workspace belongs to the inviting organization. Empty means the invitee joins the organization with no workspace access yet.",
            "items": {
              "$ref": "#/components/schemas/OrganizationInviteWorkspaceGrant"
            }
          },
          "invitedBy": {
            "description": "Id of the organization member who issued the invitation.",
            "type": "string"
          },
          "invitedByName": {
            "description": "Display name of the inviter at the time of the read, for the invitation email and pending-invites list.",
            "type": "string"
          },
          "token": {
            "type": "string",
            "description": "The shareable link token. Returned ONLY from the create and resend responses — it is stored hashed, so it cannot be shown again later. Use resend to issue a fresh link."
          },
          "expiresAt": {
            "description": "When the invitation stops being acceptable, ISO-8601 UTC: seven days after it was created or last resent. Expired invitations drop out of the lists.",
            "type": "string",
            "format": "date-time"
          },
          "acceptedAt": {
            "description": "When the invitee accepted, ISO-8601 UTC; null while the invitation is still open.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "description": "When the invitation was created, ISO-8601 UTC; set by the server.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OrganizationInviteWorkspaceGrant": {
        "description": "One workspace the invitee will be given access to, and with which role, when they accept an organization invitation. Item of `OrganizationInvite.workspaceGrants`.",
        "type": "object",
        "required": [
          "workspaceId",
          "role"
        ],
        "properties": {
          "workspaceId": {
            "description": "The workspace to grant membership of on acceptance. Must belong to the inviting organization; the invite is refused otherwise.",
            "type": "string"
          },
          "workspaceName": {
            "type": "string",
            "description": "Resolved for display; ignored on write."
          },
          "role": {
            "$ref": "#/components/schemas/WorkspaceRole"
          }
        }
      },
      "BulkOrganizationInviteRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/invites/bulk`: the people to invite, each with an organization role and optional workspace grants.",
        "type": "object",
        "required": [
          "invites"
        ],
        "additionalProperties": false,
        "properties": {
          "invites": {
            "type": "array",
            "minItems": 1,
            "maxItems": 500,
            "description": "The invitations to create, judged one by one. An address that appears twice is invited on its first entry; the later entry is reported as a repeat.",
            "items": {
              "$ref": "#/components/schemas/BulkOrganizationInviteItem"
            }
          }
        }
      },
      "BulkOrganizationInviteItem": {
        "description": "One person to invite, as an entry of `BulkOrganizationInviteRequest.invites`: the address, the organization role and the workspace access to grant on acceptance.",
        "type": "object",
        "required": [
          "email",
          "role"
        ],
        "additionalProperties": false,
        "properties": {
          "email": {
            "description": "Address the invitation is for. Accepting it joins that person with `role`.",
            "type": "string",
            "format": "email"
          },
          "role": {
            "$ref": "#/components/schemas/OrganizationRole"
          },
          "workspaceGrants": {
            "type": "array",
            "description": "Workspace memberships granted when this person accepts. Every workspace must belong to the organization. Omitted or empty, the person joins the organization alone.",
            "items": {
              "$ref": "#/components/schemas/OrganizationInviteWorkspaceGrantInput"
            }
          }
        }
      },
      "BulkOrganizationInviteResponse": {
        "description": "Response of `POST /organizations/{organizationId}/invites/bulk`: one result per request entry, in request order, plus the counts a caller reports.",
        "type": "object",
        "required": [
          "results",
          "invited",
          "skipped"
        ],
        "properties": {
          "results": {
            "type": "array",
            "description": "What became of each entry, in the order the request listed them.",
            "items": {
              "$ref": "#/components/schemas/BulkOrganizationInviteResult"
            }
          },
          "invited": {
            "type": "integer",
            "description": "How many entries became an invitation."
          },
          "skipped": {
            "type": "integer",
            "description": "How many entries made no invitation; each result's `reason` says why."
          }
        }
      },
      "BulkOrganizationInviteResult": {
        "description": "What became of one entry of a bulk invite request. `outcome` is `invited` when an invitation was created (`invite` carries it, token included); every other outcome says why none was, in `reason`.",
        "type": "object",
        "required": [
          "email",
          "outcome"
        ],
        "properties": {
          "email": {
            "description": "The entry's address, normalized to lower case.",
            "type": "string"
          },
          "outcome": {
            "description": "`invited`: an invitation was created. `already_member`: the address belongs to an active member of the organization — widen their workspace access instead. `already_invited`: a pending invitation for the address exists. `repeated`: an earlier entry of the same request already covered the address. `not_permitted`: the role is one the caller may not grant (owner/admin invites need the owner role).",
            "type": "string",
            "enum": [
              "invited",
              "already_member",
              "already_invited",
              "repeated",
              "not_permitted"
            ]
          },
          "reason": {
            "description": "A sentence saying why no invitation was made. Absent when `outcome` is `invited`.",
            "type": "string"
          },
          "invite": {
            "$ref": "#/components/schemas/OrganizationInvite"
          }
        }
      },
      "CreateOrganizationInviteRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/invites`: invite one person by email into the organization with an organization role, optionally granting workspace memberships that take effect when they accept.",
        "type": "object",
        "required": [
          "email",
          "role"
        ],
        "properties": {
          "email": {
            "description": "Address the invitation is emailed to. Accepting it joins that person to the organization with `role`.",
            "type": "string",
            "format": "email"
          },
          "role": {
            "$ref": "#/components/schemas/OrganizationRole"
          },
          "workspaceGrants": {
            "type": "array",
            "description": "Optional. Grant the invitee access to these workspaces on acceptance (one-step onboarding). Every workspace must belong to this organization.",
            "items": {
              "$ref": "#/components/schemas/OrganizationInviteWorkspaceGrantInput"
            }
          },
          "workspaceId": {
            "deprecated": true,
            "type": "string",
            "description": "Deprecated: use workspaceGrants. Single-workspace form, normalized into a one-element workspaceGrants list. Ignored when workspaceGrants is supplied."
          },
          "workspaceRole": {
            "deprecated": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/WorkspaceRole"
              }
            ],
            "description": "Deprecated: role for the deprecated workspaceId field."
          }
        }
      },
      "OrganizationInviteWorkspaceGrantInput": {
        "description": "One workspace membership to grant when an organization invitation is accepted, as sent in `workspaceGrants` of the create and update invite requests. The workspace must belong to the inviting organization.",
        "type": "object",
        "required": [
          "workspaceId",
          "role"
        ],
        "properties": {
          "workspaceId": {
            "description": "Id of a workspace belonging to the inviting organization that the invitee joins on acceptance.",
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/WorkspaceRole"
          }
        }
      },
      "UpdateOrganizationInviteRequest": {
        "type": "object",
        "description": "Fields to change on a pending invitation. Omitted fields are left as they are; supplying workspaceGrants replaces the whole set.",
        "properties": {
          "role": {
            "$ref": "#/components/schemas/OrganizationRole"
          },
          "workspaceGrants": {
            "description": "The complete new set of workspace memberships the invitee receives on acceptance; replaces the existing grants rather than merging with them.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrganizationInviteWorkspaceGrantInput"
            }
          }
        }
      },
      "AcceptOrganizationInviteResponse": {
        "description": "Confirmation that an organization invitation was accepted and the caller is now a member. Response of `POST /org-invites/{inviteId}/accept`.",
        "type": "object",
        "required": [
          "success",
          "membership"
        ],
        "properties": {
          "success": {
            "description": "Always `true` on a 200; failures are reported with an error status instead (403 email mismatch, 404 not found or expired).",
            "type": "boolean"
          },
          "membership": {
            "description": "The organization membership the acceptance created, so the client can switch into the organization without another fetch.",
            "type": "object",
            "properties": {
              "organizationId": {
                "description": "The organization the caller has just joined.",
                "type": "string"
              },
              "organizationName": {
                "description": "The organization's display name at acceptance time, for a confirmation message.",
                "type": "string"
              },
              "role": {
                "description": "The organization role granted, as set on the invitation (`owner`, `admin`, `billing` or `member`; see `OrganizationRole`).",
                "type": "string"
              }
            }
          }
        }
      },
      "OrganizationWorkspace": {
        "description": "A workspace as seen from its organization's console: identity, environment, size and the caller's own standing in it. Item of `GET /organizations/{organizationId}/workspaces`; also returned by the create and update endpoints.",
        "type": "object",
        "required": [
          "id",
          "name",
          "createdAt",
          "memberCount",
          "isMember",
          "deletable",
          "environment"
        ],
        "properties": {
          "environment": {
            "$ref": "#/components/schemas/WorkspaceEnvironment"
          },
          "id": {
            "description": "Stable identifier of the workspace; what workspace access tokens and the `workspaceId` path parameters refer to.",
            "type": "string"
          },
          "name": {
            "description": "The workspace's display name, editable via PATCH.",
            "type": "string"
          },
          "createdAt": {
            "description": "When the workspace was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "memberCount": {
            "type": "integer",
            "description": "Number of active workspace members"
          },
          "isMember": {
            "type": "boolean",
            "description": "Whether the current user is an active member of this workspace"
          },
          "myRole": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/WorkspaceRole"
              },
              {
                "type": "null"
              }
            ],
            "description": "Current user's workspace role, if a member"
          },
          "deletable": {
            "type": "boolean",
            "description": "Whether this workspace may be hard-deleted through the two-step delete flow. Toggled by org owners/admins; non-deletable workspaces refuse the delete endpoints outright."
          }
        }
      },
      "CreateOrganizationWorkspaceRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/workspaces`: the new workspace's name plus two creation-time switches, whether it may later be hard-deleted and whether it is a sandbox.",
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "description": "Display name of the new workspace, as shown in the workspace switcher. Required and non-empty; it can be renamed later with PATCH.",
            "type": "string"
          },
          "deletable": {
            "type": "boolean",
            "default": false,
            "description": "Mark the new workspace as deletable (hard-deletable via the two-step delete flow — intended for demo/test workspaces). Defaults to false; org owners/admins can toggle it later."
          },
          "environment": {
            "$ref": "#/components/schemas/WorkspaceEnvironment",
            "description": "`production` when omitted. `sandbox` can only be chosen here: the flag is immutable after creation (see WorkspaceEnvironment)."
          }
        }
      },
      "UpdateOrganizationWorkspaceRequest": {
        "type": "object",
        "description": "At least one property must be provided.",
        "properties": {
          "name": {
            "description": "New display name of the workspace.",
            "type": "string"
          },
          "deletable": {
            "type": "boolean",
            "description": "Toggle whether the workspace may be hard-deleted through the two-step delete flow. Reversible; org owner/admin only (same gate as the rest of this surface)."
          }
        }
      },
      "WorkspaceDeleteRequestResponse": {
        "description": "Response of `POST /organizations/{organizationId}/workspaces/{workspaceId}/delete-request`, step one of the two-step hard delete: the one-time confirmation token the delete call must present, and when it stops being accepted.",
        "type": "object",
        "required": [
          "confirmationToken",
          "expiresAt"
        ],
        "properties": {
          "confirmationToken": {
            "type": "string",
            "description": "One-time confirmation token for the delete endpoint. Only the most recent request per workspace is honoured — issuing a new one invalidates the previous token."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the confirmation token stops being accepted."
          }
        }
      },
      "ConfirmWorkspaceDeleteRequest": {
        "description": "Second step of deleting a workspace: proves the caller holds the token the delete-request step issued and has retyped the workspace's name. Request body of `POST /organizations/{organizationId}/workspaces/{workspaceId}/delete`.",
        "type": "object",
        "required": [
          "confirmationToken",
          "name"
        ],
        "properties": {
          "confirmationToken": {
            "type": "string",
            "description": "Token returned by the delete-request endpoint."
          },
          "name": {
            "type": "string",
            "description": "The workspace's exact current name, retyped as an explicit confirmation of what is being destroyed."
          }
        }
      },
      "KnownStageCategory": {
        "description": "The lifecycle meaning of a stage value this version knows, referenced via `x-known-values`. `open` — still in flight (the default); `terminal_success` — a successful end state; `terminal_failure` — an unsuccessful end state. Reporting semantics only: a terminal value never blocks a write. Open vocabulary; unknown categories read as `open`.",
        "type": "string",
        "enum": [
          "open",
          "terminal_success",
          "terminal_failure"
        ]
      },
      "KnownStageClock": {
        "description": "Whether time a record spends in a stage value counts toward `<stageField>.activeSeconds`: `running` (the default) burns the clock, `paused` does not — for waiting states that are someone else's delay. Known values of an open vocabulary; an absent or unknown value reads as `running`.",
        "type": "string",
        "enum": [
          "running",
          "paused"
        ]
      },
      "KnownStageSourceKind": {
        "description": "Values of a stage machine's `sourceKind` known to this version: `picklist` the stage value is a stored option-list field, `computed` it is read from a formula-derived column (the shape is reserved; computed sources are not accepted yet). Open by contract.",
        "type": "string",
        "enum": [
          "picklist",
          "computed"
        ]
      },
      "KnownIntegrationProvider": {
        "description": "The email-marketing providers an integration connection can be made to in this version (`klaviyo`, `mailchimp`, `omnisend`), referenced by `x-known-values` on `provider` fields. Open vocabulary: clients tolerate a provider not listed here and treat an unrecognised one as unusable.",
        "type": "string",
        "enum": [
          "klaviyo",
          "mailchimp",
          "omnisend"
        ]
      },
      "KnownWorkspacePersonStatus": {
        "description": "The states of a person a workspace's data can refer to, as this build knows them (open vocabulary; tolerate a value not listed): `active` — a current member, the one state a picker offers; `inactive` — a former member, whose id stays on everything they owned, created or changed and still resolves to their name; `pending` — imported before they joined, resolving to the imported name until they join. Carried as the `status` key of a `users` system-entity item (`GET /system-entities/{entityId}/items`) and as the `status` column of the `sys_users` view.",
        "type": "string",
        "enum": [
          "pending",
          "active",
          "inactive"
        ]
      },
      "KnownIntegrationConnectionStatus": {
        "description": "Health of an integration connection's credential, as known to this build (open vocabulary): `unverified` — stored but not yet probed (every new or rotated credential starts here), `ok` — the last probe succeeded, `error` — the last probe failed.",
        "type": "string",
        "enum": [
          "unverified",
          "ok",
          "error"
        ]
      },
      "KnownAudienceSyncRunStatus": {
        "description": "Values of an audience sync run's status known to this version (`AudienceSync.lastRunStatus`): `queued` waiting for a worker, `running` in progress, `completed` finished successfully, `failed` ended with an error, `cancelled` stopped before finishing. Open vocabulary — tolerate values not listed.",
        "type": "string",
        "enum": [
          "queued",
          "running",
          "completed",
          "failed",
          "cancelled"
        ]
      },
      "KnownTransitionPolicy": {
        "description": "Stage-field transition policies known to this build: `any` means a record may move between any active values, `matrix` means the configured `transitions` map is an explicit allow-list and every unlisted move is denied. Referenced by `x-known-values` on the stage config's `transitionPolicy`; the wire field is open, and a policy the server itself does not recognise blocks every transition rather than allowing them.",
        "type": "string",
        "enum": [
          "any",
          "matrix"
        ]
      },
      "KnownWorkspaceBackupStatus": {
        "description": "The workspace-backup statuses this version knows, named by `WorkspaceBackup.status` through `x-known-values`. `pending`: queued; `running`: being written; `completed`: restorable; `failed`: did not complete and holds no usable archive; `deleting`: a delete was requested and the archive is being removed. Open string on the wire: tolerate values not listed.",
        "type": "string",
        "enum": [
          "pending",
          "running",
          "completed",
          "failed",
          "deleting"
        ]
      },
      "KnownBackupRestoreJobStatus": {
        "description": "The lifecycle states of a backup restore job this version knows, referenced via `x-known-values`. `queued` — waiting for a worker; `running` — in progress; `completed` — the new workspace is ready; `failed` — stopped with an error; `cancelled` — abandoned before completion. Open vocabulary; clients must tolerate unknown values.",
        "type": "string",
        "enum": [
          "queued",
          "running",
          "completed",
          "failed",
          "cancelled"
        ]
      },
      "KnownBackupJobPhase": {
        "description": "The phases a backup or restore job (`BackupJob.phase`) passes through, in order: backup phases first (`pending`, `meta`, `tables`, `saved`, `attachments`, `finalize`), then restore phases (`validate`, `provision`, `schema`, `rows`, `referenceFields`, `referenceBackfill`, `restoreSaved`, `restoreMeta`, `restoreAttachments`, `restoreFinalize`, `archive`). Known values of an open vocabulary — the field is a plain string on the wire and clients must tolerate phases not listed here.",
        "type": "string",
        "enum": [
          "pending",
          "meta",
          "tables",
          "saved",
          "attachments",
          "finalize",
          "validate",
          "provision",
          "schema",
          "rows",
          "referenceFields",
          "referenceBackfill",
          "restoreSaved",
          "restoreMeta",
          "restoreAttachments",
          "restoreFinalize",
          "archive"
        ]
      },
      "KnownBackupDownloadStatus": {
        "description": "Values of `BackupDownload.status` known to this version: `none` no archive is packaged (never requested, or the previous one expired), `preparing` packaging is queued or running, `ready` the archive exists and `downloadUrl` is set, `failed` packaging failed and can be requested again. Open by contract — clients must tolerate values not listed here.",
        "type": "string",
        "enum": [
          "none",
          "preparing",
          "ready",
          "failed"
        ]
      },
      "KnownHostedSiteDeploymentStatus": {
        "description": "The hosted-site deployment statuses known to this version, referenced by `x-known-values` on `HostedSiteDeployment.status`: `uploading` (files may still be arriving), `ready` (verified complete, not live), `active` (the one the site serves). Open vocabulary: clients tolerate values not listed here.",
        "type": "string",
        "enum": [
          "uploading",
          "ready",
          "active"
        ]
      },
      "KnownHostedSiteDomainStatus": {
        "description": "The custom-domain statuses known to this version, referenced by `x-known-values` on `HostedSiteDomain.status`: `pending` (waiting for the CNAME to resolve and the certificate to issue), `active` (the site answers on the hostname), `failed` (the certificate could not be issued or renewed, or the CNAME went away; `detail` says which), `removed` (the hostname is no longer served but stays reserved to the workspace; never listed to the workspace, only to operators). Open vocabulary: clients tolerate values not listed here.",
        "type": "string",
        "enum": [
          "pending",
          "active",
          "failed",
          "removed"
        ]
      },
      "KnownFlowTriggerKind": {
        "description": "The ways a flow can start, as known to this build (open vocabulary — tolerate others): `record_event` fires on a record lifecycle event on one table; `schedule` fires on a cron cadence; `inbound_webhook` fires when a request hits the flow's hook path with its token; `record_action` fires only when a user presses the flow's run button on a record.",
        "type": "string",
        "enum": [
          "record_event",
          "schedule",
          "inbound_webhook",
          "record_action"
        ]
      },
      "KnownFlowRunAsMode": {
        "description": "Values of a flow's `runAsMode` known to this version. `initiating_user`: each run acts with the permissions of the user whose action triggered it, resolved at execution time (so schedule triggers, which have no such user, are refused). `automation_identity`: runs act as the flow's own principal, with whatever roles were granted to the flow. Open vocabulary — tolerate values not listed.",
        "type": "string",
        "enum": [
          "initiating_user",
          "automation_identity"
        ]
      },
      "MirrorConnection": {
        "description": "An inbound connection: an external system mirrored tables are kept in step with. The credential is write-only.",
        "type": "object",
        "required": [
          "id",
          "kind",
          "name",
          "status",
          "sourceIdentity",
          "lastError",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The connection's id; the `connectionId` the object listing and `POST /mirrors` take."
          },
          "kind": {
            "type": "string",
            "description": "The kind of source, such as `salesforce`. An open string: clients must tolerate a kind they do not know."
          },
          "name": {
            "type": "string",
            "description": "The workspace's name for the connection, unique in the workspace."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownIntegrationConnectionStatus",
            "description": "Whether the source accepted the credential when last tried (`ok`, `error`, `unverified`). An open string: render one you do not know as neutral."
          },
          "sourceIdentity": {
            "type": [
              "string",
              "null"
            ],
            "description": "The source's own identity, pinned at connect, such as a Salesforce org id."
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the source last refused the connection, in words; null when it did not."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the connection was made."
          }
        }
      },
      "CreateMirrorConnectionRequest": {
        "description": "An external system to connect, with its credential.",
        "type": "object",
        "required": [
          "name",
          "kind",
          "salesforce"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "A name for the connection, unique in the workspace."
          },
          "kind": {
            "type": "string",
            "enum": [
              "salesforce"
            ],
            "description": "The kind of source. Only Salesforce can be connected."
          },
          "salesforce": {
            "$ref": "#/components/schemas/SalesforceConnectionCredential"
          }
        }
      },
      "SalesforceConnectionCredential": {
        "description": "A Salesforce org's External Client App, signed in to with the OAuth 2.0 client credentials flow. The app's \"Run As\" user should be a Salesforce Integration user whose permission set grants Read and View All on exactly the objects to mirror: Salesforce then enforces what leaves the org.",
        "type": "object",
        "required": [
          "myDomain",
          "clientId",
          "clientSecret"
        ],
        "properties": {
          "myDomain": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "The org's My Domain host or URL, such as `acme.my.salesforce.com`."
          },
          "clientId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "description": "The External Client App's consumer key."
          },
          "clientSecret": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "description": "The External Client App's consumer secret. Stored encrypted and never returned."
          }
        }
      },
      "MirrorSourceObject": {
        "description": "A source object a connection can mirror.",
        "type": "object",
        "required": [
          "object",
          "label"
        ],
        "properties": {
          "object": {
            "type": "string",
            "description": "The source's name for the object, such as `Account`; what `POST /mirrors` takes as `sourceObject`."
          },
          "label": {
            "type": "string",
            "description": "The object's label, for display."
          }
        }
      },
      "MirrorSourceObjectDescription": {
        "description": "A source object's fields as a mirror would carry them.",
        "type": "object",
        "required": [
          "object",
          "keyField",
          "labelField",
          "fields",
          "unsupported"
        ],
        "properties": {
          "object": {
            "type": "string",
            "description": "The source's name for the object."
          },
          "keyField": {
            "type": [
              "string",
              "null"
            ],
            "description": "The field holding each record's key at the source (Salesforce's `Id`). A mirror always carries it, as the table's `source_id`."
          },
          "labelField": {
            "type": [
              "string",
              "null"
            ],
            "description": "The field that names a record, which becomes the table's label; null when it has none a mirror can carry."
          },
          "fields": {
            "type": "array",
            "description": "The fields a mirror can carry, in the source's order.",
            "items": {
              "$ref": "#/components/schemas/MirrorSourceField"
            }
          },
          "unsupported": {
            "type": "array",
            "description": "The fields a mirror cannot carry, each with why.",
            "items": {
              "$ref": "#/components/schemas/MirrorUnsupportedField"
            }
          }
        }
      },
      "MirrorSourceField": {
        "description": "One source field and the kind of value it holds.",
        "type": "object",
        "required": [
          "path",
          "label",
          "type"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "The source's name for the field, such as `Industry`; what `POST /mirrors` takes in `fields`."
          },
          "label": {
            "type": "string",
            "description": "The field's label, for display."
          },
          "type": {
            "type": "string",
            "x-known-values": "KnownMirrorFieldType",
            "description": "The kind of value, which decides the table field's type. An open string: clients must tolerate a type not listed in KnownMirrorFieldType."
          },
          "options": {
            "type": "array",
            "description": "A picklist's options, as the source lists them.",
            "items": {
              "type": "string"
            }
          },
          "targets": {
            "type": "array",
            "description": "The source objects a reference may point at; more than one is polymorphic.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "MirrorUnsupportedField": {
        "description": "A source field a mirror cannot carry.",
        "type": "object",
        "required": [
          "path",
          "label",
          "reason"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "The source's name for the field."
          },
          "label": {
            "type": "string",
            "description": "The field's label, for display."
          },
          "reason": {
            "type": "string",
            "description": "Why it cannot be mirrored, in words."
          }
        }
      },
      "KnownMirrorFieldType": {
        "description": "The source field types this build knows (`MirrorSourceField.type`); an open string on the wire.",
        "type": "string",
        "enum": [
          "text",
          "longText",
          "number",
          "currency",
          "boolean",
          "date",
          "datetime",
          "email",
          "phone",
          "url",
          "picklist",
          "multiPicklist",
          "reference",
          "file",
          "json"
        ]
      },
      "CreateMirrorRequest": {
        "description": "A source object to mirror, and which of its fields.",
        "type": "object",
        "required": [
          "connectionId",
          "sourceObject",
          "displayName",
          "fields"
        ],
        "properties": {
          "connectionId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "The inbound connection to read through."
          },
          "sourceObject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
            "description": "The source object, as the object listing names it."
          },
          "displayName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "The new table's display name."
          },
          "fields": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "uniqueItems": true,
            "description": "The source fields to mirror, by path, as the object description lists them.",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            }
          }
        }
      },
      "CreatedMirror": {
        "description": "A mirror just created, with its table.",
        "type": "object",
        "required": [
          "mirror",
          "tableId",
          "fields",
          "skipped"
        ],
        "properties": {
          "mirror": {
            "$ref": "#/components/schemas/MirrorSummary"
          },
          "tableId": {
            "type": "string",
            "description": "The table the mirror created and fills."
          },
          "fields": {
            "type": "array",
            "description": "Each mirrored source field and the table field it became.",
            "items": {
              "$ref": "#/components/schemas/CreatedMirrorField"
            }
          },
          "skipped": {
            "type": "array",
            "description": "Chosen fields that were not created, each with why.",
            "items": {
              "$ref": "#/components/schemas/MirrorUnsupportedField"
            }
          }
        }
      },
      "CreatedMirrorField": {
        "description": "A source field and the table field that mirrors it.",
        "type": "object",
        "required": [
          "path",
          "fieldId",
          "fieldName"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "The source field."
          },
          "fieldId": {
            "type": "string",
            "description": "The table field's id."
          },
          "fieldName": {
            "type": "string",
            "description": "The table field's name."
          }
        }
      },
      "MirrorFields": {
        "description": "A mirror's fields, and the source fields it could add.",
        "type": "object",
        "required": [
          "sourceObject",
          "mapped",
          "available",
          "unsupported"
        ],
        "properties": {
          "sourceObject": {
            "type": "string",
            "description": "The source object the mirror follows."
          },
          "mapped": {
            "type": "array",
            "description": "The table fields the mirror writes, in the table's order.",
            "items": {
              "$ref": "#/components/schemas/MirroredField"
            }
          },
          "available": {
            "type": "array",
            "description": "Source fields the mirror does not carry yet; one with a `blockedReason` cannot be added yet.",
            "items": {
              "$ref": "#/components/schemas/MirrorAvailableField"
            }
          },
          "unsupported": {
            "type": "array",
            "description": "Source fields no mirror can carry, each with why.",
            "items": {
              "$ref": "#/components/schemas/MirrorUnsupportedField"
            }
          }
        }
      },
      "MirroredField": {
        "description": "A table field a mirror writes, and the source field it comes from.",
        "type": "object",
        "required": [
          "fieldId",
          "fieldName",
          "displayName",
          "sourcePath",
          "type",
          "drift",
          "isKey"
        ],
        "properties": {
          "fieldId": {
            "type": "string",
            "description": "The table field; what `DELETE /mirrors/{mirrorId}/fields/{fieldId}` takes."
          },
          "fieldName": {
            "type": "string",
            "description": "The table field's name."
          },
          "displayName": {
            "type": "string",
            "description": "The table field's display name."
          },
          "sourcePath": {
            "type": "string",
            "description": "The source field it mirrors."
          },
          "type": {
            "type": "string",
            "x-known-values": "KnownMirrorFieldType",
            "description": "The kind of value the source field held when it was mapped. An open string: clients must tolerate a type not listed in KnownMirrorFieldType."
          },
          "drift": {
            "type": "string",
            "x-known-values": "KnownMirrorFieldDrift",
            "description": "Whether the source field still matches (`ok`), was removed (`removed`), or changed type (`retyped`). A drifted field keeps its data and is no longer written. An open string: clients must tolerate a value not listed in KnownMirrorFieldDrift and treat it as drifted."
          },
          "isKey": {
            "type": "boolean",
            "description": "True for the source key (`source_id`), which stays mirrored while the table is."
          }
        }
      },
      "MirrorAvailableField": {
        "description": "A source field a mirror could add.",
        "type": "object",
        "required": [
          "path",
          "label",
          "type"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "The source's name for the field; what `POST /mirrors/{mirrorId}/fields` takes."
          },
          "label": {
            "type": "string",
            "description": "The field's label, for display."
          },
          "type": {
            "type": "string",
            "x-known-values": "KnownMirrorFieldType",
            "description": "The kind of value. An open string: clients must tolerate a type not listed in KnownMirrorFieldType."
          },
          "options": {
            "type": "array",
            "description": "A picklist's options, as the source lists them.",
            "items": {
              "type": "string"
            }
          },
          "targets": {
            "type": "array",
            "description": "The source objects a reference may point at.",
            "items": {
              "type": "string"
            }
          },
          "blockedReason": {
            "type": "string",
            "description": "Why the field cannot be added yet, such as a reference to an object not mirrored; absent when it can."
          }
        }
      },
      "MapMirrorFieldsRequest": {
        "description": "Source fields to add to a mirror.",
        "type": "object",
        "required": [
          "fields"
        ],
        "properties": {
          "fields": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "uniqueItems": true,
            "description": "The source fields to add, by path, as the field listing names them.",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            }
          }
        }
      },
      "KnownMirrorFieldDrift": {
        "description": "The drift states this build knows (`MirroredField.drift`); an open string on the wire.",
        "type": "string",
        "enum": [
          "ok",
          "removed",
          "retyped"
        ]
      },
      "MirrorStatus": {
        "description": "A mirror with what the status page shows about its sync.",
        "allOf": [
          {
            "$ref": "#/components/schemas/MirrorSummary"
          },
          {
            "type": "object",
            "required": [
              "tableId",
              "tableName",
              "lagSeconds",
              "lastError",
              "openIssues",
              "driftedFields",
              "lastRun",
              "nextReconcileAt"
            ],
            "properties": {
              "tableId": {
                "type": "string",
                "description": "The mirrored table."
              },
              "tableName": {
                "type": "string",
                "description": "The mirrored table's display name."
              },
              "lagSeconds": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Seconds since the sync last completed; null before the first completes."
              },
              "lastError": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Why the last sync failed, if it did; null once a sync succeeds."
              },
              "openIssues": {
                "type": "integer",
                "description": "How many sync problems are open (see the issues list)."
              },
              "driftedFields": {
                "type": "integer",
                "description": "How many mirrored fields no longer match their source field (removed or retyped there); each keeps its data and is no longer written until it is let go or remapped."
              },
              "lastRun": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/MirrorRunSummary"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The most recent sync run, or null before the first."
              },
              "nextReconcileAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time",
                "description": "When the next full comparison with the source is due."
              }
            }
          }
        ]
      },
      "MirrorRunSummary": {
        "description": "One sync run.",
        "type": "object",
        "required": [
          "kind",
          "status",
          "counts",
          "finishedAt"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "x-known-values": "KnownMirrorRunKind",
            "description": "What the run did (`initial`, `incremental`, `reconcile`, `push`). An open string: clients must tolerate a kind not listed in KnownMirrorRunKind."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownMirrorRunStatus",
            "description": "How it ended (`running`, `succeeded`, `failed`). An open string: clients must tolerate a status not listed in KnownMirrorRunStatus."
          },
          "counts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            },
            "description": "Records created, updated, deleted, restored, left unchanged, and fields skipped."
          },
          "finishedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the run finished; null while it runs."
          }
        }
      },
      "MirrorIssue": {
        "description": "A sync problem a person should see.",
        "type": "object",
        "required": [
          "id",
          "kind",
          "sourceKey",
          "fieldName",
          "detail",
          "firstSeenAt",
          "lastSeenAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The issue's id."
          },
          "kind": {
            "type": "string",
            "x-known-values": "KnownMirrorIssueKind",
            "description": "What went wrong (`value_rejected`, `reference_unresolved`, `file_too_large`, `file_failed`, `drift`). An open string: clients must tolerate a kind not listed in KnownMirrorIssueKind."
          },
          "sourceKey": {
            "type": "string",
            "description": "The source record's key; empty for an issue about the whole field."
          },
          "fieldName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The field concerned, when there is one."
          },
          "detail": {
            "type": "string",
            "description": "What happened, in words."
          },
          "firstSeenAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the sync first met the problem."
          },
          "lastSeenAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the sync last met it."
          }
        }
      },
      "MirrorIssuePage": {
        "description": "A page of open sync problems.",
        "type": "object",
        "required": [
          "items",
          "total"
        ],
        "properties": {
          "items": {
            "type": "array",
            "description": "The issues on this page, newest first.",
            "items": {
              "$ref": "#/components/schemas/MirrorIssue"
            }
          },
          "total": {
            "type": "integer",
            "description": "How many issues are open in all."
          }
        }
      },
      "KnownMirrorRunKind": {
        "description": "The sync run kinds this build knows (`MirrorRunSummary.kind`); an open string on the wire.",
        "type": "string",
        "enum": [
          "initial",
          "incremental",
          "reconcile",
          "push"
        ]
      },
      "KnownMirrorRunStatus": {
        "description": "The sync run statuses this build knows (`MirrorRunSummary.status`); an open string on the wire.",
        "type": "string",
        "enum": [
          "running",
          "succeeded",
          "failed"
        ]
      },
      "KnownMirrorIssueKind": {
        "description": "The sync problem kinds this build knows (`MirrorIssue.kind`); an open string on the wire.",
        "type": "string",
        "enum": [
          "value_rejected",
          "row_rejected",
          "reference_unresolved",
          "file_too_large",
          "file_failed",
          "drift"
        ]
      },
      "MirrorPushResult": {
        "description": "What a push queued.",
        "type": "object",
        "required": [
          "queued"
        ],
        "properties": {
          "queued": {
            "type": "integer",
            "description": "How many batches of changes were queued for the next sync cycle."
          }
        }
      },
      "MirrorSummary": {
        "description": "A table's binding to an external source: which source object feeds it, through which connection, and where its sync stands. Detaching it (`POST /tables/{tableId}/mirror/detach`) makes the table an ordinary Tessule table for good.",
        "type": "object",
        "required": [
          "id",
          "state",
          "sourceObject",
          "sourceKind",
          "connectionName",
          "lastSuccessAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The mirror's id."
          },
          "state": {
            "type": "string",
            "x-known-values": "KnownMirrorState",
            "description": "Where the mirror stands: `initialising` (first load running), `mirrored` (syncing), `paused` (not syncing, still locked) or `detached` (the lock is lifted for good). An open string: clients must tolerate a state not listed in KnownMirrorState and treat it as locked."
          },
          "sourceObject": {
            "type": "string",
            "description": "The source's own name for the collection feeding the table, such as a Salesforce object name."
          },
          "sourceKind": {
            "type": [
              "string",
              "null"
            ],
            "description": "The kind of source (for example `salesforce`), for display. Null when the connection has been removed."
          },
          "connectionName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The name of the connection the table syncs through, for display. Null when it has been removed."
          },
          "lastSuccessAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the sync last completed. Null before the first sync completes."
          }
        }
      },
      "KnownMirrorState": {
        "description": "The mirror states this build knows (`MirrorSummary.state`). The wire field is an open string; clients must treat a state not listed here as locked.",
        "type": "string",
        "enum": [
          "initialising",
          "mirrored",
          "paused",
          "detached"
        ]
      },
      "KnownFlowVersionState": {
        "description": "The lifecycle states of a flow version known to this build (`draft` is editable and not yet live, `published` is the version runs execute, `archived` is a superseded version kept for history). Referenced by `x-known-values` on `FlowVersionSummary.state`; the wire field is an open string and clients must tolerate a state not listed here.",
        "type": "string",
        "enum": [
          "draft",
          "published",
          "archived"
        ]
      },
      "KnownFlowRunStatus": {
        "description": "The flow-run statuses this version knows, named by `FlowRun.status` through `x-known-values`. `queued`: accepted, not started; `running`: executing; `waiting`: paused for an approval or a timed delay (`waitingKind`/`wakeAt` say which); `succeeded`, `failed`, `skipped` (the trigger condition did not match, see `skipReason`) and `cancelled` are terminal. The field is an open string, so treat a value not listed here as non-terminal and render it verbatim.",
        "type": "string",
        "enum": [
          "queued",
          "running",
          "waiting",
          "succeeded",
          "failed",
          "skipped",
          "cancelled"
        ]
      },
      "KnownFlowRunStepStatus": {
        "description": "The states of one step of a flow run this version knows, referenced via `x-known-values`. `running` — executing or retrying; `succeeded` — produced its output; `failed` — ended the run with an error; `skipped` — did not execute because the run was stopped (permission, approval or stale snapshot); `waiting` — parked on a wait or approval block until its wake time. Open vocabulary.",
        "type": "string",
        "enum": [
          "running",
          "succeeded",
          "failed",
          "skipped",
          "waiting"
        ]
      },
      "KnownFlowRunTriggerSource": {
        "description": "What started a flow run (`FlowRun.triggerSource`): `record_event` a record created, updated or deleted; `schedule` the flow's cron; `inbound_webhook` an external POST to the flow's webhook URL; `record_action` a person pressing a record action; `test` a builder test run of the draft, which is never pinned to a published version. Known values of an open vocabulary — clients must tolerate a source not listed here.",
        "type": "string",
        "enum": [
          "record_event",
          "schedule",
          "inbound_webhook",
          "test",
          "record_action"
        ]
      },
      "KnownFlowApprovalStatus": {
        "description": "Values of a flow approval's `status` known to this version: `pending` awaiting a decision, `approved` the approver let the flow continue, `rejected` the approver stopped it, `expired` the deadline passed with no decision. Anything other than `pending` is settled. Open by contract.",
        "type": "string",
        "enum": [
          "pending",
          "approved",
          "rejected",
          "expired"
        ]
      },
      "KnownImportJobKind": {
        "description": "The import job kinds known to this version, referenced by `x-known-values` on `ImportJob.kind`: `commit_single` loads one file into one table; `commit_batch` loads several files (and their relationships) in one job; `fetch_http` pulls records from an HTTP source into a staged document that the ordinary analyze and import calls then take (`POST /imports/sources/http`); `revert` moves the records an earlier import created to the recycle bin (`POST /imports/jobs/{jobId}/revert`). Open vocabulary: clients tolerate values not listed here.",
        "type": "string",
        "enum": [
          "commit_single",
          "commit_batch",
          "fetch_http",
          "revert"
        ]
      },
      "KnownImportJobStatus": {
        "description": "Lifecycle of an import job, as known to this build (open vocabulary): `queued` waiting for a worker, `running` in progress, then exactly one terminal state — `succeeded`, `failed` (the job aborted; nothing partial is kept), or `cancelled` (a cancel was requested and honoured).",
        "type": "string",
        "enum": [
          "queued",
          "running",
          "succeeded",
          "failed",
          "cancelled"
        ]
      },
      "KnownImportJobPhase": {
        "description": "Phases of an import job known to this version (`ImportJob.progress.phase`), in order: `pending` not started, `applying_schema` applying the schema plan, `shredding` splitting JSON/YAML/XLSX documents into per-table CSVs, `inserting` loading rows, `linking` resolving cross-file references into reference fields, `linking_activities` attaching activities to the records an `activityLinks` file names, `attaching` filing the bodies an `attachments` manifest names into attachment fields, `backfilling_history` writing the stage moves a `stageHistory` file names as history, `finalizing` wrapping up; a `fetch_http` job has the one phase `fetching`, paging records from the HTTP source into the staged document; a `revert` job has the one phase `reverting`, moving the import's records to the recycle bin. Jobs without a plan or document files skip the phases they do not need. Open vocabulary — tolerate values not listed.",
        "type": "string",
        "enum": [
          "pending",
          "fetching",
          "applying_schema",
          "shredding",
          "inserting",
          "linking",
          "linking_activities",
          "attaching",
          "backfilling_history",
          "reverting",
          "finalizing"
        ]
      },
      "KnownImportRelationshipKind": {
        "description": "How an import relationship between two files was arrived at, as known to this build: `detected` is a heuristic match of one file's values against another's key column (a suggestion with alternatives and a confidence), `nested` is a link that is a fact of the file because the child records were nested inside the parent in a JSON or YAML document, and `declared` is a link the request's `adapter` read from the source platform's metadata (a Salesforce lookup whose target object was uploaded alongside) — certain, like `nested`. Referenced by `x-known-values` on `ImportRelationship.kind`; the wire field is open and clients must tolerate values not listed here.",
        "type": "string",
        "enum": [
          "detected",
          "nested",
          "declared"
        ]
      },
      "KnownImportFitOutcome": {
        "description": "The import-fit outcomes this version knows, named by `ImportTableFit.outcome` through `x-known-values`. `create`: nothing in the workspace fits, so the plan creates the table; `extend`: an existing table fits but lacks some columns, which become new fields on it; `map`: an existing table carries every column, so rows load into it as they are. Open string on the wire: tolerate values not listed.",
        "type": "string",
        "enum": [
          "create",
          "extend",
          "map"
        ]
      },
      "KnownImportFitMatchBasis": {
        "description": "What made an import's file column and an existing field agree, referenced by `ImportFitMatch.basis` via `x-known-values`. `name` — the names agree under the identifier rules; `values` — the sampled values overlap; `name+values` — both. Open vocabulary.",
        "type": "string",
        "enum": [
          "name",
          "values",
          "name+values"
        ]
      },
      "KnownImportRuleProposalSource": {
        "description": "Who proposed an import rule (`ImportRuleProposal.source`). Only `ai` exists today: a language model working from the column's header, a bounded sample of its values and the candidate fields. Known values of an open vocabulary — clients must tolerate a source not listed here.",
        "type": "string",
        "enum": [
          "ai"
        ]
      },
      "KnownPendingChangeStatus": {
        "description": "Values of `PendingChange.status` known to this version: `pending` awaiting the current step's decision, `approved` the route completed and the change was applied, `declined` an approver stopped it, `cancelled` withdrawn before a decision, `expired` the expiry window passed undecided, `failed` approved but the apply was rejected (see `applyError`). Open by contract — this set grows.",
        "type": "string",
        "enum": [
          "pending",
          "approved",
          "declined",
          "cancelled",
          "expired",
          "failed"
        ]
      },
      "KnownPendingChangeKind": {
        "description": "The kinds of record change an approval can hold in this version, referenced by `x-known-values` on `PendingChange.kind`: `update` (a proposed edit), `create` and `delete`. Open vocabulary: clients tolerate values not listed here.",
        "type": "string",
        "enum": [
          "update",
          "create",
          "delete"
        ]
      },
      "KnownNotificationType": {
        "description": "The notification kinds this build can raise (open vocabulary — render an unknown type verbatim). Workspace limits: `limits.breached` (a hard cap rejected work), `limits.thresholdReached` (usage crossed a warning threshold). Organization: `domain.verificationLost`, `billing.pastDue`, `billing.suspended`, `backup.jobFailed`. Automation: `automation.disabled` (an automation rule was switched off after repeated failures), `flow.runFailed`, `flow.runStuck`, `webhook.disabled` (a webhook subscription was switched off after three days of failed deliveries). Imports: `import.finishedWithIssues`. Personal: `comment.mentioned`, `task.assigned`, `record.viewMatched` (a record entered a saved view the user watches). Library: `schemaPart.needsAttention` (a published version of one of the organization's schema parts no longer validates cleanly on the current platform), `schemaPart.commented` (someone commented on one of the organization's parts), `schemaPart.versionPublished` (a part installed or followed here has a new version), `schemaPart.deprecated` (a part installed here was deprecated), `schemaPart.reportResolved` (the operators answered a report you filed), `schemaPart.withdrawn` (the operators withdrew one of the organization's parts).",
        "type": "string",
        "enum": [
          "limits.breached",
          "limits.thresholdReached",
          "domain.verificationLost",
          "billing.pastDue",
          "billing.suspended",
          "backup.jobFailed",
          "automation.disabled",
          "flow.runFailed",
          "flow.runStuck",
          "webhook.disabled",
          "import.finishedWithIssues",
          "comment.mentioned",
          "task.assigned",
          "record.viewMatched",
          "schemaPart.needsAttention",
          "schemaPart.commented",
          "schemaPart.versionPublished",
          "schemaPart.deprecated",
          "schemaPart.reportResolved",
          "schemaPart.withdrawn"
        ]
      },
      "KnownNotificationLifecycle": {
        "description": "Values of a notification's `lifecycle` known to this version: `condition` is a state that holds until it stops holding (re-raising reconciles it and it resolves itself when the fact goes away); `event` is a point-in-time fact that is appended and never resolves. Open vocabulary — tolerate values not listed.",
        "type": "string",
        "enum": [
          "condition",
          "event"
        ]
      },
      "KnownSubscriptionStatus": {
        "description": "Billing subscription statuses known to this build: `active`, `trialing` (on the granted trial), `past_due` (collection failed and a grace period is running), `cancelled`, and `suspended` (the grace period expired and writes are blocked while reads and exports still work). Referenced by `x-known-values` on `BillingSubscriptionSummary.status`; the wire field is open and clients must tolerate values not listed here.",
        "type": "string",
        "enum": [
          "active",
          "trialing",
          "past_due",
          "cancelled",
          "suspended"
        ]
      },
      "KnownInvoiceStatus": {
        "description": "The invoice statuses this version knows, named by `BillingInvoiceSummary.status` through `x-known-values`. `draft`: being assembled; `issued`: finalized and awaiting payment; `paid`: settled in full; `payment_failed`: a charge was declined and will be retried; `uncollectible`: the retry ladder is exhausted or the decline was final, and the organization is past due; `void`: cancelled, nothing owed. Open string on the wire: tolerate values not listed.",
        "type": "string",
        "enum": [
          "draft",
          "issued",
          "void",
          "paid",
          "payment_failed",
          "uncollectible"
        ]
      },
      "KnownPaymentAttemptStatus": {
        "description": "The states of one attempt to collect an invoice this version knows, referenced via `x-known-values`. `pending` — not yet presented, or a transport failure that will be re-presented; `processing` — the provider has it; `requires_action` — the issuer wants customer authentication; `succeeded` — paid; `failed` — declined; `abandoned` — the provider rejected the request outright and the attempt will not be retried. Open vocabulary.",
        "type": "string",
        "enum": [
          "pending",
          "processing",
          "requires_action",
          "succeeded",
          "failed",
          "abandoned"
        ]
      },
      "KnownChargeComponentKind": {
        "description": "The kinds of line that make up an invoice (`ChargeComponent.kind`): `plan_fee` is the subscription's base fee for the period, `metered_overage` is usage of one measure beyond the plan's included allowance, priced at the rate card. Known values of an open vocabulary — new commercial concepts arrive as new kinds, so clients must tolerate values not listed here.",
        "type": "string",
        "enum": [
          "plan_fee",
          "metered_overage"
        ]
      },
      "KnownBillingCustomerType": {
        "description": "Values of a billing profile's `customerType` known to this version: `business` a trading entity (whether or not it holds a VAT number), `individual` a private consumer. Together with the customer's country and tax id it decides the VAT treatment. Open by contract.",
        "type": "string",
        "enum": [
          "business",
          "individual"
        ]
      },
      "KnownBillingCollectionMethod": {
        "description": "The collection methods known to this version, referenced by `x-known-values` on billing-account `collectionMethod` fields: `auto_charge` charges the stored payment method when an invoice is issued; `send_invoice` emails an invoice to be paid within `paymentTermsDays`. Open vocabulary: clients tolerate values not listed here.",
        "type": "string",
        "enum": [
          "auto_charge",
          "send_invoice"
        ]
      },
      "KnownBillingCurrency": {
        "description": "The currencies an organization can be billed in: `GBP` (the historical default — anything predating multi-currency is GBP), `EUR` and `USD`. Each plan carries its own price per currency; amounts are never converted between them.",
        "type": "string",
        "enum": [
          "GBP",
          "EUR",
          "USD"
        ]
      },
      "KnownTaxIdStatus": {
        "description": "Values of a billing tax id's validation `status` known to this version: `unvalidated` stored but not yet checked against the issuing registry (VAT is charged meanwhile), `valid` the registry confirmed it, `invalid` the registry rejected it, `unavailable` the registry could not be reached and the previous verdict stands. Open vocabulary — tolerate values not listed.",
        "type": "string",
        "enum": [
          "unvalidated",
          "valid",
          "invalid",
          "unavailable"
        ]
      },
      "KnownNotificationSeverity": {
        "description": "Notification severities known to this build, affecting prominence only: `critical` tops out at a dismissible banner, `warning` and `info` are quieter. Referenced by `x-known-values` on `Notification.severity`; the wire field is open and a client must treat an unknown severity as no louder than `warning`.",
        "type": "string",
        "enum": [
          "critical",
          "warning",
          "info"
        ]
      },
      "KnownNotificationStatus": {
        "description": "The notification statuses this version knows, named by `Notification.status` through `x-known-values`. `open`: unread and, for a condition, still true; `acknowledged`: someone has dismissed the banner (shared across the organization for a condition), so it drops to the badge; `resolved`: the condition is no longer true, or the event has been read, and it leaves the badge. Open string on the wire: tolerate values not listed.",
        "type": "string",
        "enum": [
          "open",
          "acknowledged",
          "resolved"
        ]
      },
      "KnownApplicationEventType": {
        "description": "The application event types this version emits, referenced by `ApplicationEvent.eventType` through `x-known-values`. Lifecycle events for records (`Item*`), tables, fields and constraints, the approval pair, and a record's discussion thread being resolved or reopened (`CommentResolved`, `CommentReopened`), and a summary of metadata written about a record's fields (`MetadataChanged`). Open vocabulary: the wire field is a plain string and new types arrive without a spec bump.",
        "type": "string",
        "enum": [
          "ItemCreated",
          "ItemUpdated",
          "ItemDeleted",
          "TableCreated",
          "TableUpdated",
          "TableDeleted",
          "FieldCreated",
          "FieldUpdated",
          "FieldDeleted",
          "ConstraintCreated",
          "ConstraintDeleted",
          "ApprovalRequested",
          "ApprovalDecided",
          "CommentResolved",
          "CommentReopened",
          "MetadataChanged"
        ]
      },
      "BackupJobProgress": {
        "type": "object",
        "description": "Live progress of the most recent backup or restore job.",
        "required": [
          "phase",
          "tablesDone",
          "tableCount",
          "rowsProcessed",
          "attachmentsProcessed",
          "warnings"
        ],
        "properties": {
          "phase": {
            "type": "string",
            "x-known-values": "KnownBackupJobPhase",
            "description": "Lifecycle vocabulary (job state machine; backup phases then restore phases): the values known to this version are enumerated by the KnownBackupJobPhase schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed (this set grows)."
          },
          "tablesDone": {
            "description": "Tables finished so far in the current phase, out of `tableCount`. While packaging a download (`archive` phase) it counts archive members written instead.",
            "type": "integer"
          },
          "tableCount": {
            "description": "Total tables the job covers; the denominator for `tablesDone` (archive members during the `archive` phase).",
            "type": "integer"
          },
          "rowsProcessed": {
            "description": "Record rows written or restored so far across all tables. During the `archive` phase it carries bytes written instead.",
            "type": "integer",
            "format": "int64"
          },
          "attachmentsProcessed": {
            "description": "Attachment files copied so far; stays 0 for phases that do not touch attachments.",
            "type": "integer"
          },
          "warnings": {
            "type": "array",
            "description": "Non-fatal issues (dropped grants, missing attachment files).",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "WorkspaceBackup": {
        "description": "A point-in-time backup of one workspace, owned by the organization and restorable into a workspace later. Returned by the organization's backup list, create and get endpoints; the size and row counts are filled in as the backup job completes.",
        "type": "object",
        "required": [
          "id",
          "organizationId",
          "sourceWorkspaceId",
          "sourceWorkspaceName",
          "status",
          "sizeBytes",
          "tableCount",
          "rowCount",
          "attachmentCount",
          "createdBy",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Server-assigned identifier of the backup; the `backupId` the get, download and restore endpoints take.",
            "type": "string"
          },
          "organizationId": {
            "description": "The organization that owns the backup. Backups belong to the organization, not the workspace, so they outlive it.",
            "type": "string"
          },
          "sourceWorkspaceId": {
            "type": "string",
            "description": "The workspace this backup was taken from. Not a live FK — the source workspace may no longer exist."
          },
          "sourceWorkspaceName": {
            "description": "Name of the source workspace when the backup was taken, kept so the backup stays recognisable after a rename or deletion.",
            "type": "string"
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownWorkspaceBackupStatus",
            "description": "Lifecycle vocabulary: the values known to this version are enumerated by the KnownWorkspaceBackupStatus schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed (this set grows)."
          },
          "sizeBytes": {
            "description": "Total size of the stored backup in bytes (the schema dump, the copied files and the manifest). 0 until the job has written data.",
            "type": "integer",
            "format": "int64"
          },
          "tableCount": {
            "description": "How many tables the backup contains. 0 until the job has reached them.",
            "type": "integer"
          },
          "rowCount": {
            "description": "Total records across all tables in the backup, those in the recycle bin included. 0 until the job has written data.",
            "type": "integer",
            "format": "int64"
          },
          "attachmentCount": {
            "description": "How many of the workspace's files (record attachments and branding) were copied into the backup. 0 until the job has reached them.",
            "type": "integer"
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "User-facing failure message when status is failed."
          },
          "scheduleId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The backup schedule that created this backup, or null for one taken on demand. Cleared (not cascaded) if that schedule is later deleted, so the backup itself always survives."
          },
          "createdBy": {
            "description": "Id of the user the backup ran as: the requester for an on-demand backup, the schedule's creator for a scheduled one.",
            "type": "string"
          },
          "createdAt": {
            "description": "When the backup was requested and its job started, ISO-8601 UTC; set by the server.",
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "description": "When the backup job finished successfully, ISO-8601 UTC; null while it is still running or if it failed.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When restorability lapses, if scheduled. Support attaches to the backup's FORMAT version, not its age: null while that format version is still current (no scheduled expiry), and set to one year after the version was superseded once a newer format ships. Past this instant a restore request is rejected with 409."
          },
          "latestJob": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/BackupJobProgress"
              },
              {
                "type": "null"
              }
            ],
            "description": "Progress of the in-flight backup job, when one is running."
          }
        }
      },
      "BackupRestoreJob": {
        "description": "The asynchronous job that restores one organization backup into a brand-new workspace. Returned as a 202 when the restore is queued and by `GET /organizations/{organizationId}/restores/{jobId}` while the client polls it.",
        "type": "object",
        "required": [
          "id",
          "backupId",
          "organizationId",
          "status",
          "progress",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Identifier of this restore job; poll it at `GET /organizations/{organizationId}/restores/{jobId}`.",
            "type": "string"
          },
          "backupId": {
            "description": "The backup being restored.",
            "type": "string"
          },
          "organizationId": {
            "description": "The organization the backup belongs to and the new workspace is created in.",
            "type": "string"
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownBackupRestoreJobStatus",
            "description": "Lifecycle vocabulary: the values known to this version are enumerated by the KnownBackupRestoreJobStatus schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed (this set grows)."
          },
          "progress": {
            "$ref": "#/components/schemas/BackupJobProgress"
          },
          "newWorkspaceId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The workspace the backup was restored into, set once the restore completes."
          },
          "error": {
            "description": "User-facing reason the restore failed. Null unless `status` is `failed`.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the restore was queued, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "finishedAt": {
            "description": "When the job reached a terminal status (completed, failed or cancelled), ISO-8601 UTC; null while it is still queued or running.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CreateWorkspaceBackupRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/backups`: names the workspace to back up. The backup job is queued and reported as a `WorkspaceBackup`.",
        "type": "object",
        "required": [
          "workspaceId"
        ],
        "properties": {
          "workspaceId": {
            "type": "string",
            "description": "The workspace to back up. Must belong to this organization."
          }
        }
      },
      "RestoreWorkspaceBackupRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/backups/{backupId}/restore`: restore the backup into a brand-new workspace with the given name, never over an existing one.",
        "type": "object",
        "required": [
          "newWorkspaceName"
        ],
        "properties": {
          "newWorkspaceName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Name for the new workspace the backup will be restored into."
          }
        }
      },
      "BackupDownload": {
        "type": "object",
        "description": "State of a backup's downloadable archive. A backup is stored as several S3 objects (the signed manifest, a `pg_dump` custom-format dump of the workspace schema, and copies of the workspace's files), so downloading one means packaging those into a single `.tar` first — an async job. Poll this until `status` is `ready`, then fetch `downloadUrl`.",
        "required": [
          "backupId",
          "status"
        ],
        "properties": {
          "backupId": {
            "description": "The backup this archive is packaged from; echoes the `backupId` in the request path.",
            "type": "string"
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownBackupDownloadStatus",
            "description": "Lifecycle vocabulary: the values known to this version are enumerated by the KnownBackupDownloadStatus schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed (this set grows). `none` means no archive has been prepared (or the previous one expired)."
          },
          "downloadUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "Short-lived pre-signed URL for the packaged archive. Only set while `status` is `ready`; treat it as a credential — anyone holding it can read the whole backup until it expires."
          },
          "sizeBytes": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Size of the packaged archive, once it is ready."
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the packaged archive is deleted. Re-request a download after this to have it packaged again; the backup itself is unaffected."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "User-facing failure message when status is failed."
          }
        }
      },
      "BackupSchedule": {
        "type": "object",
        "description": "A recurring backup of one workspace. The cron expression is standard 5-field syntax evaluated in UTC.",
        "required": [
          "id",
          "organizationId",
          "workspaceId",
          "workspaceName",
          "cron",
          "enabled",
          "retainCount",
          "createdBy",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Server-assigned identifier of the schedule; the `scheduleId` the patch and delete endpoints take.",
            "type": "string"
          },
          "organizationId": {
            "description": "The organization that owns the schedule and whose backup limits it runs under.",
            "type": "string"
          },
          "workspaceId": {
            "description": "The workspace each firing backs up. Stable across workspace renames (see `workspaceName`).",
            "type": "string"
          },
          "workspaceName": {
            "type": "string",
            "description": "Current name of the workspace this schedule backs up."
          },
          "cron": {
            "type": "string",
            "description": "Standard 5-field cron expression, evaluated in UTC."
          },
          "enabled": {
            "description": "Whether the schedule fires. While disabled `nextRunAt` is null and nothing is backed up or pruned.",
            "type": "boolean"
          },
          "retainCount": {
            "type": "integer",
            "description": "How many backups this schedule keeps. Before each run the schedule deletes its own oldest backups down to this many, so a recurring schedule cannot silently wedge against the organization's stored-backup ceiling. Only backups this schedule created are ever deleted — on-demand ones are never touched."
          },
          "nextRunAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Next UTC firing. Null while the schedule is disabled, or if the stored expression stopped being parseable (see lastError)."
          },
          "lastRunAt": {
            "description": "When the schedule last fired, ISO-8601 UTC, whether or not that firing started a backup (see `lastError`); null before the first firing.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastBackupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The backup started by the most recent successful firing."
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the most recent firing did not start a backup (for example the organization was at its backup limit). Cleared by the next firing that succeeds."
          },
          "createdBy": {
            "description": "Id of the user who created the schedule. Backups it takes run under this user's access to the workspace, so the schedule stops firing if they lose it.",
            "type": "string"
          },
          "createdAt": {
            "description": "When the schedule was created, ISO-8601 UTC; set by the server.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the schedule was last changed, ISO-8601 UTC; set by the server.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateBackupScheduleRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/backup-schedules`: a recurring backup of one workspace on a cron cadence with a retention count.",
        "type": "object",
        "required": [
          "workspaceId",
          "cron"
        ],
        "properties": {
          "workspaceId": {
            "type": "string",
            "description": "The workspace to back up. Must belong to this organization."
          },
          "cron": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Standard 5-field cron expression, evaluated in UTC. Rejected if it would fire more often than once an hour."
          },
          "enabled": {
            "description": "Whether the schedule fires; send false to create it paused. Defaults to true.",
            "type": "boolean",
            "default": true
          },
          "retainCount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 7,
            "description": "How many of this schedule's backups to keep."
          }
        }
      },
      "UpdateBackupScheduleRequest": {
        "type": "object",
        "description": "Only the supplied fields are changed.",
        "properties": {
          "cron": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Standard 5-field cron expression, evaluated in UTC. Rejected if it would fire more often than once an hour."
          },
          "enabled": {
            "description": "Turn the schedule on or off. Disabling keeps it and its backups; `nextRunAt` becomes null until it is re-enabled.",
            "type": "boolean"
          },
          "retainCount": {
            "description": "How many of its own backups the schedule keeps, 1 to 100. Before each firing it deletes its oldest backups down to this number; on-demand backups are never touched.",
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          }
        }
      },
      "OrganizationDirectoryEntry": {
        "description": "One person in the organization directory (`GET /organizations/{organizationId}/directory`): a deduplicated union of organization members and members of every workspace in the organization, with their memberships.",
        "type": "object",
        "required": [
          "userId",
          "email",
          "name",
          "workspaces"
        ],
        "properties": {
          "userId": {
            "description": "Id of the user; the same id across every workspace they belong to.",
            "type": "string"
          },
          "email": {
            "description": "The user's login email.",
            "type": "string",
            "format": "email"
          },
          "name": {
            "description": "The user's display name.",
            "type": "string"
          },
          "orgRole": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/OrganizationRole"
              },
              {
                "type": "null"
              }
            ],
            "description": "Organization role, if the user is an active org member"
          },
          "workspaces": {
            "type": "array",
            "description": "Active workspace memberships within this organization",
            "items": {
              "type": "object",
              "required": [
                "workspaceId",
                "workspaceName",
                "role"
              ],
              "properties": {
                "workspaceId": {
                  "description": "Id of a workspace in this organization the user is an active member of.",
                  "type": "string"
                },
                "workspaceName": {
                  "description": "Display name of that workspace at the time of the request.",
                  "type": "string"
                },
                "role": {
                  "$ref": "#/components/schemas/WorkspaceRole"
                }
              }
            }
          }
        }
      },
      "SystemEntity": {
        "description": "A built-in, read-only entity (`users`, `groups`) that reference fields can point at instead of a user-created table, described with its fixed fields. Item of the `GET /system-entities` list.",
        "type": "object",
        "required": [
          "id",
          "name",
          "displayName",
          "description",
          "sqlTable",
          "fields"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "System entity identifier (e.g., 'users', 'groups')"
          },
          "sqlTable": {
            "type": "string",
            "description": "The read-only SQL view that holds this entity's rows for `POST /query`, e.g. `sys_users` for users and `sys_usergroups` for groups. Its columns are the `fieldName`s of `fields`. Shown beside the entity so a builder knows what to select from."
          },
          "name": {
            "type": "string",
            "description": "Internal name"
          },
          "displayName": {
            "type": "string",
            "description": "User-friendly display name"
          },
          "description": {
            "type": "string",
            "description": "Description of this system entity"
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SystemEntityField"
            },
            "description": "Field definitions for this system entity"
          }
        }
      },
      "SystemEntityField": {
        "description": "One attribute of a built-in system entity (users, groups) that reference fields and formulas can target, described the way a table field is. Item of `SystemEntity.fields`.",
        "type": "object",
        "required": [
          "id",
          "fieldName",
          "displayName",
          "fieldType"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the system attribute, e.g. `sys_user_email`; what configuration refers to.",
            "type": "string"
          },
          "fieldName": {
            "description": "The attribute's key as it appears in data, e.g. `email`.",
            "type": "string"
          },
          "displayName": {
            "description": "Human-readable label for pickers and headers, e.g. `Email`.",
            "type": "string"
          },
          "fieldType": {
            "$ref": "#/components/schemas/FieldType"
          },
          "description": {
            "description": "Short explanation of what the attribute holds. Null when there is nothing to add beyond the name.",
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Group": {
        "description": "A named set of workspace members, used to grant record visibility, shares and approvals to several people at once. Returned by the groups list, create, get and update endpoints.",
        "type": "object",
        "required": [
          "id",
          "name",
          "isActive",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the group, used in `/groups/{groupId}` paths and in `groupIds` lists elsewhere.",
            "type": "string"
          },
          "name": {
            "description": "Display name of the group, unique within the workspace.",
            "type": "string"
          },
          "description": {
            "description": "What the group is for; null when none was given.",
            "type": [
              "string",
              "null"
            ]
          },
          "isActive": {
            "description": "False when the group has been deactivated: it is hidden from the default list (ask with `includeInactive`) and grants nothing, but keeps its members and can be reactivated.",
            "type": "boolean"
          },
          "createdById": {
            "description": "User id of the member who created the group.",
            "type": "string"
          },
          "createdByName": {
            "description": "Display name of that creator at read time; null when they are no longer a member.",
            "type": [
              "string",
              "null"
            ]
          },
          "memberCount": {
            "type": "integer",
            "description": "Number of members in the group"
          },
          "createdAt": {
            "description": "When the group was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the group's name, description or active state last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "GroupMember": {
        "description": "One user's membership of a group, as listed by `GET /groups/{groupId}/members` and returned when a member is added: who they are and who added them, when.",
        "type": "object",
        "required": [
          "userId",
          "email",
          "name",
          "addedAt"
        ],
        "properties": {
          "userId": {
            "description": "The member's user id, as used in `DELETE /groups/{groupId}/members/{userId}` and in user references.",
            "type": "string"
          },
          "email": {
            "description": "The member's sign-in email address.",
            "type": "string",
            "format": "email"
          },
          "name": {
            "description": "The member's display name.",
            "type": "string"
          },
          "addedById": {
            "description": "User id of whoever added the member to the group. Null when that is not recorded.",
            "type": [
              "string",
              "null"
            ]
          },
          "addedByName": {
            "description": "Display name of the user in `addedById`, looked up at read time; null when unknown.",
            "type": [
              "string",
              "null"
            ]
          },
          "addedAt": {
            "description": "When the user was added to the group, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateGroupRequest": {
        "description": "Request body of `POST /groups`: creates a group in the caller's current workspace. Members are added afterwards through the group's membership endpoints.",
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "description": "Display name of the new group, shown wherever members, shares and permissions name it.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "description": {
            "description": "Free-text note on what the group is for, shown in the group list. Null or omitted for none.",
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "UpdateGroupRequest": {
        "description": "Request body of `PATCH /groups/{groupId}`. Every property is optional; only the supplied ones change.",
        "type": "object",
        "properties": {
          "name": {
            "description": "New display name of the group, 1 to 255 characters.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "description": {
            "description": "New description; null clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "isActive": {
            "description": "False deactivates the group without deleting it: it drops out of default group listings and can no longer be the target of new record shares or filters. True reactivates it.",
            "type": "boolean"
          }
        }
      },
      "AddGroupMemberRequest": {
        "description": "Request body of `POST /groups/{groupId}/members`: the user to add to the group.",
        "type": "object",
        "required": [
          "userId"
        ],
        "properties": {
          "userId": {
            "type": "string",
            "description": "User ID to add to the group"
          }
        }
      },
      "GroupEffectivePermissions": {
        "description": "Response of `GET /groups/{groupId}/effective-permissions`: what each active member of one group can do on one table, plus the records of that table shared with the group as a whole. A group holds no permissions of its own, so the answer is computed per member from the same snapshots enforcement uses.",
        "type": "object",
        "required": [
          "groupId",
          "tableId",
          "tableVisibility",
          "members",
          "sharedRecordCount",
          "sharedRecords"
        ],
        "properties": {
          "groupId": {
            "type": "string",
            "description": "The group the answer is about, echoed from the path."
          },
          "tableId": {
            "type": "string",
            "description": "The table the answer is scoped to, echoed from the request so a cached response is self-describing."
          },
          "tableVisibility": {
            "$ref": "#/components/schemas/RecordVisibility"
          },
          "members": {
            "type": "array",
            "description": "Every active member of the group, in name order.",
            "items": {
              "$ref": "#/components/schemas/MemberEffectivePermissions"
            }
          },
          "sharedRecordCount": {
            "type": "integer",
            "description": "Records of this table shared with the group as a whole (sharedRecords below is capped)."
          },
          "sharedRecords": {
            "description": "Records of this table shared explicitly with the group as a whole, with the access level each share grants. Capped at 100 entries; `sharedRecordCount` is the full number.",
            "type": "array",
            "maxItems": 100,
            "items": {
              "type": "object",
              "required": [
                "recordId",
                "accessLevel"
              ],
              "properties": {
                "recordId": {
                  "type": "string",
                  "description": "Id of the shared record."
                },
                "accessLevel": {
                  "description": "What the share grants every member of the group on that record: `view` (read only) or `edit` (read and write).",
                  "type": "string",
                  "enum": [
                    "view",
                    "edit"
                  ]
                }
              }
            }
          }
        }
      },
      "MemberEffectivePermissions": {
        "description": "What one member can actually do with one table's records once their base role, every role assigned to them and their field restrictions are combined: the union across their roles, computed from the same permission snapshot enforcement uses. The answer of `GET /permissions/effective`, and the item of `GroupEffectivePermissions.members`.",
        "type": "object",
        "required": [
          "userId",
          "name",
          "email",
          "baseRole",
          "roleIds",
          "baselineAdmin",
          "records",
          "rowRules",
          "restrictedFields"
        ],
        "properties": {
          "userId": {
            "type": "string",
            "description": "The member's user id."
          },
          "name": {
            "type": "string",
            "description": "The member's display name."
          },
          "email": {
            "type": "string",
            "description": "The member's email address."
          },
          "baseRole": {
            "$ref": "#/components/schemas/WorkspaceRole"
          },
          "roleIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Roles assigned beyond the base membership role."
          },
          "baselineAdmin": {
            "type": "boolean",
            "description": "Whether the member's base role is Admin. A baseline admin is the one principal row rules and field checks are not applied to: they reach every record and every field, so `rowRules` and `restrictedFields` are empty for them whatever their roles carry. A client says so rather than showing an empty rule list as \"no access\"."
          },
          "rowRules": {
            "$ref": "#/components/schemas/EffectiveRowRules"
          },
          "records": {
            "type": "object",
            "description": "The member's effective access to this table's records: whether they hold each record action at all, and the row scope each verb resolves to (`none` when the action is not held). On a verb `rowRules` lists, the rules decide which records and this scope does not apply.",
            "required": [
              "create",
              "read",
              "update",
              "delete"
            ],
            "properties": {
              "create": {
                "type": "boolean",
                "description": "Holds `records:create`."
              },
              "read": {
                "$ref": "#/components/schemas/RecordAccessScope"
              },
              "update": {
                "$ref": "#/components/schemas/RecordAccessScope"
              },
              "delete": {
                "$ref": "#/components/schemas/RecordAccessScope"
              }
            }
          },
          "restrictedFields": {
            "type": "object",
            "description": "Field names of this table the member may not read / may not update.",
            "required": [
              "read",
              "update"
            ],
            "properties": {
              "read": {
                "description": "Field names of this table the member may not read; the values are withheld from them.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "update": {
                "description": "Field names of this table the member may not change, even on records they may otherwise update.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "create": {
                "description": "Field names of this table the member may not set when creating a record. Absent from answers written before the create bit existed.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "EffectiveRowRules": {
        "type": "object",
        "description": "The row rules that decide one member's access to one table, by verb: the union of the rules every role they hold carries there. A verb that is PRESENT is governed (some role in the workspace has a rule on it, or the table is `restricted`): the member reaches exactly the records one of the listed rules matches, plus the records shared with them, and an empty list means none. A verb that is ABSENT is open, and `records` says what the member reaches. A rule that no longer compiles (a field it names is gone) grants nothing and is not listed.",
        "properties": {
          "read": {
            "type": "array",
            "description": "The rules that grant reading records, when reading this table is governed.",
            "items": {
              "$ref": "#/components/schemas/EffectiveRowRule"
            }
          },
          "update": {
            "type": "array",
            "description": "The rules that grant changing records, when updating this table is governed.",
            "items": {
              "$ref": "#/components/schemas/EffectiveRowRule"
            }
          },
          "delete": {
            "type": "array",
            "description": "The rules that grant deleting records, when deleting from this table is governed.",
            "items": {
              "$ref": "#/components/schemas/EffectiveRowRule"
            }
          }
        }
      },
      "EffectiveRowRule": {
        "type": "object",
        "description": "One rule in a member's union: a row rule one of their roles carries, or a legacy record scope folded in as a rule. A legacy scope (a role's `own`, `group` or `workspace` scope on a private table) keeps granting what it granted the day the table became governed; it is shown as the `ownedBy` filter it compiles to, so whoever configures roles can see it and replace it with a rule.",
        "required": [
          "ruleId",
          "roleId",
          "filter"
        ],
        "properties": {
          "ruleId": {
            "type": "string",
            "description": "The stored rule's id (the one `/roles/{roleId}/row-rules/{ruleId}` edits), or `legacy:<scope>` for a folded-in scope grant, which has no stored rule of its own."
          },
          "roleId": {
            "type": "string",
            "description": "The role carrying the rule. Empty for a folded-in scope grant, which comes from the member's roles' scopes together rather than from one rule."
          },
          "legacyScope": {
            "type": "string",
            "enum": [
              "own",
              "group",
              "workspace"
            ],
            "description": "Set only on a folded-in scope grant: the legacy scope it comes from. `own` is records the member owns, `group` records owned by them or by anyone sharing a group with them, `workspace` every record."
          },
          "filter": {
            "$ref": "#/components/schemas/RecordFilter"
          }
        }
      },
      "WorkspaceOpenApiAudience": {
        "type": "string",
        "description": "Who the workspace OpenAPI document is rendered for. `api`: a client of the API host (paths under `/api`, `servers` the API base URL, bearer security). `site`: a hosted site's pages calling the API through their own origin's `/_api` proxy (only the operations a site may call, paths relative to `/_api`, no bearer security).",
        "enum": [
          "api",
          "site"
        ],
        "default": "api"
      },
      "WorkspaceOpenApiScope": {
        "type": "string",
        "description": "How much of the workspace API a document covers. `full`: the workspace's tables plus every workspace-wide resource. `tables`: the workspace-specific part alone. `table`: one table's operations and the schemas they use, the table named by `table`.",
        "enum": [
          "full",
          "tables",
          "table"
        ],
        "default": "full"
      },
      "WorkspaceOpenApiDocumentInfo": {
        "type": "object",
        "description": "One form of the workspace's OpenAPI document, described without its contents: which audience and scope it is for, the version it is at, and its size.",
        "required": [
          "audience",
          "scope",
          "version",
          "revision",
          "bytes",
          "mediaType"
        ],
        "properties": {
          "audience": {
            "$ref": "#/components/schemas/WorkspaceOpenApiAudience"
          },
          "scope": {
            "$ref": "#/components/schemas/WorkspaceOpenApiScope"
          },
          "table": {
            "type": "string",
            "description": "For scope `table`, the id of the table the document covers; absent for every other scope.",
            "example": "a1b2c3d4e5f6"
          },
          "version": {
            "type": "string",
            "description": "The document's `info.version`: the generator's version plus a build-metadata digest of the document, so it changes whenever the document does. Compare the whole string.",
            "example": "1.23.0+ws.3f9a1c2b7d04"
          },
          "revision": {
            "type": "string",
            "description": "The digest alone (`info.x-revision`): twelve hex characters of the SHA-256 of the document without its `servers` block.",
            "example": "3f9a1c2b7d04"
          },
          "bytes": {
            "type": "integer",
            "description": "The size of the document as the API serves it (compact JSON, UTF-8), in bytes."
          },
          "mediaType": {
            "type": "string",
            "description": "The media type the document is served as.",
            "example": "application/json"
          }
        }
      },
      "WorkspaceOpenApiDocumentList": {
        "type": "object",
        "description": "Every form of the workspace's OpenAPI document, described.",
        "required": [
          "documents"
        ],
        "properties": {
          "documents": {
            "type": "array",
            "description": "One entry per audience at the `full` and `tables` scopes, in a fixed order. The one-table documents (scope `table`) are not listed: there is one per table, each fetched by naming its table.",
            "items": {
              "$ref": "#/components/schemas/WorkspaceOpenApiDocumentInfo"
            }
          }
        }
      },
      "WorkspaceOpenApiDownloadLinkRequest": {
        "type": "object",
        "description": "Which form of the document the download link should reach.",
        "properties": {
          "audience": {
            "$ref": "#/components/schemas/WorkspaceOpenApiAudience"
          },
          "scope": {
            "$ref": "#/components/schemas/WorkspaceOpenApiScope"
          },
          "table": {
            "type": "string",
            "minLength": 1,
            "maxLength": 63,
            "description": "The table a scope `table` document covers, by its id or its name. Required with scope `table`, and refused with any other scope."
          }
        }
      },
      "WorkspaceOpenApiDownloadLink": {
        "description": "A short-lived download link for one form of the workspace's OpenAPI document, with that document described. The link needs no header: its URL carries a signed token that names the workspace, the document and the caller it was created for.",
        "allOf": [
          {
            "$ref": "#/components/schemas/WorkspaceOpenApiDocumentInfo"
          },
          {
            "type": "object",
            "required": [
              "url",
              "expiresAt",
              "lifetimeSeconds"
            ],
            "properties": {
              "url": {
                "type": "string",
                "description": "Where to fetch the document from: the signed file route, `/api/workspace/openapi/file`, with the token in its query, usable without a credential header until `expiresAt`."
              },
              "expiresAt": {
                "type": "string",
                "format": "date-time",
                "description": "When the link stops working. A new link is one call away."
              },
              "lifetimeSeconds": {
                "type": "integer",
                "description": "How long a freshly created link lives, in seconds (600)."
              }
            }
          }
        ]
      },
      "WorkspaceSdkDownloadLinkRequest": {
        "type": "object",
        "description": "Which form of the workspace's typed client archive the download link should reach.",
        "properties": {
          "audience": {
            "description": "`site` (the default, as for `tessule pull`): the archive a hosted site builds on, with the per-table accessors (`tessule-ws.ts`). `api`: the types for a client of the API host, with the client and no accessors.",
            "allOf": [
              {
                "$ref": "#/components/schemas/WorkspaceOpenApiAudience"
              }
            ]
          }
        }
      },
      "WorkspaceSdkDownloadLink": {
        "type": "object",
        "description": "A short-lived download link for the workspace's typed client archive: a gzipped tarball in npm-pack layout (everything under `package/`) holding the zero-dependency `@tessule/client` build, the workspace's OpenAPI types (`openapi.d.ts`) and its per-table accessor module (`tessule-ws.ts`, exporting `createWorkspace`), generated from the workspace's current OpenAPI document for one audience. The archive can be installed from the file (`npm i ./file.tgz`) or unpacked with `tar -xzf`; no package registry or registry credential is involved.",
        "required": [
          "audience",
          "url",
          "version",
          "clientVersion",
          "digest",
          "sizeBytes",
          "expiresAt"
        ],
        "properties": {
          "audience": {
            "$ref": "#/components/schemas/WorkspaceOpenApiAudience"
          },
          "url": {
            "type": "string",
            "description": "Where to fetch the archive from, with no credential header, until `expiresAt`. The URL reaches this one archive and nothing else."
          },
          "version": {
            "type": "string",
            "description": "The archive's package version: the OpenAPI document's `info.version`, including its `+ws.<revision>` build metadata. A new revision of the workspace's schema is a new version and a new archive."
          },
          "clientVersion": {
            "type": "string",
            "description": "The build of `@tessule/client` inside the archive: the commit it was built from (`dev-<content digest>` for a local build). The archive's README names it too."
          },
          "digest": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "The archive's SHA-256, lowercase hex. Compare it with the downloaded file's before unpacking it."
          },
          "sizeBytes": {
            "type": "integer",
            "description": "The archive's size in bytes."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the link stops working. A new link is one call away."
          }
        }
      },
      "WorkspaceMe": {
        "type": "object",
        "description": "The caller, as the workspace the request acts in sees them.",
        "required": [
          "id",
          "name",
          "email",
          "role",
          "workspace"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The caller's user id."
          },
          "name": {
            "description": "The caller's display name.",
            "type": "string"
          },
          "email": {
            "description": "The caller's email address.",
            "type": "string"
          },
          "role": {
            "type": "string",
            "description": "The caller's baseline membership role in this workspace (admin, member or reader). Display only: what the caller may do is `/me/permissions`."
          },
          "workspace": {
            "description": "The workspace the request acts in (from the access token), so an integration can confirm which workspace it is talking to.",
            "type": "object",
            "required": [
              "id",
              "name"
            ],
            "properties": {
              "id": {
                "description": "Id of the current workspace, as used in `RefreshTokenRequest.workspaceId`.",
                "type": "string"
              },
              "name": {
                "description": "The workspace's real name (not any branding `displayName`).",
                "type": "string"
              }
            }
          }
        }
      },
      "HostedSiteSessionChannel": {
        "type": "string",
        "description": "The BroadcastChannel a hosted site's pages share with its `/_auth/done` page (docs/HOSTED_SITES.md, \"Signing in again without leaving the page\"). Not an HTTP payload: the page posts a `HostedSiteSessionMessage` on this channel when a sign-in started from the site finishes, and every tab of the site listening on it (`@tessule/client` in `hold` mode) learns the outcome.",
        "enum": [
          "tessule-site-session"
        ]
      },
      "HostedSiteSignInOutcome": {
        "type": "string",
        "description": "How a sign-in started from a hosted site ended. `signed-in`: the browser now holds a session for the site. `cancelled`: the member declined, or the sign-in was abandoned before it finished. `failed`: it could not complete (expired, refused, or no session resulted).",
        "enum": [
          "signed-in",
          "cancelled",
          "failed"
        ]
      },
      "HostedSiteSessionMessage": {
        "type": "object",
        "description": "What `/_auth/done` posts on the `HostedSiteSessionChannel` when a sign-in finishes.",
        "required": [
          "type",
          "outcome"
        ],
        "properties": {
          "type": {
            "description": "Discriminator of the message; always `sign-in`, so a listener can ignore anything else posted on the channel.",
            "type": "string",
            "enum": [
              "sign-in"
            ]
          },
          "outcome": {
            "$ref": "#/components/schemas/HostedSiteSignInOutcome"
          }
        }
      },
      "MyMetadataGrant": {
        "description": "What the caller may do to one metadata table's rows, from their roles' grants on it (`PUT /roles/{roleId}/metadata-tables/{metadataTableId}`; a baseline admin holds create and delete) and the record action each verb needs.",
        "type": "object",
        "required": [
          "canCreate",
          "canUpdate",
          "canDelete"
        ],
        "properties": {
          "canCreate": {
            "type": "boolean",
            "description": "May write a row about a field that has none."
          },
          "canUpdate": {
            "type": "boolean",
            "description": "May replace an existing row's values (never on an append-only table)."
          },
          "canDelete": {
            "type": "boolean",
            "description": "May delete a row."
          }
        }
      },
      "MyPermissions": {
        "description": "The caller's effective permission snapshot in the current workspace, returned by `GET /me/permissions`: the actions they may take, the roles and groups behind them, and the record scopes and field restrictions that narrow what they see. For gating UI only — every check is also enforced server-side.",
        "type": "object",
        "required": [
          "principalId",
          "actions",
          "roleIds",
          "groupIds",
          "privateTables",
          "restrictedFields",
          "queryUnrestricted",
          "metadataGrants"
        ],
        "properties": {
          "metadataGrants": {
            "type": "object",
            "description": "What the caller may write on each metadata table of the workspace, keyed by the metadata table's id (`MetadataTable.tableId`). Each verb folds in the record action it needs. A write also needs the right to edit the host record and change the covered field, which the app checks from the record and `restrictedFields`. A metadata table absent from the map is one the caller may not write.",
            "additionalProperties": {
              "$ref": "#/components/schemas/MyMetadataGrant"
            }
          },
          "principalId": {
            "type": "string",
            "description": "The id the workspace's data knows the caller by: what `created_by`, `updated_by` and `owned_by` hold for their writes, and what the `currentUser` filter value stands for. Equal to the caller's user id unless they were imported as a pending member before joining, in which case it is that member's id."
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Effective action grants in the current workspace"
          },
          "roleIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Additional roles assigned beyond the base membership role"
          },
          "groupIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The caller's own workspace group ids — what transition-actor gates and record shares match against"
          },
          "privateTables": {
            "type": "object",
            "description": "Per-table record scopes for tables with private visibility (absent table = unrestricted)",
            "additionalProperties": {
              "type": "object",
              "required": [
                "read",
                "update",
                "delete"
              ],
              "properties": {
                "read": {
                  "$ref": "#/components/schemas/RecordAccessScope"
                },
                "update": {
                  "$ref": "#/components/schemas/RecordAccessScope"
                },
                "delete": {
                  "$ref": "#/components/schemas/RecordAccessScope"
                }
              }
            }
          },
          "restrictedFields": {
            "type": "object",
            "description": "Field names the caller may not read/update, per table id",
            "additionalProperties": {
              "type": "object",
              "required": [
                "read",
                "update"
              ],
              "properties": {
                "read": {
                  "description": "Column names on this table whose values are withheld from the caller: they never leave the data layer, so they are absent from record reads, exports and query results.",
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "update": {
                  "description": "Column names on this table the caller may see but not change; a write that sets one is refused.",
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "create": {
                  "description": "Column names on this table the caller may not set when creating a record; a create body naming one is refused.",
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "queryUnrestricted": {
            "type": "boolean",
            "description": "Whether the caller's record visibility is restricted on no table at all. Raw SQL is gated per statement, so a false value does not close the query endpoints: a statement that reads a table the caller is restricted on is refused by name, and every other statement runs. A client shows the caveat on SQL affordances when this is false."
          }
        }
      },
      "AccessChangeSet": {
        "type": "object",
        "description": "A set of edits to the access document, previewed and published together against the version it was written on.",
        "required": [
          "baseVersion",
          "changes"
        ],
        "properties": {
          "baseVersion": {
            "type": "integer",
            "minimum": 0,
            "description": "The published version the edits were written against; a publish on a later version is rebased and previewed again."
          },
          "changes": {
            "type": "array",
            "description": "The edits, each setting one part of the document (a cell, a role's header, a section's declarations, the tests) to its new value. Each is checked by the server's validator, which explains a malformed one in a sentence.",
            "items": {
              "type": "object",
              "description": "One edit of the access document."
            }
          }
        }
      },
      "AccessRoleRef": {
        "type": "object",
        "description": "A role, named across the workspace's section and the sections of installed parts.",
        "required": [
          "section",
          "key"
        ],
        "properties": {
          "section": {
            "type": "string",
            "description": "The section that carries the role, \"workspace\" or a part's install id."
          },
          "key": {
            "type": "string",
            "description": "The role's key within that section."
          }
        }
      },
      "AccessValidationIssue": {
        "type": "object",
        "description": "A reason the access document cannot be published as it stands.",
        "required": [
          "code",
          "at",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "A stable code for the refusal, for a client that groups or links them."
          },
          "at": {
            "type": "string",
            "description": "Where in the document the refusal points, as a path a client can highlight."
          },
          "message": {
            "type": "string",
            "description": "The refusal in a sentence naming the role, the table and the field."
          }
        }
      },
      "AccessPathFound": {
        "type": "object",
        "description": "A path to more access the document opens and no acknowledgement covers: an edit one role may make that gives a role more, or reads out a field the writer cannot see.",
        "required": [
          "path",
          "previous",
          "sentence",
          "at"
        ],
        "properties": {
          "path": {
            "type": "object",
            "description": "The acknowledgement that would accept the path, to add to the section as it is."
          },
          "previous": {
            "type": [
              "object",
              "null"
            ],
            "description": "The acknowledgement given when the path gave less, when that is why it is asked again; null for a path never acknowledged."
          },
          "sentence": {
            "type": "string",
            "description": "Why it is a path, in a sentence."
          },
          "at": {
            "type": "string",
            "description": "The writing cell, as a path in the document."
          }
        }
      },
      "AccessReviewCheck": {
        "type": "object",
        "description": "Something a reviewer should look at before publishing; it never blocks a publish.",
        "required": [
          "code",
          "sentence",
          "roles",
          "table"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "What the check found: NO_EFFECT_ALL_MEMBERS, WIDER_THROUGH_ROLE, GRANTS_BY_EXCLUSION, BUILDERS_ONLY_TABLE, CONDITIONAL_FIELD, REQUIRED_HIDDEN_FROM_ADDER or CONSTRAINT_OVER_HIDDEN_FIELD. More may be added; a client shows the sentence for one it does not know."
          },
          "sentence": {
            "type": "string",
            "description": "What the check found, in a sentence."
          },
          "roles": {
            "type": "array",
            "description": "The roles it is about.",
            "items": {
              "$ref": "#/components/schemas/AccessRoleRef"
            }
          },
          "table": {
            "type": "string",
            "description": "The table it is about."
          },
          "field": {
            "type": "string",
            "description": "The field it is about, when it is about one."
          }
        }
      },
      "AccessTestResult": {
        "type": "object",
        "description": "The outcome of one saved access test on the previewed document.",
        "required": [
          "name",
          "passed",
          "sentence"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The test's name."
          },
          "passed": {
            "type": "boolean",
            "description": "Whether the document gives the answer the test expects; a failing test blocks a publish."
          },
          "sentence": {
            "type": "string",
            "description": "What the document answers, in a sentence."
          }
        }
      },
      "AccessChangeSetPreview": {
        "type": "object",
        "description": "What publishing a change set would do: the edits in sentences, what would refuse it, what it would open, and the digests a publish names so that what is applied is what was previewed.",
        "required": [
          "baseVersion",
          "changeSetDigest",
          "definitionDigests",
          "sentences",
          "issues",
          "paths",
          "checks",
          "tests",
          "grantsNew"
        ],
        "properties": {
          "baseVersion": {
            "type": "integer",
            "minimum": 0,
            "description": "The published version the preview was computed on; a publish names it."
          },
          "changeSetDigest": {
            "type": "string",
            "description": "The digest of the change set previewed; a publish names it, so a draft edited after its preview is not applied."
          },
          "definitionDigests": {
            "type": "object",
            "description": "The digest of each field definition the changed rules read, by \"table.field\"; a publish that finds one changed is treated as a publish on a later version.",
            "additionalProperties": {
              "type": "string",
              "description": "The digest of the definitions the field is computed from, itself included."
            }
          },
          "sentences": {
            "type": "object",
            "description": "The edits in sentences, grouped by what they do.",
            "required": [
              "removesAccess",
              "addsAccess",
              "changesRecords",
              "other"
            ],
            "properties": {
              "removesAccess": {
                "type": "array",
                "description": "Edits after which some holders can do less.",
                "items": {
                  "type": "string",
                  "description": "One edit."
                }
              },
              "addsAccess": {
                "type": "array",
                "description": "Edits after which some holders can do more.",
                "items": {
                  "type": "string",
                  "description": "One edit."
                }
              },
              "changesRecords": {
                "type": "array",
                "description": "Edits that change which records a rule reaches, neither wider nor narrower as a whole.",
                "items": {
                  "type": "string",
                  "description": "One edit."
                }
              },
              "other": {
                "type": "array",
                "description": "Edits that change no one's access, such as a renamed role or a new test.",
                "items": {
                  "type": "string",
                  "description": "One edit."
                }
              }
            }
          },
          "issues": {
            "type": "array",
            "description": "What would refuse the publish; empty when it may go ahead.",
            "items": {
              "$ref": "#/components/schemas/AccessValidationIssue"
            }
          },
          "paths": {
            "type": "array",
            "description": "Paths to more access that must be acknowledged before the publish.",
            "items": {
              "$ref": "#/components/schemas/AccessPathFound"
            }
          },
          "checks": {
            "type": "array",
            "description": "Things a reviewer should look at; they never block.",
            "items": {
              "$ref": "#/components/schemas/AccessReviewCheck"
            }
          },
          "tests": {
            "type": "array",
            "description": "The saved access tests, run on the previewed document.",
            "items": {
              "$ref": "#/components/schemas/AccessTestResult"
            }
          },
          "grantsNew": {
            "type": "boolean",
            "description": "Whether any holder could do something after the publish they cannot do now."
          }
        }
      },
      "AccessCatalogueReach": {
        "type": "string",
        "enum": [
          "all",
          "some",
          "none"
        ],
        "description": "How much of a table one verb reaches: every record, some records (which ones depends on the record), or none."
      },
      "AccessCatalogueFieldRule": {
        "type": "string",
        "enum": [
          "read",
          "write",
          "varies"
        ],
        "description": "What one field allows on the records a person views: read on each, write on each they may edit, or one or the other depending on the record."
      },
      "AccessCatalogueTable": {
        "type": "object",
        "description": "One table of a person's catalogue: how far each verb reaches and what each field they can see allows. A field hidden on every record is absent.",
        "required": [
          "table",
          "verbs",
          "fields",
          "addFields"
        ],
        "properties": {
          "table": {
            "type": "string",
            "description": "The table's name."
          },
          "verbs": {
            "type": "object",
            "description": "How far each verb reaches.",
            "required": [
              "read",
              "create",
              "update",
              "delete"
            ],
            "properties": {
              "read": {
                "$ref": "#/components/schemas/AccessCatalogueReach"
              },
              "create": {
                "$ref": "#/components/schemas/AccessCatalogueReach"
              },
              "update": {
                "$ref": "#/components/schemas/AccessCatalogueReach"
              },
              "delete": {
                "$ref": "#/components/schemas/AccessCatalogueReach"
              }
            }
          },
          "fields": {
            "type": "object",
            "description": "The fields they can see on some record, by name; a client shows a field only when it is here.",
            "additionalProperties": {
              "$ref": "#/components/schemas/AccessCatalogueFieldRule"
            }
          },
          "addFields": {
            "type": "array",
            "description": "The fields they may set on some record they add, so a form can offer them even with no view of the table.",
            "items": {
              "type": "string",
              "description": "A field name."
            }
          }
        }
      },
      "AccessCatalogue": {
        "type": "object",
        "description": "What one person may do with each table they reach at all, as far as it can be said without a record in hand.",
        "required": [
          "tables"
        ],
        "properties": {
          "tables": {
            "type": "array",
            "description": "The tables they reach, a verb or a field of them; a table they reach in no way is absent.",
            "items": {
              "$ref": "#/components/schemas/AccessCatalogueTable"
            }
          }
        }
      },
      "MyAccess": {
        "type": "object",
        "description": "The caller's own access, with no rule text.",
        "required": [
          "kind",
          "actions",
          "tables"
        ],
        "properties": {
          "kind": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "member",
              "builder",
              "administrator",
              null
            ],
            "description": "The caller's kind of membership; null for a holder who is not a member."
          },
          "actions": {
            "type": "array",
            "description": "The workspace actions the caller holds.",
            "items": {
              "type": "string",
              "description": "An action name."
            }
          },
          "tables": {
            "type": "array",
            "description": "Per table, how far each verb reaches and what each field allows.",
            "items": {
              "$ref": "#/components/schemas/AccessCatalogueTable"
            }
          }
        }
      },
      "RecordAccess": {
        "type": "object",
        "description": "What the caller may do with one record, sent with a record only where the caller's catalogue says a verb or a field varies.",
        "required": [
          "update",
          "delete",
          "discuss",
          "hidden",
          "readOnly"
        ],
        "properties": {
          "update": {
            "type": "boolean",
            "description": "Whether the caller may edit the record."
          },
          "delete": {
            "type": "boolean",
            "description": "Whether the caller may delete the record."
          },
          "discuss": {
            "type": "boolean",
            "description": "Whether the caller may comment on the record."
          },
          "hidden": {
            "type": "array",
            "description": "Fields of the caller's catalogue hidden on this record.",
            "items": {
              "type": "string",
              "description": "A field name."
            }
          },
          "readOnly": {
            "type": "array",
            "description": "Fields the caller may write on some records but only read on this one.",
            "items": {
              "type": "string",
              "description": "A field name."
            }
          }
        }
      },
      "RecordAccessScope": {
        "type": "string",
        "enum": [
          "none",
          "own",
          "group",
          "workspace"
        ],
        "description": "Record-visibility scope (ordered; each level includes those below)"
      },
      "FieldVisibility": {
        "type": "string",
        "enum": [
          "private",
          "workspace"
        ],
        "description": "A field's visibility: 'workspace' = every reader of the record sees the field; 'private' = the field is hidden, and refused on write, except for baseline admins and roles holding a grant on it (see `RoleFieldGrant`). A field with a grant row on any role is governed the same way whatever this setting says. Changing it requires the permissions:manage action."
      },
      "RecordVisibility": {
        "type": "string",
        "enum": [
          "private",
          "workspace",
          "restricted"
        ],
        "description": "Default record visibility for a table: 'workspace' = all members with record access see every record, until a row rule governs the table; 'private' = members see only records they own plus whatever role scopes, row rules or shares additionally grant; 'restricted' = governed from creation on every verb with no ownership floor, so nobody but a baseline admin reaches a record unless a row rule on one of their roles grants it (the table to create locked and open rule by rule). Setting anything but 'workspace' requires the permissions:manage action."
      },
      "Role": {
        "description": "A workspace role, as returned by the `/roles` endpoints: a named bundle of action grants and record-visibility scopes that principals are assigned. Four system roles are seeded per workspace; the rest are custom.",
        "type": "object",
        "required": [
          "id",
          "name",
          "isSystem",
          "actions",
          "recordScopes",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the role, used when assigning it to principals.",
            "type": "string"
          },
          "name": {
            "description": "Display name of the role, unique within the workspace.",
            "type": "string"
          },
          "description": {
            "description": "Free-text note on what the role is for; null when none was given.",
            "type": [
              "string",
              "null"
            ]
          },
          "isSystem": {
            "type": "boolean",
            "description": "System roles are seeded per workspace and cannot be modified or deleted"
          },
          "systemKey": {
            "description": "Which seeded system role this is: `owner`, `admin`, `member` or `reader`. Null for custom roles.",
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "owner",
              "admin",
              "member",
              "reader",
              null
            ]
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Action grants (namespaced, e.g. records:read); effective permissions are the union across a principal's roles"
          },
          "recordScopes": {
            "description": "How far record access reaches for each operation (read, create, update, delete), each a `RecordAccessScope`.",
            "type": "object",
            "required": [
              "read",
              "create",
              "update",
              "delete"
            ],
            "properties": {
              "read": {
                "$ref": "#/components/schemas/RecordAccessScope"
              },
              "create": {
                "$ref": "#/components/schemas/RecordAccessScope"
              },
              "update": {
                "$ref": "#/components/schemas/RecordAccessScope"
              },
              "delete": {
                "$ref": "#/components/schemas/RecordAccessScope"
              }
            }
          },
          "assignmentCount": {
            "type": "integer",
            "description": "Number of principals assigned this role"
          },
          "createdAt": {
            "description": "When the role was created, ISO-8601 UTC (workspace creation for system roles).",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the role's name, description, grants or scopes last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateRoleRequest": {
        "description": "Definition of a new workspace-defined role: its name, the actions it grants and, optionally, the record scope each record verb resolves to. Request body of `POST /roles`.",
        "type": "object",
        "required": [
          "name",
          "actions"
        ],
        "properties": {
          "name": {
            "description": "Display name of the role, shown wherever roles are assigned. 1 to 255 characters.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "description": {
            "description": "What the role is for, for administrators; null or omitted for none.",
            "type": [
              "string",
              "null"
            ]
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Action grants from the shared catalog"
          },
          "recordScopes": {
            "description": "The row scope the role grants for each record verb (`read`, `create`, `update`, `delete`) on private tables. A verb left out grants no scope of its own; the action grants in `actions` still apply.",
            "type": "object",
            "properties": {
              "read": {
                "$ref": "#/components/schemas/RecordAccessScope"
              },
              "create": {
                "$ref": "#/components/schemas/RecordAccessScope"
              },
              "update": {
                "$ref": "#/components/schemas/RecordAccessScope"
              },
              "delete": {
                "$ref": "#/components/schemas/RecordAccessScope"
              }
            }
          }
        }
      },
      "UpdateRoleRequest": {
        "description": "Request body of `PATCH /roles/{roleId}`: the parts of a custom role to change. Only the fields sent are updated; `actions` and `recordScopes` are replaced as a whole when present. System roles cannot be modified.",
        "type": "object",
        "properties": {
          "name": {
            "description": "New display name of the role; omit to keep the current one.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "description": {
            "description": "New description; null clears it, omit to keep the current one.",
            "type": [
              "string",
              "null"
            ]
          },
          "actions": {
            "description": "The role's full new set of action grants (namespaced, e.g. `records:read`), replacing the current set. Unknown actions are refused, as are actions the caller does not hold themselves.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "recordScopes": {
            "description": "The role's new record-access scope per verb (read, create, update, delete), replacing the current scopes.",
            "type": "object",
            "properties": {
              "read": {
                "$ref": "#/components/schemas/RecordAccessScope"
              },
              "create": {
                "$ref": "#/components/schemas/RecordAccessScope"
              },
              "update": {
                "$ref": "#/components/schemas/RecordAccessScope"
              },
              "delete": {
                "$ref": "#/components/schemas/RecordAccessScope"
              }
            }
          }
        }
      },
      "RoleAssignment": {
        "description": "One grant of a role to a principal in the workspace. Exactly one of `userId`, `apiTokenId` or `automationId` is set, naming a workspace member, an API token or a flow; the matching `*Name` (and `userEmail`) fields are resolved for display. Returned by `GET`/`POST /roles/{roleId}/assignments`.",
        "type": "object",
        "required": [
          "id",
          "roleId",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the assignment row itself (not of the role or the principal); use it to revoke this grant.",
            "type": "string"
          },
          "roleId": {
            "description": "The role granted by this assignment.",
            "type": "string"
          },
          "userId": {
            "description": "The member's user id when the principal is a workspace member; null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "userName": {
            "description": "The member's display name, resolved at read time; null when the principal is not a user or the account no longer resolves.",
            "type": [
              "string",
              "null"
            ]
          },
          "userEmail": {
            "description": "The member's email address, resolved at read time; null when the principal is not a user.",
            "type": [
              "string",
              "null"
            ]
          },
          "apiTokenId": {
            "description": "The API token's id when the principal is an API token; null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "apiTokenName": {
            "description": "The API token's label, resolved at read time; null when the principal is not a token.",
            "type": [
              "string",
              "null"
            ]
          },
          "automationId": {
            "description": "The flow's id when the principal is a flow (`automation` is the legacy wire name for flow); null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "automationName": {
            "description": "The flow's name, resolved at read time; null when the principal is not a flow.",
            "type": [
              "string",
              "null"
            ]
          },
          "agentId": {
            "description": "The agent's id when the principal is an agent (`Agent`); null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "agentName": {
            "description": "The agent's name, resolved at read time; null when the principal is not an agent.",
            "type": [
              "string",
              "null"
            ]
          },
          "assignedBy": {
            "description": "User id of whoever created the assignment. Null when it was not made by a user or was not recorded.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the role was granted, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RoleFieldGrant": {
        "type": "object",
        "description": "One role's grant on one governed field. A field is governed when it is marked `private` or when any role carries a grant row on it; a governed field is hidden from a principal unless some role they hold carries a grant with `canRead` (baseline admins always see it), `canUpdate` additionally allows patching it, and `canCreate` setting it on insert. A field with no grant row is simply not granted — all flags false never persists as a row.",
        "required": [
          "roleId",
          "fieldId",
          "tableId",
          "canRead",
          "canUpdate",
          "canCreate"
        ],
        "properties": {
          "roleId": {
            "description": "The role that carries the grant; principals holding this role see the field.",
            "type": "string"
          },
          "fieldId": {
            "description": "The private field the grant applies to.",
            "type": "string"
          },
          "tableId": {
            "type": "string",
            "description": "The table the field belongs to, so a client can group grants without a per-field lookup."
          },
          "canRead": {
            "description": "Whether principals with this role may read the field's value. Always true on a persisted grant, since a both-false grant is never stored.",
            "type": "boolean"
          },
          "canUpdate": {
            "description": "Whether principals with this role may also write the field. Implies read.",
            "type": "boolean"
          },
          "canCreate": {
            "description": "Whether principals with this role may set the field when creating a record. A grant saved before this bit existed reports its `canUpdate` value here.",
            "type": "boolean"
          }
        }
      },
      "AssignRoleRequest": {
        "type": "object",
        "description": "Exactly one of userId, apiTokenId, automationId or agentId must be provided",
        "properties": {
          "userId": {
            "type": "string",
            "description": "Assign to this workspace member"
          },
          "apiTokenId": {
            "type": "string",
            "description": "Assign to this API token"
          },
          "automationId": {
            "type": "string",
            "description": "Assign to this automation principal — since the flows engine replaced single-action automations, the id is a FLOW id (the principal axis and its column name carried over). Automation principals have no base role — their effective permissions come only from assigned roles — and the assigner may only attach roles whose action grants are a subset of the assigner's own effective actions (anti-escalation)."
          },
          "agentId": {
            "type": "string",
            "description": "Assign to this agent (`Agent`). The same anti-escalation rule as for a flow applies to the assigner, who needs `permissions:manage` here; an agent's own owner attaches the roles they hold through `POST /agents/{agentId}/roles` instead."
          }
        }
      },
      "ApprovalApprovers": {
        "type": "object",
        "description": "Who may decide one step of an approval route: listed members, the members of listed groups, and the people the record's own fields name. There is no delegation or out-of-office routing. At least one entry across the three lists is required. Membership is resolved LIVE on every use, never frozen: someone who leaves the workspace (or the named group) stops being an approver immediately, and someone added to the group afterwards can decide requests already in flight. The people `recordFields` names are the exception: they are read once, when a request is made, and held on that request.",
        "properties": {
          "userIds": {
            "description": "Workspace members who may decide the step, by user id (at most 25). Someone no longer an active member drops out of the list's effect immediately.",
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 25
          },
          "groupIds": {
            "description": "Groups whose current members may decide the step, by group id (at most 25). Membership is read at decision time, so the group's roster can change while a request is in flight.",
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 25
          },
          "recordFields": {
            "description": "Fields that hold the person who should decide, for the record a request is about (at most 5). Each is the name of a field of the rule's table that is a single reference to a workspace member (`owner`), or a single table reference of that table and such a field of the row it points at (`project.manager`): one hop and no further. Checked when the rule is saved. When a request is made, the fields are read from the record as it is stored before the proposed change, and the people they name are held on the request, so changing the field afterwards does not change who decides it. A field that names the requester names nobody for that request; if the step is left with no one who could decide, the request is refused when it is made. Being named grants nothing else: the person still needs `approvals:decide` and sight of the record. A pending change's own `steps` never carry this list, since the names have already been read. Only the `approvers` of a rule do.",
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z_][a-z0-9_]*(\\.[a-z_][a-z0-9_]*)?$"
            },
            "maxItems": 5
          }
        }
      },
      "ApprovalStep": {
        "type": "object",
        "description": "One stage of an approval route: who may decide it, how many of them must agree, and what happens if nobody does in time. A rule with a single `any` step is exactly the v1 behaviour.",
        "required": [
          "approvers",
          "policy",
          "onTimeout"
        ],
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 63,
            "description": "Label for this stage (\"Line manager\", \"Finance\"); display only."
          },
          "approvers": {
            "$ref": "#/components/schemas/ApprovalApprovers"
          },
          "policy": {
            "type": "string",
            "description": "How many of the step's approvers must approve before the route advances. `any` = one is enough; `all` = every approver who is live at the moment each decision lands; `quorum` = the `quorum` count. Open by contract — clients MUST tolerate values not yet listed. A DECLINE at any step terminates the whole request regardless of policy.",
            "example": "any"
          },
          "quorum": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 2,
            "maximum": 25,
            "description": "How many distinct approvers must approve when `policy` is `quorum`; null otherwise. Deliberately NOT lowered when the live approver set shrinks below it — a \"2 of 3\" step whose group loses two members stalls (and eventually times out) rather than silently becoming \"1 of 1\"."
          },
          "timeoutHours": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 8760,
            "description": "SLA for this step, measured from when it became current. Null = no per-step deadline (the request-level expiry still applies, and wins whenever it lands first)."
          },
          "onTimeout": {
            "type": "string",
            "description": "What happens when `timeoutHours` elapses with the step unsatisfied. `decline` terminates the request; `advance` passes the step over and moves to the next one — on the LAST step `advance` also declines, because approving with nobody having said yes would be an authorization bypass. Open by contract — clients MUST tolerate values not yet listed.",
            "example": "decline"
          }
        }
      },
      "ApprovalStepInput": {
        "type": "object",
        "description": "One stage of an approval route, as written by the client.",
        "required": [
          "approvers"
        ],
        "properties": {
          "name": {
            "description": "Optional label for the step, shown to requesters and approvers (\"Manager\", \"Finance\"). Null or empty leaves the step unnamed.",
            "type": [
              "string",
              "null"
            ],
            "maxLength": 63
          },
          "approvers": {
            "$ref": "#/components/schemas/ApprovalApprovers"
          },
          "policy": {
            "description": "How many of the step's approvers must approve before it is satisfied: `any` — one approval decides (the default); `all` — every approver who is still an active member must approve; `quorum` — the number given in `quorum`, which must then be supplied.",
            "type": "string",
            "enum": [
              "any",
              "all",
              "quorum"
            ],
            "default": "any"
          },
          "quorum": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 2,
            "maximum": 25,
            "description": "Required when policy is `quorum`; rejected otherwise."
          },
          "timeoutHours": {
            "description": "Hours the step may wait for a decision after it becomes current before `onTimeout` applies; up to one year. Null means no step deadline — only the request-level expiry ends it.",
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 8760
          },
          "onTimeout": {
            "description": "What happens when `timeoutHours` elapses with the step unsatisfied: `decline` (the default) declines the whole pending change; `advance` records a timeout and moves the request on to the next step, except on the last step, where it declines.",
            "type": "string",
            "enum": [
              "decline",
              "advance"
            ],
            "default": "decline"
          }
        }
      },
      "ApprovalRule": {
        "type": "object",
        "description": "What requires approval on one table, and who decides. A write whose WOULD-BE result matches an enabled rule's condition is rejected with 409 APPROVAL_REQUIRED instead of being applied.",
        "required": [
          "id",
          "tableId",
          "name",
          "enabled",
          "approvers",
          "appliesTo",
          "createdBy",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Server-assigned identifier of the rule; the `ruleId` the approval-rule endpoints take.",
            "type": "string"
          },
          "tableId": {
            "description": "The table whose writes the rule intercepts. Stable across table renames.",
            "type": "string"
          },
          "tableDisplayName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Convenience for list UIs; not part of the stored rule."
          },
          "name": {
            "description": "Human-readable name shown to requesters and approvers (it appears as `ruleName` on the pending changes it creates).",
            "type": "string"
          },
          "description": {
            "description": "Optional free text explaining why the rule exists; null when none was given.",
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "description": "Whether the rule is in force. A disabled rule is kept but intercepts nothing.",
            "type": "boolean"
          },
          "condition": {
            "description": "AutomationPredicate document (the restricted predicate AST — see @taskexchange/api-spec automationTypes), evaluated against the would-be result of the write: `record` = existing row merged with the proposed patch, `before` = the existing row. With `matchCurrent: true` the rule also matches when the existing row alone satisfies the conditions, so a threshold rule guards writes that move a record out of the range as well as into it. Null means the rule matches every write to the table. Validated by the backend; intentionally untyped here, exactly like Automation.trigger."
          },
          "approvers": {
            "$ref": "#/components/schemas/ApprovalApprovers",
            "description": "The FIRST step's approvers, always. Kept alongside `steps` so a single-step rule needs no route document and so this field is never a lie about who decides next."
          },
          "steps": {
            "type": "array",
            "description": "The ordered approval route. Always at least one entry: a rule saved with only `approvers` reads back as a single `any` step. A request freezes this route at creation, so editing a rule reshapes only FUTURE requests — an in-flight one keeps the route its requester was told about (approver membership inside those steps is still resolved live).",
            "items": {
              "$ref": "#/components/schemas/ApprovalStep"
            }
          },
          "appliesTo": {
            "type": "array",
            "description": "Which verbs the rule intercepts. Only [\"update\"] is accepted today — the pending-change model carries `kind` for create/delete, but those flows are not implemented.",
            "items": {
              "type": "string"
            },
            "example": [
              "update"
            ]
          },
          "createdBy": {
            "description": "Id of the user who created the rule.",
            "type": "string"
          },
          "createdAt": {
            "description": "When the rule was created, ISO-8601 UTC; set by the server.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the rule was last changed, ISO-8601 UTC; set by the server.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateApprovalRuleRequest": {
        "type": "object",
        "description": "Give either `steps` (an ordered route) or `approvers` (shorthand for a single `any` step). Exactly one is required; sending both is rejected rather than silently preferring one.",
        "required": [
          "tableId",
          "name"
        ],
        "properties": {
          "tableId": {
            "description": "The table the rule guards: writes to this table whose would-be result matches `condition` are held for approval. Must be a table in the caller's workspace.",
            "type": "string"
          },
          "name": {
            "description": "Short label for the rule, 1–63 characters, shown in the approvals UI and on the pending changes it creates (`ruleName`).",
            "type": "string",
            "minLength": 1,
            "maxLength": 63
          },
          "description": {
            "description": "Free-text explanation of what the rule is for, shown beside the name. Null or omitted for none.",
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "description": "Whether the rule intercepts writes from the moment it is created. Defaults to true; a disabled rule is stored but matches nothing until enabled.",
            "type": "boolean",
            "default": true
          },
          "condition": {
            "description": "AutomationPredicate document (backend-validated); null matches every write."
          },
          "approvers": {
            "$ref": "#/components/schemas/ApprovalApprovers"
          },
          "steps": {
            "description": "The ordered approval route, 1–10 steps, each naming its approvers and decision policy. Mutually exclusive with `approvers`. The route is frozen onto every pending change the rule creates.",
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/ApprovalStepInput"
            }
          },
          "appliesTo": {
            "description": "Which write verbs the rule intercepts. Only `update` is accepted today, and it is the default; proposed creates and deletes are not implemented.",
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "update"
              ]
            },
            "default": [
              "update"
            ]
          }
        }
      },
      "UpdateApprovalRuleRequest": {
        "type": "object",
        "description": "Partial update; omitted fields are unchanged. The table cannot be changed. `approvers` and `steps` both replace the whole route, so at most one of them may be sent. Requests already in flight keep the route they froze at creation.",
        "properties": {
          "name": {
            "description": "New name of the rule (1–63 characters), unique within the table.",
            "type": "string",
            "minLength": 1,
            "maxLength": 63
          },
          "description": {
            "description": "New free-text explanation of what the rule guards; null clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "description": "Whether the rule intercepts writes. Disabling stops new requests; requests already in flight are unaffected.",
            "type": "boolean"
          },
          "condition": {
            "description": "Replacement AutomationPredicate document; null matches every write."
          },
          "approvers": {
            "$ref": "#/components/schemas/ApprovalApprovers"
          },
          "steps": {
            "description": "Replacement approval route, 1–10 ordered steps; applies to future requests only. Mutually exclusive with `approvers`, which is shorthand for a single step.",
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/ApprovalStepInput"
            }
          },
          "appliesTo": {
            "description": "Which verbs the rule intercepts. Only `[\"update\"]` is accepted today.",
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "update"
              ]
            }
          }
        }
      },
      "PendingChangeFieldDiff": {
        "type": "object",
        "description": "One proposed field change, ready to render as a diff row. Present only for fields the VIEWER may read — see PendingChange.hiddenFieldCount.",
        "required": [
          "fieldName",
          "proposedValue"
        ],
        "properties": {
          "fieldName": {
            "description": "Name of the field the proposed change writes, as used in record `data`.",
            "type": "string"
          },
          "displayName": {
            "description": "The field's human label for the diff row. Null when the field no longer exists on the table.",
            "type": [
              "string",
              "null"
            ]
          },
          "currentValue": {
            "description": "The record's value right now (null when the record is gone). Left untyped: a field value is any JSON scalar or object the table's field types allow."
          },
          "proposedValue": {
            "description": "The value to be written, of the same shape as currentValue."
          },
          "baseValue": {
            "description": "The value at request time; differs from currentValue when the record moved on."
          },
          "conflicted": {
            "type": "boolean",
            "description": "True when another write changed this field since the request was made. Applying with conflicts fails the pending change rather than silently clobbering the newer value."
          }
        }
      },
      "PendingChangeDecision": {
        "type": "object",
        "description": "One approver's recorded decision on one step. A step needing several approvals accumulates several of these; the row is written before the tally is re-counted, so a double-click cannot count twice. Which step it belongs to is the step it is nested under.",
        "required": [
          "decision",
          "decidedBy",
          "decidedAt"
        ],
        "properties": {
          "decision": {
            "type": "string",
            "description": "`approve` or `decline`. Open by contract — clients MUST tolerate values not yet listed.",
            "example": "approve"
          },
          "decidedBy": {
            "description": "User id of the approver who made the decision. A step that timed out is recorded with the sentinel `system` in place of a user id.",
            "type": "string"
          },
          "decidedByName": {
            "description": "Display name of the approver, resolved at read time. Null when the account no longer resolves or the decision was the server's (a timeout).",
            "type": [
              "string",
              "null"
            ]
          },
          "decidedAt": {
            "description": "When the decision was recorded, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "comment": {
            "description": "The approver's note, if they left one; for a timeout, the server's explanation of what happened. Null when none was given.",
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PendingChangeStepState": {
        "type": "object",
        "description": "One step of a request's FROZEN route together with its live tally — what the approvals UI renders as \"Step 2 of 3 · 1 of 2 approvals\".",
        "required": [
          "index",
          "policy",
          "required",
          "approved",
          "state",
          "isApprover",
          "decisions"
        ],
        "properties": {
          "index": {
            "description": "Position of the step in the frozen route, in route order; the first step is 0.",
            "type": "integer"
          },
          "name": {
            "description": "The step's display label from the rule (\"Line manager\", \"Finance\"); null when the rule gave it none.",
            "type": [
              "string",
              "null"
            ]
          },
          "policy": {
            "type": "string",
            "description": "Open by contract — see ApprovalStep.policy."
          },
          "required": {
            "type": "integer",
            "description": "How many approvals this step needs right now. For `all` this tracks the LIVE approver set, so it can move while the step is open; for `quorum` it is the configured count even when fewer approvers remain live (the step stalls rather than lowering its own bar)."
          },
          "approved": {
            "description": "How many approvals the step has collected so far; compare against `required`.",
            "type": "integer"
          },
          "state": {
            "type": "string",
            "description": "`waiting` (not reached yet), `current`, `approved`, `declined`, or `timed_out`. Open by contract — clients MUST tolerate values not yet listed.",
            "example": "current"
          },
          "deadlineAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When this step times out; null when it carries no SLA or is not current."
          },
          "isApprover": {
            "type": "boolean",
            "description": "Whether the READING principal is a live approver for this step."
          },
          "decisions": {
            "description": "Every decision recorded on this step so far, in the order they were made, including the comments approvers left.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PendingChangeDecision"
            }
          }
        }
      },
      "PendingChange": {
        "type": "object",
        "description": "A proposed mutation frozen at request time, awaiting a human decision. Field values are masked through the READING principal's own snapshot, so an approver may legitimately see fewer fields than the requester proposed (hiddenFieldCount says how many).",
        "required": [
          "id",
          "tableId",
          "kind",
          "status",
          "proposedData",
          "fields",
          "hiddenFieldCount",
          "requestedBy",
          "requestedAt",
          "isStale",
          "canDecide",
          "expiresAt",
          "currentStep",
          "steps"
        ],
        "properties": {
          "id": {
            "description": "Server-assigned identifier of the request; the `pendingChangeId` the decision and cancel endpoints take.",
            "type": "string"
          },
          "tableId": {
            "description": "The table of the record the proposed write targets. Stable across table renames.",
            "type": "string"
          },
          "tableDisplayName": {
            "description": "Current display name of that table, for list UIs; null if the table no longer exists.",
            "type": [
              "string",
              "null"
            ]
          },
          "itemId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null for a proposed create (not implemented in v1)."
          },
          "kind": {
            "type": "string",
            "x-known-values": "KnownPendingChangeKind",
            "description": "Lifecycle vocabulary (which verb was proposed): the values known to this version are enumerated by the KnownPendingChangeKind schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed (this set grows)."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownPendingChangeStatus",
            "description": "Lifecycle vocabulary: the values known to this version are enumerated by the KnownPendingChangeStatus schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed (this set grows). `failed` means the decision was approve but the apply was rejected (validation, permissions, or a conflicting concurrent write) — the decision and its outcome stay distinct."
          },
          "ruleId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The rule that forced this into review; null if that rule was since deleted."
          },
          "ruleName": {
            "description": "Name of the approval rule that forced the write into review, as it was when read; null when the rule has since been deleted.",
            "type": [
              "string",
              "null"
            ]
          },
          "proposedData": {
            "type": "object",
            "additionalProperties": true,
            "description": "The field→value patch, masked through the reading principal's snapshot."
          },
          "fields": {
            "type": "array",
            "description": "Per-field diff rows for the proposed (and viewer-readable) fields.",
            "items": {
              "$ref": "#/components/schemas/PendingChangeFieldDiff"
            }
          },
          "hiddenFieldCount": {
            "type": "integer",
            "description": "How many proposed fields the reading principal may NOT read. They are omitted from proposedData/fields entirely; an approver can still decline knowing only that N hidden fields would change."
          },
          "requestedBy": {
            "description": "Id of the principal whose write was intercepted and who is waiting on the decision.",
            "type": "string"
          },
          "requestedByName": {
            "description": "Display name of the requester, for approvers; null when the account no longer exists.",
            "type": [
              "string",
              "null"
            ]
          },
          "requestedAt": {
            "description": "When the write was intercepted and the request created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "requestReason": {
            "description": "The requester's explanation of the change, if they gave one; null otherwise. When `requestedVia` is `mcp` this may be the assistant's summary rather than the requester's own words.",
            "type": [
              "string",
              "null"
            ]
          },
          "requestedVia": {
            "type": [
              "string",
              "null"
            ],
            "description": "Which write surface made the request: `mcp` when an AI assistant asked on the requester's behalf (the MCP `request_record_approval` tool, or `POST /pending-changes` through the gateway); null for the app or a direct API call. Set by the server from the request's origin, never from the body. Provenance for approvers — the requester's own permissions capped the proposal either way, so `requestReason` may be the assistant's summary rather than the requester's words."
          },
          "currentStep": {
            "type": "integer",
            "description": "Zero-based index into `steps` of the step awaiting a decision."
          },
          "steps": {
            "type": "array",
            "description": "The frozen route with its live tally. Always at least one entry — a request made before multi-step routes existed reads back as a single `any` step.",
            "items": {
              "$ref": "#/components/schemas/PendingChangeStepState"
            }
          },
          "stepDeadlineAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the CURRENT step times out; null when it carries no SLA. The request-level `expiresAt` still applies and wins whenever it lands first."
          },
          "decidedBy": {
            "type": [
              "string",
              "null"
            ],
            "description": "The decision that TERMINATED the request (the final approval, or the decline that stopped it) — not every approver who signed off. The per-step tally is in `steps[].decisions`."
          },
          "decidedByName": {
            "description": "Display name of the person whose decision terminated the request; null while pending or when the account no longer exists.",
            "type": [
              "string",
              "null"
            ]
          },
          "decidedAt": {
            "description": "When the terminating decision was made, ISO-8601 UTC; null while the request is pending.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "decisionComment": {
            "description": "The comment the deciding approver attached, if any; null while pending or when none was given.",
            "type": [
              "string",
              "null"
            ]
          },
          "appliedAt": {
            "description": "When the approved change was actually written to the record, ISO-8601 UTC. Null while pending, when declined, or when the apply failed (see `applyError`).",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "applyError": {
            "description": "Why an approved change could not be applied (validation, permissions, a conflicting concurrent write, or the rule being deleted first), when `status` is `failed`; null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "baseUpdatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The record's updatedAt when the request was made (the optimistic-lock seed)."
          },
          "isStale": {
            "type": "boolean",
            "description": "The record changed since the request was made. Deciding a stale change requires acknowledgeStale — the approver must confirm they looked at the newer state."
          },
          "canDecide": {
            "type": "boolean",
            "description": "Whether the READING principal may decide this one: holds approvals:decide, is named by the rule, can see the row, and is not self-approving (unless the rule names them)."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "Pending changes auto-expire after the workspace's approval expiry window."
          }
        }
      },
      "CreatePendingChangeRequest": {
        "type": "object",
        "description": "Explicitly request approval for a change the write path rejected with 409 APPROVAL_REQUIRED. The proposal is capped by the REQUESTER's own snapshot — you cannot propose writing a field you could not write, or touching a row you cannot update.",
        "required": [
          "tableId",
          "itemId",
          "proposedData"
        ],
        "properties": {
          "tableId": {
            "description": "The table of the record whose write was refused with APPROVAL_REQUIRED.",
            "type": "string"
          },
          "itemId": {
            "description": "The record (an item is a record) the proposed patch applies to.",
            "type": "string"
          },
          "kind": {
            "description": "The verb awaiting approval. Only `update` exists today; create and delete flows are not implemented.",
            "type": "string",
            "enum": [
              "update"
            ],
            "default": "update"
          },
          "proposedData": {
            "type": "object",
            "additionalProperties": true,
            "description": "The field→value patch to apply once approved. A reference to workspace users may be written as the `CurrentUserValue` token: it is stored as the requester's id when the request is made, so it still names the requester when an approver applies it."
          },
          "requestReason": {
            "description": "Free-text justification shown to the approvers alongside the diff. Optional; at most 2000 characters.",
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          }
        }
      },
      "DecidePendingChangeRequest": {
        "description": "Request body of `POST /pending-changes/{pendingChangeId}/decision`: one approver's verdict on the current step of a pending change, with an optional comment.",
        "type": "object",
        "required": [
          "decision"
        ],
        "properties": {
          "decision": {
            "description": "`approve` records an approval toward the current step's tally (the change is applied once the whole route completes); `decline` stops the request at this step.",
            "type": "string",
            "enum": [
              "approve",
              "decline"
            ]
          },
          "comment": {
            "description": "Optional note recorded with the decision and shown to the requester and the other approvers, up to 2000 characters.",
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "acknowledgeStale": {
            "type": "boolean",
            "default": false,
            "description": "Required when the record changed since the request was made (PendingChange.isStale). Without it a stale change returns 409 STALE_APPROVAL so an approver cannot rubber-stamp a diff they did not actually see."
          }
        }
      },
      "ApprovalRequiredError": {
        "type": "object",
        "description": "409 body when an approval rule intercepts a record write. The write did NOT happen; POST /pending-changes with the same patch to request it.",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "description": "Human-readable explanation naming the rule, suitable to show the user.",
            "type": "string"
          },
          "code": {
            "description": "Machine-readable code; always `APPROVAL_REQUIRED` for this shape, distinguishing it from other 409s such as `STALE_RECORD`.",
            "type": "string",
            "enum": [
              "APPROVAL_REQUIRED"
            ]
          },
          "ruleId": {
            "description": "Id of the approval rule that intercepted the write.",
            "type": "string"
          },
          "ruleName": {
            "description": "Display name of the approval rule that intercepted the write.",
            "type": "string"
          }
        }
      },
      "ApprovalEventPayload": {
        "type": "object",
        "description": "Payload for ApprovalRequested / ApprovalDecided events. Delivered only to the participants (requester and the rule's resolved approvers) — never workspace-wide.",
        "required": [
          "pendingChangeId",
          "tableId",
          "status"
        ],
        "properties": {
          "pendingChangeId": {
            "description": "Id of the pending change (approval request) the event is about; fetch it through `GET /pending-changes/{pendingChangeId}` for the full request.",
            "type": "string"
          },
          "tableId": {
            "description": "Table of the record under review.",
            "type": "string"
          },
          "itemId": {
            "description": "The record under review. Null when the proposed change would create a record that does not exist yet.",
            "type": [
              "string",
              "null"
            ]
          },
          "ruleId": {
            "description": "The approval rule that forced the change into review; null when that rule has since been deleted.",
            "type": [
              "string",
              "null"
            ]
          },
          "requestedBy": {
            "description": "User id of the person who proposed the change.",
            "type": "string"
          },
          "decidedBy": {
            "description": "User id of the approver whose decision settled the request. Null on `ApprovalRequested` and while the request is still open.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownPendingChangeStatus",
            "description": "Lifecycle vocabulary: the values known to this version are enumerated by the KnownPendingChangeStatus schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed (this set grows)."
          }
        }
      },
      "WorkspaceSecret": {
        "type": "object",
        "description": "Metadata for a stored workspace secret. Values are WRITE-ONLY — they are never returned by any endpoint. Reference secrets from webhook flows as {{secrets.NAME}} (URL, headers, body) or `input.env` in sandboxed code.",
        "required": [
          "id",
          "name",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the secret row; the API addresses secrets by `name`, not by this id.",
            "type": "string"
          },
          "name": {
            "description": "UPPER_SNAKE_CASE name, unique within the workspace, that flows reference as `{{secrets.NAME}}` and the `/secrets/{name}` endpoints address.",
            "type": "string"
          },
          "createdBy": {
            "description": "Id of the user who created the secret; null when unknown.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the secret was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the value was last rotated through `PUT /secrets/{name}` (or the secret created), ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateWorkspaceSecretRequest": {
        "description": "A new workspace secret: a name flows refer to and the value, which is stored encrypted and never returned. Request body of `POST /secrets`.",
        "type": "object",
        "required": [
          "name",
          "value"
        ],
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_]{0,63}$",
            "description": "UPPER_SNAKE_CASE identifier, unique per workspace."
          },
          "value": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4096,
            "description": "The secret value; stored encrypted, never returned."
          }
        }
      },
      "RotateWorkspaceSecretRequest": {
        "description": "Request body of `PUT /secrets/{name}`: the replacement value for an existing workspace secret. Flows read the new value on their next run.",
        "type": "object",
        "required": [
          "value"
        ],
        "properties": {
          "value": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4096,
            "description": "The replacement value; stored encrypted, never returned."
          }
        }
      },
      "KnownWebhookEventKind": {
        "description": "The webhook event kinds this version can deliver, named by `WebhookSubscription.events` and `WebhookEvent.event` through `x-known-values`. `record.created`, `record.updated` and `record.deleted` follow the record writes that fire flow record-event triggers (imports write in bulk and deliver no per-record events); `record.restored` is a record brought back from the recycle bin; `record.stage_changed` is an update that moved a stage field to a new value; `comment.created` is a new comment on a record of the table. Open vocabulary: clients tolerate kinds not listed here.",
        "type": "string",
        "enum": [
          "record.created",
          "record.updated",
          "record.deleted",
          "record.restored",
          "record.stage_changed",
          "comment.created"
        ]
      },
      "WebhookEventKindInput": {
        "description": "An event kind a subscription asks for. Request-side, so the list is closed: the server refuses a kind it cannot deliver.",
        "type": "string",
        "enum": [
          "record.created",
          "record.updated",
          "record.deleted",
          "record.restored",
          "record.stage_changed",
          "comment.created"
        ]
      },
      "KnownWebhookChangeSource": {
        "description": "Who or what made the change a webhook event reports, named by `WebhookChangeSource.kind` through `x-known-values`. `user`: a person in the app; `api_token`: a script holding an API token; `mcp`: an AI assistant connected over MCP; `automation`: a flow or a table automation rule; `system`: the platform applying a write nobody made directly, such as an approved change. Open vocabulary: clients tolerate sources not listed here.",
        "type": "string",
        "enum": [
          "user",
          "api_token",
          "mcp",
          "automation",
          "system"
        ]
      },
      "KnownWebhookDeliveryStatus": {
        "description": "The delivery statuses this version knows, named by `WebhookDelivery.status` through `x-known-values`. `pending`: waiting for its first attempt or a retry; `succeeded`: the endpoint answered 2xx; `failed`: retries ran out, or the endpoint answered a 4xx other than 408 or 429, or the URL was refused; `skipped`: nothing was sent, see `skipReason`. Open vocabulary: treat a status not listed here as non-terminal and show it verbatim.",
        "type": "string",
        "enum": [
          "pending",
          "succeeded",
          "failed",
          "skipped"
        ]
      },
      "KnownWebhookSkipReason": {
        "description": "Why a webhook delivery was skipped, named by `WebhookDelivery.skipReason` through `x-known-values`. `permission`: the subscription's creator can no longer read the record, the field or the table; `no_visible_change`: an update changed only fields the creator may not read or the allow-list leaves out; `subscription_disabled`: the subscription was switched off before the delivery was sent. Open vocabulary: clients tolerate reasons not listed here.",
        "type": "string",
        "enum": [
          "permission",
          "no_visible_change",
          "subscription_disabled"
        ]
      },
      "WarehouseExportTableSelection": {
        "description": "One table a warehouse export sends, and the fields it leaves out.",
        "type": "object",
        "required": [
          "tableId"
        ],
        "additionalProperties": false,
        "properties": {
          "tableId": {
            "description": "The table to send. Records of SQL views are not exported.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "excludedFieldIds": {
            "description": "Fields of this table never sent, for example a salary. Omitted or empty, every field is sent.",
            "type": "array",
            "maxItems": 500,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        }
      },
      "WarehouseExportTable": {
        "description": "One table a warehouse export sends, as stored.",
        "type": "object",
        "required": [
          "tableId",
          "excludedFieldIds"
        ],
        "properties": {
          "tableId": {
            "description": "The table sent.",
            "type": "string"
          },
          "excludedFieldIds": {
            "description": "Fields of this table never sent. An id whose field has since been deleted excludes nothing.",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "CustomerS3DestinationInput": {
        "description": "Send to the customer's own S3 bucket, written by assuming their IAM role. The external id for the role's trust policy is generated by the server and returned with the export.",
        "type": "object",
        "required": [
          "kind",
          "bucket",
          "region",
          "roleArn"
        ],
        "additionalProperties": false,
        "properties": {
          "kind": {
            "description": "Which kind of destination this is.",
            "type": "string",
            "enum": [
              "customerS3"
            ]
          },
          "bucket": {
            "description": "The bucket's name.",
            "type": "string",
            "minLength": 3,
            "maxLength": 63,
            "pattern": "^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$"
          },
          "prefix": {
            "description": "Key prefix every file is written under, without a leading slash, for example `tessule/sales/`. Empty writes at the bucket's root.",
            "type": "string",
            "maxLength": 512,
            "pattern": "^(?!/)[A-Za-z0-9!_.*'()/-]*$"
          },
          "region": {
            "description": "The bucket's AWS region, for example `eu-west-2`.",
            "type": "string",
            "maxLength": 32,
            "pattern": "^[a-z]{2}(-[a-z]+)+-[0-9]$"
          },
          "roleArn": {
            "description": "The IAM role the export assumes to write. Its trust policy must allow this platform's account with the export's `externalId`, and its policy `s3:PutObject` on the bucket and prefix.",
            "type": "string",
            "maxLength": 2048,
            "pattern": "^arn:aws[a-z-]*:iam::[0-9]{12}:role/[A-Za-z0-9+=,.@_/-]{1,512}$"
          }
        }
      },
      "HostedDestinationInput": {
        "description": "Send to a prefix this platform hosts, which the warehouse reads with its own principal (for Snowflake, the storage integration's IAM user). The reader can be set now or later, once the warehouse side exists.",
        "type": "object",
        "required": [
          "kind"
        ],
        "additionalProperties": false,
        "properties": {
          "kind": {
            "description": "Which kind of destination this is.",
            "type": "string",
            "enum": [
              "hosted"
            ]
          },
          "readerPrincipalArn": {
            "$ref": "#/components/schemas/WarehouseReaderPrincipalArn"
          },
          "readerExternalId": {
            "$ref": "#/components/schemas/WarehouseReaderExternalId"
          }
        }
      },
      "WarehouseReaderPrincipalArn": {
        "description": "The IAM user or role the warehouse reads a hosted destination with. For Snowflake, the `STORAGE_AWS_IAM_USER_ARN` from `DESC INTEGRATION`.",
        "type": "string",
        "maxLength": 2048,
        "pattern": "^arn:aws[a-z-]*:iam::[0-9]{12}:(user|role)/[A-Za-z0-9+=,.@_/-]{1,512}$"
      },
      "WarehouseReaderExternalId": {
        "description": "The external id the warehouse presents when reading a hosted destination. For Snowflake, the `STORAGE_AWS_EXTERNAL_ID` from `DESC INTEGRATION`.",
        "type": "string",
        "minLength": 2,
        "maxLength": 256,
        "pattern": "^[A-Za-z0-9+=,.@:/_-]+$"
      },
      "WarehouseExportDestinationInput": {
        "description": "Where a new warehouse export sends its files.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/CustomerS3DestinationInput"
          },
          {
            "$ref": "#/components/schemas/HostedDestinationInput"
          }
        ]
      },
      "CustomerS3Destination": {
        "description": "A destination in the customer's own S3 bucket, as stored.",
        "type": "object",
        "required": [
          "kind",
          "bucket",
          "prefix",
          "region",
          "roleArn",
          "externalId"
        ],
        "properties": {
          "kind": {
            "description": "Which kind of destination this is.",
            "type": "string",
            "enum": [
              "customerS3"
            ]
          },
          "bucket": {
            "description": "The bucket's name.",
            "type": "string"
          },
          "prefix": {
            "description": "Key prefix every file is written under; empty for the bucket's root.",
            "type": "string"
          },
          "region": {
            "description": "The bucket's AWS region.",
            "type": "string"
          },
          "roleArn": {
            "description": "The IAM role the export assumes to write.",
            "type": "string"
          },
          "externalId": {
            "description": "The external id this platform presents when assuming `roleArn`. Put it in the role's trust policy as the `sts:ExternalId` condition, so no one else can make the platform write with that role.",
            "type": "string"
          }
        }
      },
      "HostedDestination": {
        "description": "A destination hosted by this platform, as stored.",
        "type": "object",
        "required": [
          "kind",
          "location",
          "readerRoleArn",
          "readerPrincipalArn",
          "readerExternalId",
          "readerRoleReady",
          "readerRoleError"
        ],
        "properties": {
          "kind": {
            "description": "Which kind of destination this is.",
            "type": "string",
            "enum": [
              "hosted"
            ]
          },
          "location": {
            "description": "The S3 URL the files are written under, for the warehouse's external stage. Files are kept for 30 days after they are written. Null when this deployment does not host exports.",
            "type": [
              "string",
              "null"
            ]
          },
          "readerRoleArn": {
            "description": "The IAM role the warehouse assumes to read `location`; for Snowflake, the storage integration's `STORAGE_AWS_ROLE_ARN`. It exists once `readerPrincipalArn` and `readerExternalId` are both set and `readerRoleReady` is true. Null when this deployment does not host exports.",
            "type": [
              "string",
              "null"
            ]
          },
          "readerPrincipalArn": {
            "description": "The warehouse principal allowed to assume the reader role; null until set.",
            "type": [
              "string",
              "null"
            ]
          },
          "readerExternalId": {
            "description": "The external id that principal presents; null until set.",
            "type": [
              "string",
              "null"
            ]
          },
          "readerRoleReady": {
            "description": "Whether the reader role exists and trusts the current `readerPrincipalArn` with `readerExternalId`. False until both are set, and for a few minutes after either changes.",
            "type": "boolean"
          },
          "readerRoleError": {
            "description": "Why the reader role could not be set up as asked (for example, AWS refused the principal as not existing); null when it is set up or still being set up.",
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "WarehouseExportDestination": {
        "description": "Where a warehouse export sends its files, as stored.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/CustomerS3Destination"
          },
          {
            "$ref": "#/components/schemas/HostedDestination"
          }
        ]
      },
      "WarehouseExport": {
        "description": "A warehouse export: the tables it sends, where, and how often. Each run writes the changes since the last one as Parquet; the first writes a full snapshot.",
        "type": "object",
        "required": [
          "id",
          "name",
          "destination",
          "tables",
          "intervalMinutes",
          "enabled",
          "lastRunAt",
          "lastSuccessAt",
          "lastError",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "The export's id.",
            "type": "string"
          },
          "name": {
            "description": "A name to tell exports apart, unique in the workspace.",
            "type": "string"
          },
          "destination": {
            "$ref": "#/components/schemas/WarehouseExportDestination"
          },
          "tables": {
            "description": "The tables the export sends, each with the fields it leaves out.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WarehouseExportTable"
            }
          },
          "intervalMinutes": {
            "description": "Minutes between two runs.",
            "type": "integer"
          },
          "enabled": {
            "description": "Whether the export runs. Off, it keeps its configuration and position.",
            "type": "boolean"
          },
          "lastRunAt": {
            "description": "When the export last ran, ISO-8601 UTC; null before its first run.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastSuccessAt": {
            "description": "When a run last finished writing everything, ISO-8601 UTC; null until one has.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastError": {
            "description": "Why the last run failed, in words an admin can act on (for example the destination refusing the role); null when it succeeded. A failing export retries with a growing delay.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the export was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the export was last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WarehouseExportAvailability": {
        "description": "What the organization's plan and settings allow for warehouse exports.",
        "type": "object",
        "required": [
          "enabled",
          "availableOnPlan",
          "minIntervalMinutes",
          "maxPerWorkspace",
          "platformAwsAccountId",
          "hostedAvailable"
        ],
        "properties": {
          "enabled": {
            "description": "Whether exports can be created and switched on now: the plan includes the feature and the organization has switched it on.",
            "type": "boolean"
          },
          "availableOnPlan": {
            "description": "Whether the organization's plan includes warehouse export. When it does and `enabled` is false, an organization owner or admin can switch it on in organization settings.",
            "type": "boolean"
          },
          "minIntervalMinutes": {
            "description": "The shortest interval between runs the plan allows.",
            "type": "integer"
          },
          "maxPerWorkspace": {
            "description": "How many exports the plan allows in one workspace.",
            "type": "integer"
          },
          "platformAwsAccountId": {
            "description": "The AWS account this platform writes from. A `customerS3` destination's IAM role trusts this account as its principal, on the condition that the export's `externalId` is presented. Null when this deployment does not say, in which case support provides it.",
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9]{12}$"
          },
          "hostedAvailable": {
            "description": "Whether a new export may use a `hosted` destination: the plan includes hosted storage and this deployment provides it. Files at a hosted destination are kept for 30 days.",
            "type": "boolean"
          }
        }
      },
      "WarehouseExportList": {
        "description": "Response of `GET /warehouse-exports`.",
        "type": "object",
        "required": [
          "exports",
          "availability"
        ],
        "properties": {
          "exports": {
            "description": "Every export in the workspace, oldest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WarehouseExport"
            }
          },
          "availability": {
            "$ref": "#/components/schemas/WarehouseExportAvailability"
          }
        }
      },
      "CreateWarehouseExportRequest": {
        "description": "Request body of `POST /warehouse-exports`.",
        "type": "object",
        "required": [
          "name",
          "destination",
          "tables",
          "intervalMinutes"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "description": "A name to tell exports apart, unique in the workspace.",
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "destination": {
            "$ref": "#/components/schemas/WarehouseExportDestinationInput"
          },
          "tables": {
            "description": "The tables to send, each named once.",
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "items": {
              "$ref": "#/components/schemas/WarehouseExportTableSelection"
            }
          },
          "intervalMinutes": {
            "description": "Minutes between two runs, at least the plan's minimum (`availability.minIntervalMinutes`).",
            "type": "integer",
            "minimum": 5,
            "maximum": 10080
          },
          "enabled": {
            "description": "Whether the export runs. Defaults to true.",
            "type": "boolean"
          }
        }
      },
      "UpdateWarehouseExportRequest": {
        "description": "Request body of `PATCH /warehouse-exports/{exportId}`. A property left out keeps its value; `tables` replaces the whole list.",
        "type": "object",
        "minProperties": 1,
        "additionalProperties": false,
        "properties": {
          "name": {
            "description": "A new name, unique in the workspace.",
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "tables": {
            "description": "The tables to send from now on, each named once.",
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "items": {
              "$ref": "#/components/schemas/WarehouseExportTableSelection"
            }
          },
          "intervalMinutes": {
            "description": "Minutes between two runs, at least the plan's minimum.",
            "type": "integer",
            "minimum": 5,
            "maximum": 10080
          },
          "enabled": {
            "description": "Whether the export runs.",
            "type": "boolean"
          },
          "readerPrincipalArn": {
            "$ref": "#/components/schemas/WarehouseReaderPrincipalArn"
          },
          "readerExternalId": {
            "$ref": "#/components/schemas/WarehouseReaderExternalId"
          }
        }
      },
      "WebhookSubscription": {
        "type": "object",
        "description": "An outbound webhook subscription: a URL that receives a signed `WebhookEvent` for chosen events on one table. It runs as its creator, so deliveries carry only what the creator can read. The signing secret is never part of this object.",
        "required": [
          "id",
          "url",
          "tableId",
          "events",
          "fieldAllowList",
          "enabled",
          "createdBy",
          "consecutiveFailures",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "The subscription's id; it is sent with every delivery as `subscriptionId`.",
            "type": "string"
          },
          "url": {
            "description": "The HTTPS endpoint deliveries are POSTed to.",
            "type": "string"
          },
          "description": {
            "description": "A note saying what the subscription is for (for example \"Zapier — new deals\").",
            "type": [
              "string",
              "null"
            ]
          },
          "tableId": {
            "description": "The table whose events are delivered.",
            "type": "string"
          },
          "events": {
            "description": "The event kinds delivered to the URL.",
            "type": "array",
            "items": {
              "type": "string",
              "x-known-values": "KnownWebhookEventKind",
              "description": "An event kind. Open vocabulary: clients tolerate kinds this build does not know."
            }
          },
          "fieldAllowList": {
            "description": "When set, deliveries carry only these fields (by field name) in `record.data` and `previous`, and an update that changes none of them is not delivered. Null delivers every field the creator can read.",
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "enabled": {
            "description": "Whether events are being delivered. False after someone switched it off, or after it failed continuously for three days (`disabledReason` says which).",
            "type": "boolean"
          },
          "disabledReason": {
            "description": "`manual` when a person switched the subscription off, `auto_failures` when it was switched off after three days of failed deliveries; null while it is on.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdBy": {
            "description": "The user the subscription runs as — its creator, or whoever last moved its URL to a new address; deliveries carry what this user can read.",
            "type": "string"
          },
          "consecutiveFailures": {
            "description": "Deliveries that have failed in a row since the last success.",
            "type": "integer"
          },
          "failingSince": {
            "description": "When the current run of failures began, ISO-8601 UTC; null after a success. Three days of failure switch the subscription off.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastDeliveryAt": {
            "description": "When a delivery last succeeded, ISO-8601 UTC; null before the first success.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastError": {
            "description": "The most recent delivery error, or why an event was dropped (for example the daily delivery limit); null once a delivery succeeds.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the subscription was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the subscription was last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookSubscriptionWithSecret": {
        "description": "A subscription together with its signing secret. Returned only when the subscription is created and when its secret is rotated; the secret cannot be read back afterwards.",
        "allOf": [
          {
            "$ref": "#/components/schemas/WebhookSubscription"
          },
          {
            "type": "object",
            "required": [
              "secret"
            ],
            "properties": {
              "secret": {
                "description": "The signing secret. Each delivery carries `X-CRM-Signature: sha256=<hex>`, the HMAC-SHA256 under this secret of `<X-CRM-Timestamp>.<raw body>`.",
                "type": "string"
              }
            }
          }
        ]
      },
      "CreateWebhookSubscriptionRequest": {
        "description": "Request body of `POST /webhooks`.",
        "type": "object",
        "required": [
          "url",
          "tableId",
          "events"
        ],
        "properties": {
          "url": {
            "description": "The HTTPS endpoint to POST deliveries to.",
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "description": {
            "description": "A note saying what the subscription is for.",
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          },
          "tableId": {
            "description": "The table whose events to deliver.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "events": {
            "description": "The event kinds to deliver; at least one.",
            "type": "array",
            "minItems": 1,
            "maxItems": 6,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/WebhookEventKindInput"
            }
          },
          "fieldAllowList": {
            "description": "Field names to deliver; omit or send null to deliver every field the creator can read. Each name must be a field of the table.",
            "type": [
              "array",
              "null"
            ],
            "maxItems": 500,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        }
      },
      "UpdateWebhookSubscriptionRequest": {
        "description": "Request body of `PATCH /webhooks/{webhookId}`. Only the properties present are changed; the table cannot be changed — create a new subscription instead.",
        "type": "object",
        "properties": {
          "url": {
            "description": "A new HTTPS endpoint; checked the same way as at creation.",
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "description": {
            "description": "A new note, or null to clear it.",
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          },
          "events": {
            "description": "The new set of event kinds; at least one.",
            "type": "array",
            "minItems": 1,
            "maxItems": 6,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/WebhookEventKindInput"
            }
          },
          "fieldAllowList": {
            "description": "The new field allow-list, or null to deliver every readable field.",
            "type": [
              "array",
              "null"
            ],
            "maxItems": 500,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          },
          "enabled": {
            "description": "Switch delivery on or off. Switching on clears the failure streak and any automatic disable.",
            "type": "boolean"
          }
        }
      },
      "WebhookChangeSource": {
        "type": "object",
        "description": "Who or what made the change a webhook event reports.",
        "required": [
          "kind",
          "isBulkEdit",
          "userId"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "x-known-values": "KnownWebhookChangeSource",
            "description": "The kind of writer (`user`, `api_token`, `mcp`, `automation`, `system`). Open vocabulary: clients tolerate kinds this build does not know."
          },
          "isBulkEdit": {
            "description": "True when the change was one record of a bulk create, update or delete (a selection edited in one go), so a receiver can batch or quieten its reaction.",
            "type": "boolean"
          },
          "userId": {
            "description": "The user who made the change, or on whose behalf a token, flow or approval made it; null when the platform cannot name one.",
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "WebhookStageChange": {
        "type": "object",
        "description": "The stage move a `record.stage_changed` event reports.",
        "required": [
          "fieldName",
          "from",
          "to"
        ],
        "properties": {
          "fieldName": {
            "description": "The stage field that moved.",
            "type": "string"
          },
          "from": {
            "description": "The stage the record left; null when the field was empty.",
            "type": [
              "string",
              "null"
            ]
          },
          "to": {
            "description": "The stage the record entered; null when the field was cleared.",
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "description": "The JSON body POSTed to a webhook subscription's URL. It is signed: verify `X-CRM-Signature` (HMAC-SHA256 of `<X-CRM-Timestamp>.<raw body>` under the subscription's secret) before trusting it, and use `id` (also the `X-CRM-Delivery` and `Idempotency-Key` headers) to ignore a repeat. Deliveries can arrive out of order; `sequence` restores the order. Record values are those the subscription's creator can read, narrowed to its field allow-list.",
        "required": [
          "id",
          "event",
          "occurredAt",
          "sequence",
          "subscriptionId",
          "tableId",
          "recordId",
          "record",
          "previous",
          "changeSource"
        ],
        "properties": {
          "id": {
            "description": "The delivery's id, the same on every retry and redelivery of this event; equal to the `X-CRM-Delivery` and `Idempotency-Key` headers.",
            "type": "string"
          },
          "event": {
            "type": "string",
            "x-known-values": "KnownWebhookEventKind",
            "description": "What happened (for example `record.updated`). Open vocabulary: clients tolerate kinds this build does not know."
          },
          "occurredAt": {
            "description": "When the change happened, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "sequence": {
            "description": "Position of this event among the subscription's events: strictly increasing per subscription, so a receiver can order events and spot a gap.",
            "type": "integer",
            "format": "int64"
          },
          "subscriptionId": {
            "description": "The subscription this delivery belongs to.",
            "type": "string"
          },
          "tableId": {
            "description": "The table the record belongs to.",
            "type": "string"
          },
          "recordId": {
            "description": "The record the event is about.",
            "type": "string"
          },
          "record": {
            "description": "The record as it is after the change (as it was just before deletion, for `record.deleted`), with only the fields the creator can read and the allow-list keeps. Null for `comment.created`.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/TableItem"
              },
              {
                "type": "null"
              }
            ]
          },
          "previous": {
            "description": "For `record.updated` and `record.stage_changed`, the earlier value of each field the change altered (readable and allowed fields only), keyed by field name. Null for the other events.",
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {}
          },
          "stage": {
            "description": "The stage move, for `record.stage_changed`; null for every other event.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/WebhookStageChange"
              },
              {
                "type": "null"
              }
            ]
          },
          "comment": {
            "description": "The new comment, for `comment.created`; null for every other event.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/RecordComment"
              },
              {
                "type": "null"
              }
            ]
          },
          "changeSource": {
            "$ref": "#/components/schemas/WebhookChangeSource"
          }
        }
      },
      "WebhookDelivery": {
        "type": "object",
        "description": "One event's delivery to a subscription: its status, attempts and the endpoint's last answer. An entry in the delivery log of `GET /webhooks/{webhookId}/deliveries`.",
        "required": [
          "id",
          "subscriptionId",
          "event",
          "sequence",
          "recordId",
          "status",
          "attempts",
          "occurredAt",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "The delivery's id — the `X-CRM-Delivery` header and `WebhookEvent.id`.",
            "type": "string"
          },
          "subscriptionId": {
            "description": "The subscription the delivery belongs to.",
            "type": "string"
          },
          "event": {
            "type": "string",
            "x-known-values": "KnownWebhookEventKind",
            "description": "The event kind delivered. Open vocabulary: clients tolerate kinds this build does not know."
          },
          "sequence": {
            "description": "The event's position in the subscription's sequence (`WebhookEvent.sequence`).",
            "type": "integer",
            "format": "int64"
          },
          "recordId": {
            "description": "The record the event is about.",
            "type": "string"
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownWebhookDeliveryStatus",
            "description": "Where the delivery stands. Open vocabulary: clients tolerate a status this build does not know (show it verbatim, treat it as non-terminal)."
          },
          "skipReason": {
            "type": [
              "string",
              "null"
            ],
            "x-known-values": "KnownWebhookSkipReason",
            "description": "Why nothing was sent, for a `skipped` delivery; null otherwise. Open vocabulary: clients tolerate reasons this build does not know."
          },
          "attempts": {
            "description": "How many times sending has been tried.",
            "type": "integer"
          },
          "lastStatusCode": {
            "description": "The HTTP status the endpoint last answered; null before any answer.",
            "type": [
              "integer",
              "null"
            ]
          },
          "lastError": {
            "description": "Why the last attempt failed; null after a success or before any attempt.",
            "type": [
              "string",
              "null"
            ]
          },
          "nextAttemptAt": {
            "description": "When the next attempt is due, for a `pending` delivery; null otherwise.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "payload": {
            "description": "The body last signed and sent; null before the first attempt, when skipped, and for anyone but the user it was built for (the subscription's `createdBy` at send time).",
            "anyOf": [
              {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              {
                "type": "null"
              }
            ]
          },
          "occurredAt": {
            "description": "When the change the event reports happened, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "deliveredAt": {
            "description": "When the delivery finished (succeeded, failed or skipped); null while pending.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "description": "When the delivery was queued, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the delivery last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookDeliveryList": {
        "type": "object",
        "description": "One page of a subscription's delivery log, newest first.",
        "required": [
          "deliveries",
          "nextBefore"
        ],
        "properties": {
          "deliveries": {
            "description": "The deliveries on this page.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookDelivery"
            }
          },
          "nextBefore": {
            "description": "Pass as `before` to read the next (older) page; null when this page is the last.",
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          }
        }
      },
      "IntegrationConnection": {
        "type": "object",
        "description": "A configured marketing-platform account. The credential is WRITE-ONLY — stored encrypted with the same cipher as workspace secrets and never returned by any endpoint.",
        "required": [
          "id",
          "provider",
          "name",
          "status",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Server-assigned identifier of the connection; the `connectionId` the update, delete and test endpoints take and that audience syncs reference.",
            "type": "string"
          },
          "provider": {
            "type": "string",
            "x-known-values": "KnownIntegrationProvider",
            "description": "Open vocabulary — clients must tolerate a provider they do not know. A provider the server does not recognise is treated as unusable rather than guessed at."
          },
          "name": {
            "type": "string",
            "description": "Workspace-chosen label, unique per workspace."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownIntegrationConnectionStatus",
            "description": "Whether the credential has been proven against the provider. Open vocabulary — clients must tolerate a status they do not know and render it as neutral rather than assuming failure."
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ],
            "description": "Provider-reported failure from the last test or sync run."
          },
          "lastCheckedAt": {
            "description": "When the credential was last tested against the provider, ISO-8601 UTC. Null until the first test, and reset to null when the credential is replaced.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdBy": {
            "description": "Id of the user who created the connection; null when that account no longer exists.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the connection was created, ISO-8601 UTC; set by the server.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the connection's name, credential or status last changed, ISO-8601 UTC; set by the server.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateIntegrationConnectionRequest": {
        "description": "Request body of `POST /integrations/connections`: connects a marketing provider account by its API key under a name of the caller's choosing. The credential is verified and stored encrypted; it is never returned.",
        "type": "object",
        "required": [
          "provider",
          "name",
          "credential"
        ],
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "klaviyo",
              "mailchimp",
              "omnisend"
            ],
            "description": "Request-side enums stay closed — an unknown provider is a client bug."
          },
          "name": {
            "description": "Label the caller gives this connection so it can be told from other accounts of the same provider (\"Marketing Klaviyo\", \"EU list\"). Display only; the provider never sees it.",
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "credential": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4096,
            "description": "The provider API key (Klaviyo private key, Mailchimp API key including its datacenter suffix, or Omnisend API key). Stored encrypted; never returned."
          }
        }
      },
      "UpdateIntegrationConnectionRequest": {
        "type": "object",
        "description": "Rename, and/or rotate the credential. Both fields optional.",
        "properties": {
          "name": {
            "description": "New workspace-facing label, 1–100 characters; must stay unique within the workspace.",
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "credential": {
            "description": "Replacement API key or token for the provider, up to 4096 characters. Stored encrypted and never returned by any endpoint; send it only when rotating.",
            "type": "string",
            "minLength": 1,
            "maxLength": 4096
          }
        }
      },
      "IntegrationConnectionTestResult": {
        "description": "Response of `POST /integrations/connections/{connectionId}/test`: whether the stored credentials still reach the provider, and which provider account they belong to.",
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "description": "True when the connection's credentials authenticated against the provider just now; false means the connection needs reconnecting, see `message`.",
            "type": "boolean"
          },
          "accountLabel": {
            "type": [
              "string",
              "null"
            ],
            "description": "Provider-side account identifier, so the user can confirm they connected the right one."
          },
          "message": {
            "type": [
              "string",
              "null"
            ],
            "description": "Failure detail when ok is false. Provider text, never credential material."
          }
        }
      },
      "RemoteAudience": {
        "type": "object",
        "description": "A list/audience/segment that exists on the provider side.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "description": "The provider's own identifier of the list/audience; send it as `remoteAudienceId` when configuring a sync.",
            "type": "string"
          },
          "name": {
            "description": "The list's name as it appears in the provider's UI.",
            "type": "string"
          },
          "memberCount": {
            "description": "Number of contacts in the list as reported by the provider; null when the provider does not report one.",
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "AudienceAttributeMapping": {
        "type": "object",
        "description": "One workspace field pushed onto the provider profile as a named property.",
        "required": [
          "fieldName",
          "remoteProperty"
        ],
        "properties": {
          "fieldName": {
            "type": "string",
            "description": "Column of the source table/view."
          },
          "remoteProperty": {
            "type": "string",
            "description": "Provider-side property name (Klaviyo profile attribute, Mailchimp merge field tag, Omnisend custom property)."
          }
        }
      },
      "AudienceSync": {
        "description": "One table or SQL view activated as an audience on a connected marketing platform, with the state of its most recent run. Returned by the audience-sync list, create and update endpoints under `/integrations/audience-syncs`.",
        "type": "object",
        "required": [
          "id",
          "connectionId",
          "provider",
          "sourceTableId",
          "emailFieldName",
          "remoteAudienceId",
          "attributeMapping",
          "enabled",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Server-assigned identifier of the sync; the `syncId` the update and delete endpoints take.",
            "type": "string"
          },
          "connectionId": {
            "description": "The `IntegrationConnection` whose credential the sync pushes through.",
            "type": "string"
          },
          "provider": {
            "description": "Provider key of that connection (e.g. the marketing platform), copied here so a list can be rendered without loading connections. Open vocabulary (`KnownIntegrationProvider` lists the known values); clients must tolerate a provider they do not know.",
            "type": "string",
            "x-known-values": "KnownIntegrationProvider"
          },
          "sourceTableId": {
            "type": "string",
            "description": "A data table or SQL view — the audience definition."
          },
          "emailFieldName": {
            "type": "string",
            "description": "Column holding the email address — the identity key."
          },
          "remoteAudienceId": {
            "description": "Identifier of the list/audience on the provider's side that this sync feeds.",
            "type": "string"
          },
          "remoteAudienceName": {
            "description": "The provider-side list's display name as last known, for display only; null when it was not captured.",
            "type": [
              "string",
              "null"
            ]
          },
          "attributeMapping": {
            "description": "Which source columns are pushed as which provider profile attributes, beyond the email identity key.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AudienceAttributeMapping"
            }
          },
          "enabled": {
            "description": "Whether scheduled runs happen. A disabled sync keeps its configuration and ledger but makes no provider calls.",
            "type": "boolean"
          },
          "lastRunAt": {
            "description": "When the most recent run started, ISO-8601 UTC; null until the sync has run once.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastRunStatus": {
            "type": [
              "string",
              "null"
            ],
            "x-known-values": "KnownAudienceSyncRunStatus",
            "description": "Status of the most recent run. Open vocabulary — clients must tolerate a status they do not know rather than switching on it exhaustively."
          },
          "lastRunSummary": {
            "description": "Counts of what the most recent run did (added, changed, removed, unchanged, failed profiles); null until the sync has run once.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/AudienceSyncRunSummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastError": {
            "description": "Error message recorded on the most recent run; null when that run had none or the sync has not run yet.",
            "type": [
              "string",
              "null"
            ]
          },
          "memberCount": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Rows currently tracked in the sync ledger."
          },
          "createdAt": {
            "description": "When the sync was created, ISO-8601 UTC; set by the server.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the sync's configuration was last changed, ISO-8601 UTC; set by the server.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AudienceSyncRunSummary": {
        "type": "object",
        "description": "What the last run did. `removed` means removed from the provider's list — never a profile deletion and never an unsubscribe.",
        "required": [
          "added",
          "changed",
          "removed",
          "unchanged",
          "failed"
        ],
        "properties": {
          "added": {
            "description": "Profiles the run created on the provider's list because they matched the sync for the first time.",
            "type": "integer"
          },
          "changed": {
            "description": "Profiles already on the provider's list whose synced fields the run updated.",
            "type": "integer"
          },
          "removed": {
            "description": "Profiles the run took off the provider's list because they no longer match. Not a deletion and not an unsubscribe.",
            "type": "integer"
          },
          "unchanged": {
            "description": "Matching profiles the run found already up to date and left alone.",
            "type": "integer"
          },
          "failed": {
            "description": "Profiles the provider rejected or the run could not write; the rest of the run still completes.",
            "type": "integer"
          }
        }
      },
      "CreateAudienceSyncRequest": {
        "description": "Request body of `POST /integrations/audience-syncs`: define a sync that pushes the email addresses (and any mapped fields) of one table or SQL view's rows into a marketing-platform audience through an existing integration connection.",
        "type": "object",
        "required": [
          "connectionId",
          "sourceTableId",
          "emailFieldName",
          "remoteAudienceId"
        ],
        "properties": {
          "connectionId": {
            "description": "The integration connection (provider account plus stored credential) the sync pushes through. Must belong to the caller's workspace; it fixes the provider.",
            "type": "string"
          },
          "sourceTableId": {
            "description": "The table or SQL view whose rows define the audience: every row with a usable email address is a member.",
            "type": "string"
          },
          "emailFieldName": {
            "description": "Column of the source table or view that holds the email address — the identity key the provider matches profiles on.",
            "type": "string"
          },
          "remoteAudienceId": {
            "description": "The provider's own identifier for the list or audience to populate (a Klaviyo list id, a Mailchimp audience id, …), as the provider's API reports it.",
            "type": "string"
          },
          "remoteAudienceName": {
            "description": "Display name of that remote audience, stored so the sync list can label it without calling the provider. Optional.",
            "type": "string"
          },
          "attributeMapping": {
            "description": "Workspace columns to push onto each profile as named provider properties, in addition to the email. Omit for membership-only syncing.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AudienceAttributeMapping"
            }
          },
          "enabled": {
            "type": "boolean",
            "description": "Defaults to true."
          }
        }
      },
      "UpdateAudienceSyncRequest": {
        "description": "Request body of `PUT /integrations/audience-syncs/{syncId}`: changes an audience sync's source email field, target list, attribute mapping or on/off state. Only the supplied fields change; the connection and source table are fixed at creation.",
        "type": "object",
        "properties": {
          "emailFieldName": {
            "description": "Column of the source table whose value identifies the provider profile — the email each record is synced under. Records with an empty or invalid value are skipped.",
            "type": "string"
          },
          "remoteAudienceId": {
            "description": "Provider-side identifier of the list, audience or segment records are pushed into (Klaviyo list id, Mailchimp audience id, Omnisend list). Changing it does not remove people from the previous list.",
            "type": "string"
          },
          "remoteAudienceName": {
            "description": "Display name of the remote list as the provider calls it, stored so the UI can label the sync without another provider round-trip. Not used to address the list.",
            "type": "string"
          },
          "attributeMapping": {
            "description": "Full replacement of the field-to-property mapping: each entry pushes one source column onto the provider profile as a named property. Send the complete list; omit the key to leave the mapping as it is.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AudienceAttributeMapping"
            }
          },
          "enabled": {
            "description": "Whether the sync runs. False pauses it without deleting its ledger; provider-side membership is left as it is.",
            "type": "boolean"
          }
        }
      },
      "AudienceSyncRunAccepted": {
        "description": "Acknowledgement that an audience sync run was enqueued; the run itself proceeds asynchronously. Response (202) of `POST /integrations/audience-syncs/{syncId}/run`.",
        "type": "object",
        "required": [
          "runId"
        ],
        "properties": {
          "runId": {
            "description": "Identifier of the run that was enqueued; use it to find the run in the sync's run history once it has executed.",
            "type": "string"
          }
        }
      },
      "RecordShare": {
        "description": "One additive grant of view or edit access on a single record to a user or a group, over and above what their roles allow. Returned by `GET` and `POST /tables/{tableId}/items/{itemId}/shares`. Exactly one of `userId`/`groupId` is set.",
        "type": "object",
        "required": [
          "id",
          "tableId",
          "recordId",
          "accessLevel",
          "rowCause",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the share row, used to revoke it via `DELETE .../shares/{shareId}`.",
            "type": "string"
          },
          "tableId": {
            "description": "The table of the shared record.",
            "type": "string"
          },
          "recordId": {
            "description": "The record this share grants access to.",
            "type": "string"
          },
          "userId": {
            "description": "The user granted access, when the share is to a user. Null for a group share.",
            "type": [
              "string",
              "null"
            ]
          },
          "userName": {
            "description": "Display name of `userId`, resolved for convenience. Null for a group share or when the user is no longer known.",
            "type": [
              "string",
              "null"
            ]
          },
          "groupId": {
            "description": "The group granted access, when the share is to a group. Null for a user share.",
            "type": [
              "string",
              "null"
            ]
          },
          "groupName": {
            "description": "Display name of `groupId`, resolved for convenience. Null for a user share or when the group is no longer known.",
            "type": [
              "string",
              "null"
            ]
          },
          "accessLevel": {
            "description": "What the share grants on the record: `view` to read it, `edit` to read and update it. Additive to the principal's role scope; never below it.",
            "type": "string",
            "enum": [
              "view",
              "edit"
            ]
          },
          "rowCause": {
            "type": "string",
            "description": "Why this share exists (e.g. 'manual')"
          },
          "reason": {
            "description": "Free-text note the sharer gave for the grant, shown alongside it. Null when none was given.",
            "type": [
              "string",
              "null"
            ]
          },
          "sharedBy": {
            "description": "Id of the user who created the share. Null when that user has since been deleted.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the share was granted, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PushSubscription": {
        "description": "A browser Web Push subscription as returned by `PushManager.subscribe()`, sent in `PushSubscribeRequest.subscription` so the server can deliver notifications to this browser.",
        "type": "object",
        "required": [
          "endpoint",
          "keys"
        ],
        "properties": {
          "endpoint": {
            "type": "string",
            "format": "uri",
            "description": "The push service URL endpoint"
          },
          "expirationTime": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Time in milliseconds until the subscription expires"
          },
          "keys": {
            "description": "The subscription's encryption keys (`p256dh` public key and `auth` secret) exactly as the browser reports them; the server needs both to encrypt pushes.",
            "type": "object",
            "required": [
              "p256dh",
              "auth"
            ],
            "properties": {
              "p256dh": {
                "type": "string",
                "description": "User public key for encryption"
              },
              "auth": {
                "type": "string",
                "description": "Auth secret for encryption"
              }
            }
          }
        }
      },
      "PushSubscribeRequest": {
        "description": "Request body of `POST /push/subscribe`: registers this browser's Web Push subscription so notifications can be delivered to it when the app is closed. Re-posting an existing endpoint refreshes it.",
        "type": "object",
        "required": [
          "subscription"
        ],
        "properties": {
          "subscription": {
            "$ref": "#/components/schemas/PushSubscription"
          }
        }
      },
      "PushSubscribeResponse": {
        "description": "Acknowledgement of a Web Push subscription change. Response of `POST /push/subscribe` and `DELETE /push/unsubscribe`.",
        "type": "object",
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "description": "`true` on a successful change; failures use an error status instead.",
            "type": "boolean"
          },
          "message": {
            "description": "Human-readable outcome: `Subscription created`, `Subscription updated` (an existing endpoint rebound to the caller) or `Subscription removed`.",
            "type": "string"
          }
        }
      },
      "VapidPublicKeyResponse": {
        "description": "Response of `GET /push/vapid-public-key`: the server's VAPID public key a browser passes as `applicationServerKey` when subscribing to Web Push.",
        "type": "object",
        "required": [
          "publicKey"
        ],
        "properties": {
          "publicKey": {
            "type": "string",
            "description": "VAPID public key for push subscription"
          }
        }
      },
      "QueryVariableType": {
        "type": "string",
        "description": "Kind of a template variable:\n- text / number: free-form scalar, substituted as an escaped literal\n- select: single choice from options (dropdown)\n- multiselect: multiple choices; substituted as a parenthesized list\n  for use with IN, e.g. `WHERE status IN {{status}}`\n- daterange: a from/to pair referenced as {{name.from}} / {{name.to}};\n  value is either a relative preset (resolved at run time) or explicit\n  bounds. `from` is inclusive, `to` is exclusive.\n",
        "enum": [
          "text",
          "number",
          "select",
          "multiselect",
          "daterange"
        ]
      },
      "QueryVariableOption": {
        "description": "One static choice of a `select` or `multiselect` query variable. Item of `QueryVariableDef.options`.",
        "type": "object",
        "required": [
          "value"
        ],
        "properties": {
          "value": {
            "description": "The value substituted for the variable in the SQL when this option is chosen; also the display text when `label` is absent.",
            "type": "string"
          },
          "label": {
            "type": "string",
            "description": "Display label (defaults to the value)"
          }
        }
      },
      "QueryDateRangeValue": {
        "type": "object",
        "description": "Value for a daterange variable. Either a relative `preset` token\n(e.g. last_month, this_quarter — resolved to concrete bounds when the\nquery runs, so saved defaults stay relative), or explicit `from`/`to`\nbounds (ISO date or date-time strings). `from` is inclusive and `to`\nis exclusive; either bound may be omitted for an open-ended range.\nWhen `preset` is set it takes precedence over from/to.\n",
        "properties": {
          "preset": {
            "type": "string",
            "description": "Relative range token, e.g. last_month, this_quarter, last_7_days"
          },
          "from": {
            "type": "string",
            "description": "Inclusive lower bound (ISO date or date-time)"
          },
          "to": {
            "type": "string",
            "description": "Exclusive upper bound (ISO date or date-time)"
          }
        }
      },
      "QueryVariableValue": {
        "description": "A value supplied for a template variable. Strings and numbers render as\nescaped SQL literals; an array renders as a parenthesized IN list; a\ndate-range object is referenced via {{name.from}} / {{name.to}}.\nOmit the variable entirely (or send an empty array) to leave it unset —\nunset variables mean \"All\": [[ ... ]] optional blocks referencing them\nare dropped from the SQL.\n",
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/schemas/QueryDateRangeValue"
          }
        ]
      },
      "QueryVariableValues": {
        "type": "object",
        "description": "Map of variable name → value. Omitted variables are unset (\"All\").",
        "additionalProperties": {
          "$ref": "#/components/schemas/QueryVariableValue"
        }
      },
      "QueryVariableDef": {
        "type": "object",
        "description": "Declares a template variable used by a saved query (or a chart's\ncustomSql), driving the value controls shown in the UI.\n",
        "required": [
          "name",
          "type"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Placeholder name referenced as {{name}} in the SQL",
            "pattern": "^[A-Za-z_][A-Za-z0-9_]*$",
            "maxLength": 64
          },
          "label": {
            "type": "string",
            "maxLength": 255,
            "description": "Display label (defaults to the name)"
          },
          "type": {
            "$ref": "#/components/schemas/QueryVariableType"
          },
          "options": {
            "type": "array",
            "description": "Static options for select/multiselect",
            "items": {
              "$ref": "#/components/schemas/QueryVariableOption"
            }
          },
          "optionsQuery": {
            "type": "string",
            "description": "SQL that produces the options for select/multiselect (alternative\nto static options). The first column supplies option values; the\nsecond column, when present, supplies display labels.\n"
          },
          "includeAll": {
            "type": "boolean",
            "description": "select/multiselect — offer an \"All\" choice that leaves the variable unset"
          },
          "defaultValue": {
            "$ref": "#/components/schemas/QueryVariableValue"
          },
          "min": {
            "type": "number",
            "description": "number only — the smallest value the control offers (inclusive).\nMust be below `max` when both are set. A bound value outside\n[min, max] is clamped to the range wherever the definition is\nknown (the variable bar, `POST /queries/{queryId}/run`, scheduled\ndeliveries). A `slider` needs both `min` and `max`.\n"
          },
          "max": {
            "type": "number",
            "description": "number only — the largest value the control offers (inclusive). Must be above `min`."
          },
          "step": {
            "type": "number",
            "description": "number only — the increment a slider moves by and a stepper's\n+/- buttons add or subtract (default 1). Must be greater than 0.\n"
          },
          "control": {
            "$ref": "#/components/schemas/QueryVariableControl"
          }
        }
      },
      "QueryVariableControl": {
        "type": "string",
        "description": "How a `number` variable is presented in the variable bar. Absent means\n`input`, the free-form number field committed on blur or Enter.\n- input: free-form number field (today's behaviour)\n- slider: a range slider between `min` and `max` (both required) that\n  re-runs dependent tiles while it is dragged — the what-if control\n  for a growth or price assumption\n- stepper: a number field with − / + buttons that move by `step`,\n  kept within `min`/`max` when set\n",
        "enum": [
          "input",
          "slider",
          "stepper"
        ]
      },
      "ApiName": {
        "description": "The name a program uses for a saved query, a dashboard or a flow. It is set when the resource is created, is unique among resources of its kind in the workspace, and never changes afterwards: renaming the resource leaves it as it was. The run operations accept it wherever they take an id, so code written against one workspace also works against a copy of it, where the ids differ. It starts with a lowercase letter and holds lowercase letters, digits and underscores, up to 63 characters, and is never twelve hexadecimal characters, which is the shape of an id.",
        "type": "string",
        "pattern": "^[a-z][a-z0-9_]{0,62}$",
        "not": {
          "pattern": "^[0-9a-f]{12}$"
        },
        "examples": [
          "deals_by_stage"
        ]
      },
      "SavedQuery": {
        "description": "A named SQL query kept in the workspace, with the template variables it declares. Returned by the `/queries` endpoints; the SQL runs through the query endpoints and feeds charts, dashboards and scheduled deliveries.",
        "type": "object",
        "required": [
          "id",
          "apiName",
          "name",
          "sql",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the saved query, used by the `/queries/{queryId}` endpoints and referenced from charts, dashboard tiles and delivery schedules.",
            "type": "string"
          },
          "apiName": {
            "$ref": "#/components/schemas/ApiName"
          },
          "name": {
            "description": "Title the query is listed under. Need not be unique.",
            "type": "string"
          },
          "sql": {
            "description": "The read-only SQL as the author wrote it, with `{{name}}` placeholders for each entry of `variables`. Executed against the workspace's query schema under the caller's permissions.",
            "type": "string"
          },
          "variables": {
            "type": "array",
            "description": "Template variables declared for this query",
            "items": {
              "$ref": "#/components/schemas/QueryVariableDef"
            }
          },
          "createdBy": {
            "description": "User id of the author. Null when that account no longer exists or the query was created by the system.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the query was saved, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the query's name, SQL or variables last changed, ISO-8601 UTC; equals `createdAt` until the first edit.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateSavedQueryRequest": {
        "description": "Request body of `POST /queries`: the name, SQL text and optional variable definitions of a new saved query.",
        "type": "object",
        "required": [
          "name",
          "sql"
        ],
        "properties": {
          "name": {
            "description": "Display name of the saved query as it appears in the queries list and chart pickers; 1 to 255 characters.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "apiName": {
            "description": "The query's API name. Omit it and one is derived from `name` and made unique. One another saved query already has is refused with 409. It cannot be changed later.",
            "allOf": [
              {
                "$ref": "#/components/schemas/ApiName"
              }
            ]
          },
          "sql": {
            "description": "The SQL text to save: a read-only SELECT over workspace tables, validated like `POST /query`. May reference the declared `variables` as placeholders that are bound when the query runs.",
            "type": "string",
            "minLength": 1
          },
          "variables": {
            "description": "Declarations of the parameters the SQL references (name, type, default), so the UI can prompt for values before running. Omit for a query with no parameters.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QueryVariableDef"
            }
          }
        }
      },
      "UpdateSavedQueryRequest": {
        "description": "Partial update of a saved query; only the fields present change. Request body of `PUT /queries/{queryId}`.",
        "type": "object",
        "properties": {
          "name": {
            "description": "New display name, 1 to 255 characters; omit to keep the current one.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "sql": {
            "description": "New SQL text, which may contain `{{name}}` placeholders declared in `variables`; omit to keep the current one.",
            "type": "string",
            "minLength": 1
          },
          "variables": {
            "description": "New declaration of the placeholders the SQL uses; replaces the previous list when present.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QueryVariableDef"
            }
          }
        }
      },
      "ChartYAxis": {
        "description": "One plotted series of a bar, line, area or cumulative-flow chart: which result column to plot and how to colour and label it. Item of `ChartConfig.yAxes`.",
        "type": "object",
        "required": [
          "field",
          "color"
        ],
        "properties": {
          "field": {
            "description": "Name of the result column to plot on the y-axis: a field name for a record-sourced chart, or the SQL output column alias for a query-backed one.",
            "type": "string"
          },
          "color": {
            "description": "Hex colour (`#rrggbb`) used to draw the series. Required on the wire, but an empty string lets the renderer assign one from its palette.",
            "type": "string"
          },
          "name": {
            "description": "Legend and tooltip label for the series. Falls back to `field` when absent.",
            "type": "string"
          },
          "mark": {
            "description": "`combo` charts only — how this series is drawn: `bar` (the default) or `line`. Other chart types draw every series the same way and ignore it.",
            "type": "string",
            "enum": [
              "bar",
              "line"
            ]
          },
          "axis": {
            "description": "`combo` charts only — which value axis the series is scaled against: `left` (the default, shared with benchmarks) or `right`, a second axis drawn on the right of the plot for a series of a different magnitude or unit (a rate beside an amount). Other chart types ignore it.",
            "type": "string",
            "enum": [
              "left",
              "right"
            ]
          }
        }
      },
      "ChartBenchmark": {
        "type": "object",
        "description": "A comparison drawn over a chart's actual values: last quarter's figure, an SLA, a target. Exactly one of `field` (a per-row column of the same query — a benchmark that differs per category or per point) or `value` (one constant for the whole chart) supplies it. Where the SQL puts both the actual and the comparison on the same row, the chart never needs a second query.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Legend/tooltip label, e.g. \"Last quarter\" or \"SLA\"."
          },
          "field": {
            "type": "string",
            "description": "Column alias holding the benchmark value for each row."
          },
          "value": {
            "type": "number",
            "description": "Constant benchmark applied to every category/point."
          },
          "color": {
            "type": "string",
            "description": "Hex color; defaults to a muted neutral."
          },
          "style": {
            "type": "string",
            "enum": [
              "line",
              "ghost"
            ],
            "description": "`line` (default) — a dashed reference line or a tick per category; `ghost` — a faded bar behind each actual (the previous-period comparison), meaningful on bar, stage_funnel and bullet charts."
          },
          "goal": {
            "type": "string",
            "enum": [
              "at_least",
              "at_most"
            ],
            "description": "When set, each category is judged against this benchmark and colored met/missed: `at_least` for conversion or revenue targets, `at_most` for dwell, cycle time or SLA hours. The first benchmark carrying a goal drives the colouring."
          }
        }
      },
      "ChartConfig": {
        "description": "How a saved chart (or one the query assistant proposes) is drawn: which result columns feed each axis, label or value, the benchmarks drawn over them, and where the data comes from (a saved query, inline `customSql`, or a table's records via `source`). Which keys apply depends on the chart type.",
        "type": "object",
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "description": "Version of the stored config shape, stamped by the server on write. Absent on rows written before versioning (read as 1)."
          },
          "xAxis": {
            "type": "string",
            "description": "Field name for the x-axis (bar/line/area/cumulative_flow; control_chart — when the record finished; mekko — the category each column stands for)"
          },
          "yAxes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChartYAxis"
            },
            "description": "Y-axis series (bar/line/area/cumulative_flow/combo; control_chart plots the first series as each record's cycle time; mekko stacks each series as its share of the column, whose width is their sum)"
          },
          "stack": {
            "type": "string",
            "enum": [
              "none",
              "stacked",
              "percent"
            ],
            "description": "bar and combo — how several bar series share a category: `none` (the default) draws them side by side, `stacked` piles them into one bar per category whose height is their sum, and `percent` stacks them to 100% so each bar shows the series' shares of the category. Other chart types ignore it."
          },
          "nameKey": {
            "type": "string",
            "description": "Label column — pie segments, funnel/stage_funnel/bullet/waterfall categories, the stage of an aging_wip row"
          },
          "dataKey": {
            "type": "string",
            "description": "Value column — pie/funnel/bullet values, records reaching a stage_funnel stage, moves on a stage_flow row, age in seconds on an aging_wip row, the signed change on a waterfall row"
          },
          "sourceKey": {
            "type": "string",
            "description": "stage_flow — column alias of the stage a move came FROM"
          },
          "targetKey": {
            "type": "string",
            "description": "stage_flow — column alias of the stage a move went TO"
          },
          "elapsedKey": {
            "type": "string",
            "description": "stage_funnel — column alias of the average/median SECONDS spent in the stage before moving on; rendered as a duration on each step"
          },
          "benchmarks": {
            "type": "array",
            "description": "Comparisons drawn over the actuals (bar/line/area/cumulative_flow, stage_funnel, bullet, control_chart, aging_wip). See ChartBenchmark.",
            "items": {
              "$ref": "#/components/schemas/ChartBenchmark"
            }
          },
          "labelKey": {
            "type": "string",
            "description": "control_chart / aging_wip — column alias naming the record each dot stands for (shown in the tooltip)"
          },
          "totalKey": {
            "type": "string",
            "description": "waterfall — column alias of a boolean marking a row as a running total (the opening and closing balances) rather than a signed step"
          },
          "customSql": {
            "type": "string",
            "description": "Inline SQL used when the chart is not linked to a saved query"
          },
          "variables": {
            "type": "array",
            "description": "Template variables for customSql charts. Charts backed by a saved\nquery inherit the query's variables instead.\n",
            "items": {
              "$ref": "#/components/schemas/QueryVariableDef"
            }
          },
          "source": {
            "$ref": "#/components/schemas/ChartRecordSource"
          }
        }
      },
      "SavedChart": {
        "description": "A chart saved in the workspace, returned by the `/charts` endpoints. Draws either from a linked saved query (`queryId`) or from a table's records or custom SQL carried inside `config`.",
        "type": "object",
        "required": [
          "id",
          "name",
          "chartType",
          "config",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the chart, referenced by dashboard tiles and the `/charts/{chartId}` endpoints.",
            "type": "string"
          },
          "name": {
            "description": "Title shown on the chart and in the charts list.",
            "type": "string"
          },
          "chartType": {
            "$ref": "#/components/schemas/ChartType"
          },
          "queryId": {
            "description": "The saved query the chart draws from. Null when the chart is instead sourced from a table's records or custom SQL in `config`; the three sources are mutually exclusive.",
            "type": [
              "string",
              "null"
            ]
          },
          "config": {
            "$ref": "#/components/schemas/ChartConfig"
          },
          "createdBy": {
            "description": "Id of the user who created the chart. Null when that user is no longer known.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the chart was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the chart's name, type, query or config last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "openCommentThreads": {
            "type": "integer",
            "minimum": 0,
            "description": "How many unresolved discussion threads the chart carries (`/charts/{chartId}/comments`), for the count shown on the chart. Present on the list and single-chart reads. Always 0 for a caller without `comments:read`, who may not open the discussion either."
          }
        }
      },
      "CreateSavedChartRequest": {
        "description": "Request body of `POST /charts`: a new saved chart drawn from either a saved query (`queryId`) or a table named in `config.source`, never both.",
        "type": "object",
        "required": [
          "name",
          "chartType",
          "config"
        ],
        "properties": {
          "name": {
            "description": "Display name of the chart.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "chartType": {
            "$ref": "#/components/schemas/ChartType"
          },
          "queryId": {
            "description": "The saved query whose result the chart draws. Omit or send null when `config.source` names a table instead — a chart has exactly one source, and sending both is a 400.",
            "type": [
              "string",
              "null"
            ]
          },
          "config": {
            "$ref": "#/components/schemas/ChartConfig"
          }
        }
      },
      "UpdateSavedChartRequest": {
        "description": "Request body of `PUT /charts/{chartId}`. Every property is optional and only the supplied ones change, except that a chart has exactly one data source: a `config` that carries a table `source` clears `queryId`, and sending both at once is rejected.",
        "type": "object",
        "properties": {
          "name": {
            "description": "New display name of the chart, 1 to 255 characters.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "chartType": {
            "$ref": "#/components/schemas/ChartType"
          },
          "queryId": {
            "description": "The saved query to draw the chart from; null detaches it. Rejected when the chart's config (sent or stored) already names a table `source`, since a chart has one data source.",
            "type": [
              "string",
              "null"
            ]
          },
          "config": {
            "$ref": "#/components/schemas/ChartConfig"
          }
        }
      },
      "DashboardTileKind": {
        "type": "string",
        "description": "What a dashboard tile shows.\n  chart     — a saved chart (chartId)\n  table     — a saved query rendered as a table of rows (queryId)\n  pivot     — one metric over a table's records broken down by a row\n              field and a column field (pivot), with row totals and a\n              grand total; record-sourced, so it renders for every\n              viewer under their own row scope.\n  savedView — a table's saved view drawn by its own kind (tableId +\n              savedViewId): a map places the records on a map, a\n              gallery shows them as cards, a calendar by date. Only\n              workspace-shared views of those kinds can be placed.\n              The view's own config (filter, sort, field mapping) is\n              read by id — the tile never copies it — and the tile\n              may add one thing of its own: a `filter` override,\n              bound to the dashboard's variables, that is AND-ed\n              onto the view's filter at render time.\nextension — an app extension of the workspace's hosted site that\n              declares the `dashboard.tile` target, shown in a frame\n              (extension). It receives the dashboard's id and current\n              variable values in its context. A dashboard holds at\n              most four.\n",
        "enum": [
          "chart",
          "table",
          "savedView",
          "pivot",
          "extension"
        ]
      },
      "PivotTileConfig": {
        "type": "object",
        "description": "What a pivot tile (kind=pivot) shows (#1075): one metric over a table's records, broken down by a row dimension and a column dimension, with a total per row and a grand total — run through `POST /tables/{tableId}/report` for whoever views the dashboard, so a restricted-visibility viewer sees their own numbers. Column totals are summed by the client for `count` and `sum` metrics.",
        "required": [
          "tableId",
          "rows",
          "columns",
          "metric"
        ],
        "properties": {
          "tableId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "The table whose records the pivot runs over."
          },
          "rows": {
            "$ref": "#/components/schemas/RecordReportDimension"
          },
          "columns": {
            "$ref": "#/components/schemas/RecordReportDimension"
          },
          "metric": {
            "$ref": "#/components/schemas/RecordAggregateMetric"
          },
          "filter": {
            "$ref": "#/components/schemas/RecordFilter"
          }
        }
      },
      "QueryTileRecordLink": {
        "type": "object",
        "description": "On a table tile (kind=table), which result column holds record ids, so\nits cells link to those records instead of being plain text. The\nrecords belong either to one data table (`tableId`) or, for a query\nthat UNIONs several tables, to the table each row names in another\nresult column (`tableColumn`, holding the table's name as SQL sees it,\ne.g. `SELECT 'deals' AS source, id FROM deals UNION ALL ...`). Set\nexactly one of the two. A cell whose table cannot be resolved, or\nthat is empty, renders as plain text; opening a record applies the\nviewer's own access as everywhere else.\n",
        "required": [
          "column"
        ],
        "properties": {
          "column": {
            "type": "string",
            "minLength": 1,
            "maxLength": 63,
            "description": "Name of the result column whose values are record ids, as the query returns it."
          },
          "tableId": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "The data table every id in `column` belongs to. Set this or `tableColumn`."
          },
          "tableColumn": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "maxLength": 63,
            "description": "Name of a result column holding, per row, the name of the data table that row's id belongs to. Set this or `tableId`."
          }
        }
      },
      "DashboardTile": {
        "type": "object",
        "description": "One tile on a dashboard: a saved chart (kind=chart, chartId set), a\nsaved query rendered as a table of rows (kind=table, queryId set), or\na table's saved view (kind=savedView, tableId + savedViewId set).\nTiles sit on a 12-column grid: `x`/`y` give the position (column /\nrow units), `width` the span in columns and `height` the span in row\nunits (one unit ≈ 80px). Tiles without x/y (older dashboards) are\nauto-placed left-to-right, top-to-bottom in array order.\n",
        "required": [
          "id",
          "kind"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique id within the dashboard (client-generated)",
            "maxLength": 64
          },
          "kind": {
            "$ref": "#/components/schemas/DashboardTileKind"
          },
          "chartId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Saved chart id (kind=chart)"
          },
          "queryId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Saved query id (kind=table)"
          },
          "tableId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Data table the saved view belongs to (kind=savedView)"
          },
          "savedViewId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Saved view id within that table (kind=savedView)"
          },
          "pivot": {
            "$ref": "#/components/schemas/PivotTileConfig"
          },
          "recordLink": {
            "$ref": "#/components/schemas/QueryTileRecordLink"
          },
          "filter": {
            "allOf": [
              {
                "$ref": "#/components/schemas/RecordFilter"
              }
            ],
            "description": "savedView tiles only — a filter override in the saved-view filter grammar, bound to the dashboard's variables. A condition `value` string may carry `{{variableName}}` placeholders naming one of the dashboard's `variables`; `{{name.from}}` / `{{name.to}}` reference the bounds of a `daterange` variable. At render time each placeholder is replaced by the variable's current value (a value that is exactly one placeholder takes the value as-is; a multiselect's chosen values expand an `eq` condition into an \"any of\" group and a `neq` one into \"none of\"; a placeholder inside a longer string is spliced in as text, a multiselect joined with \", \"). A condition whose placeholder names a variable that is UNSET (\"All\" — absent from the wire values) is DROPPED rather than sent, so an \"All\" choice widens the tile back to the view. Whatever remains is AND-ed onto the view's own filter and travels to `GET /tables/{tableId}/items` exactly as a view's filter does — the override can only narrow what the view already selects, and the caller's row scope applies as always. Field names resolve on the view's table. A chart tile whose chart is drawn from a table's records (`ChartConfig.source`) takes the same override, bound the same way and AND-ed onto the record source's own `filter` before `POST /tables/{tableId}/aggregate`; its field names resolve on that source table, and a pivot tile takes it the same way onto its own `filter`. Ignored on table tiles and on SQL-backed chart tiles (their SQL binds variables directly); the dashboard-plan validator refuses it there."
          },
          "selects": {
            "$ref": "#/components/schemas/DashboardTileSelects"
          },
          "title": {
            "type": "string",
            "maxLength": 255,
            "description": "Title override (defaults to the chart/query/view name)"
          },
          "extension": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ExtensionPlacement"
              }
            ],
            "description": "Which app extension an `extension` tile shows (kind=extension); required for that kind and refused on any other. The site is resolved server-side against the workspace's own sites (400 `EXTENSION_SITE_UNKNOWN` otherwise)."
          },
          "x": {
            "type": "integer",
            "minimum": 0,
            "maximum": 11,
            "description": "Column position, 0-indexed from the left"
          },
          "y": {
            "type": "integer",
            "minimum": 0,
            "description": "Row position, 0-indexed from the top (row units)"
          },
          "width": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12,
            "description": "Width in 12-column grid units (default 6)"
          },
          "height": {
            "type": "integer",
            "minimum": 1,
            "maximum": 24,
            "description": "Height in row units of ~80px (default 4)"
          }
        }
      },
      "DashboardRunRequest": {
        "type": "object",
        "description": "Body of `POST /dashboards/{dashboardId}/run`: the dashboard's variable values as the page holds them — the same map every tile's own request would carry. Each tile's values are resolved on the server by the one shared rule: a dashboard value wins for every placeholder the dashboard declares (even unset, which is \"All\"), the backing query's own defaults fill the rest, and a chart drawn from a table's records binds the values through its tile's `filter`.",
        "properties": {
          "variables": {
            "$ref": "#/components/schemas/QueryVariableValues"
          }
        }
      },
      "DashboardRunResult": {
        "type": "object",
        "description": "Every chart and table tile of a dashboard answered in one request (REVIEWABLE_CHARTS_DESIGN.md step 6): one entry per such tile, in the dashboard's tile order, each carrying its result or its own refusal. Saved-view tiles are not run here — they draw records through the items list. Authorization is per tile, exactly as each tile's own endpoint applies it: a SQL tile needs unrestricted record visibility and otherwise answers with a 403 body in `error`; a record-sourced tile runs with the caller's row scope. One refused or failed tile never fails the dashboard. Tiles with identical rendered SQL run once.",
        "required": [
          "readAt",
          "tiles"
        ],
        "properties": {
          "readAt": {
            "type": "string",
            "format": "date-time",
            "description": "The server time at which the run started reading."
          },
          "tiles": {
            "type": "array",
            "description": "One entry per chart or table tile, in the dashboard's tile order.",
            "items": {
              "$ref": "#/components/schemas/DashboardTileRunResult"
            }
          }
        }
      },
      "DashboardTileRunResult": {
        "type": "object",
        "description": "One tile's answer in a dashboard run: exactly one of `result` and `error` is present. `result` is the same document the tile's own endpoint returns — `QueryResponse` for a SQL-backed chart or table tile, `RecordAggregateResult` for a chart drawn from a table's records — so a client renders it with the same code either way.",
        "required": [
          "tileId"
        ],
        "properties": {
          "tileId": {
            "type": "string",
            "description": "The `id` of the dashboard tile this entry answers."
          },
          "result": {
            "description": "The rows the tile draws: a `QueryResponse` (its `metadata` says what ran) for a SQL tile, a `RecordAggregateResult` (its `explain` does) for a record-sourced chart tile.",
            "oneOf": [
              {
                "$ref": "#/components/schemas/QueryResponse"
              },
              {
                "$ref": "#/components/schemas/RecordAggregateResult"
              }
            ]
          },
          "error": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ErrorResponse"
              }
            ],
            "description": "Why the tile has no result — the body its own endpoint would have refused with: `PERMISSION_DENIED` for a SQL tile whose caller's record visibility is restricted, a SQL error code for a query that failed, `NOT_FOUND` for a chart or query the tile names that no longer exists, `VIEW_READ_ONLY` or a filter refusal for a record tile. `status` carries the HTTP status that endpoint would have answered with."
          },
          "status": {
            "type": "integer",
            "description": "Present with `error`: the HTTP status the tile's own endpoint would have answered with — 400 for a request it refuses, 403 for a permission or visibility the caller lacks, 404 for a chart, query or table that is gone, 429 for a SQL statement the workspace's query allowance no longer covers, 500 for a fault of the server's."
          }
        }
      },
      "DashboardTileSelects": {
        "type": "object",
        "description": "Cross-filtering (REVIEWABLE_CHARTS_DESIGN.md step 5): selecting a mark on this chart tile sets one of the dashboard's variables to the mark's category value, and nothing more — the variable then drives every other tile exactly as if it had been typed into the variable bar, and lives in the URL as `v.<name>`. The value follows the variable's type: a `select`, `multiselect` or `text` variable takes the category as a string (a multiselect as a one-entry list); a `number` variable takes a numeric category only; a `daterange` variable takes a date-bucketed category only, as the bucket's half-open range (its first day to the next bucket's first day). The empty bucket is not selectable, and selecting the already-selected mark clears the variable (an explicit \"All\"). The tile that set the variable does not re-run on it and highlights the mark instead, so the comparison stays visible. Only a chart tile has marks; the dashboard-plan validator refuses `selects` on a savedView or table tile, on a variable the dashboard does not declare, and on a type the chart's category cannot supply.",
        "required": [
          "variable"
        ],
        "properties": {
          "variable": {
            "type": "string",
            "maxLength": 64,
            "description": "Name of one of the dashboard's `variables` that a selected mark sets."
          }
        }
      },
      "Dashboard": {
        "description": "A saved dashboard: a named grid of tiles (saved charts, saved-query tables, saved views) plus the variables its tile queries are bound to. Returned by the dashboards list, create, get and update endpoints.",
        "type": "object",
        "required": [
          "id",
          "apiName",
          "name",
          "variables",
          "tiles",
          "createdAt",
          "updatedAt",
          "url"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the dashboard, used in its URL and by home-page tiles that embed it.",
            "type": "string"
          },
          "apiName": {
            "$ref": "#/components/schemas/ApiName"
          },
          "name": {
            "description": "Title shown in the dashboards list and at the top of the page.",
            "type": "string"
          },
          "description": {
            "description": "Optional longer text about what the dashboard shows; null when none was given.",
            "type": [
              "string",
              "null"
            ]
          },
          "variables": {
            "type": "array",
            "description": "Dashboard-level variables. Bound to tile queries by name: a value\nfor variable `customer` is applied to every {{customer}}\nplaceholder in the SQL behind the dashboard's tiles.\n",
            "items": {
              "$ref": "#/components/schemas/QueryVariableDef"
            }
          },
          "tiles": {
            "description": "The dashboard's tiles with their grid positions. Rendered in array order where a tile has no explicit position.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DashboardTile"
            }
          },
          "createdBy": {
            "description": "User id of the member who created the dashboard; null when the creator is not recorded.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the dashboard was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the dashboard's definition last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "url": {
            "description": "The dashboard's link in the app, naming its workspace the way a published page's `url` does, so a page, a message or an AI session can send a reader to it without guessing the route; access is still decided by the server on open.",
            "type": "string",
            "format": "uri"
          }
        }
      },
      "CreateDashboardRequest": {
        "description": "Request body of `POST /dashboards`: the dashboard's name and optional description, the variables its tiles share, and the tiles themselves. Omitting `variables` or `tiles` creates an empty dashboard to fill in later.",
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "description": "Title shown in the dashboard list and page header. Need not be unique.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "apiName": {
            "description": "The dashboard's API name. Omit it and one is derived from `name` and made unique. One another dashboard already has is refused with 409. It cannot be changed later.",
            "allOf": [
              {
                "$ref": "#/components/schemas/ApiName"
              }
            ]
          },
          "description": {
            "description": "Optional free-text note on what the dashboard shows and who it is for. Null or omitted leaves it blank.",
            "type": [
              "string",
              "null"
            ]
          },
          "variables": {
            "description": "Dashboard-level template variables, bound to tile queries by name: a value for `customer` is applied to every `{{customer}}` placeholder in the SQL behind the tiles. Omit for a dashboard with no shared controls.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QueryVariableDef"
            }
          },
          "tiles": {
            "description": "The dashboard's panels in layout order, each referencing a saved chart or query. Omit to create an empty dashboard.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DashboardTile"
            }
          }
        }
      },
      "UpdateDashboardRequest": {
        "description": "Request body of `PUT /dashboards/{dashboardId}`. Every field is optional and a field left out keeps its current value; `variables` and `tiles` are replaced whole when given.",
        "type": "object",
        "properties": {
          "name": {
            "description": "New name for the dashboard, 1–255 characters. Omit to keep the current one.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "description": {
            "description": "New description; null clears it. Omit to keep the current one.",
            "type": [
              "string",
              "null"
            ]
          },
          "variables": {
            "description": "The full replacement list of query variables that tiles may reference; the previous list is discarded. Omit to keep it.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QueryVariableDef"
            }
          },
          "tiles": {
            "description": "The full replacement list of tiles in display order; the previous list is discarded. Omit to keep it.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DashboardTile"
            }
          }
        }
      },
      "DashboardPlanRequest": {
        "type": "object",
        "description": "Exactly one of `plan` and `planId` — the same contract as `SchemaPlanRequest`: validate stores what it checked and returns a `planId`, apply with `{ \"planId\" }` runs exactly that document.",
        "additionalProperties": false,
        "properties": {
          "plan": {
            "description": "Dashboard plan document (version 1) describing new saved queries,\ncharts, and dashboards as one document. Charts and tiles may\nreference queries/charts created in the same plan (by ref) or\nreuse existing ones (by id). Deliberately untyped so malformed\nplans reach the validator and come back as teaching issues\n(code/path/message/suggestion) instead of opaque\nrequest-validation errors.\n"
          },
          "planId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "A validated draft's id, from an earlier validate response; held for 30 minutes."
          },
          "patch": {
            "type": "array",
            "maxItems": 200,
            "items": {
              "$ref": "#/components/schemas/PlanPatchOperation"
            },
            "description": "Validate only, with `planId`: JSON Patch operations applied to the stored draft before validating it; the result is stored as a new draft. A bad operation is a 400 (`PLAN_PATCH_INVALID`)."
          }
        }
      },
      "PlanPatchOperation": {
        "type": "object",
        "description": "One RFC 6902 operation — `add`, `remove` or `replace` — at an RFC 6901 JSON Pointer into the plan document, e.g. `/createTables/0/fields/2/type`. `move`, `copy` and `test` are not supported.",
        "required": [
          "op",
          "path"
        ],
        "additionalProperties": false,
        "properties": {
          "op": {
            "description": "The RFC 6902 operation: `add` inserts or appends `value` at `path`, `replace` overwrites the existing value there, `remove` deletes it (`value` is ignored).",
            "type": "string",
            "enum": [
              "add",
              "remove",
              "replace"
            ]
          },
          "path": {
            "description": "RFC 6901 JSON Pointer into the plan document, e.g. `/createTables/0/fields/2/type`. Array indices are zero-based; `-` appends for `add`.",
            "type": "string",
            "maxLength": 500
          },
          "value": {
            "description": "The value to add or replace with (any JSON); not used by `remove`."
          }
        }
      },
      "DashboardPlanStats": {
        "description": "What a dashboard plan would create and what it reuses, counted by object kind. Returned with the assistant's proposed plan, with a validation result, and after an apply so the UI can summarise the change in one line.",
        "type": "object",
        "required": [
          "newQueries",
          "newCharts",
          "newDashboards",
          "reusedQueries",
          "reusedCharts"
        ],
        "properties": {
          "newQueries": {
            "description": "Saved queries the plan creates (as opposed to existing ones it reuses).",
            "type": "integer"
          },
          "newCharts": {
            "description": "Saved charts the plan creates (as opposed to existing ones it reuses).",
            "type": "integer"
          },
          "newDashboards": {
            "description": "Dashboards the plan creates.",
            "type": "integer"
          },
          "reusedQueries": {
            "type": "integer",
            "description": "Distinct existing saved queries the plan references"
          },
          "reusedCharts": {
            "type": "integer",
            "description": "Distinct existing saved charts the plan references"
          }
        }
      },
      "DashboardPlanValidationResult": {
        "description": "Outcome of dry-running a dashboard plan: whether it would apply, the teaching issues found, what it would create, and a draft id the client can apply by. Response of `POST /dashboard-plans/validate`.",
        "type": "object",
        "required": [
          "valid",
          "issues",
          "stats"
        ],
        "properties": {
          "valid": {
            "description": "True when the plan has no errors and could be applied as it stands; warnings alone leave it true.",
            "type": "boolean"
          },
          "issues": {
            "description": "Errors and warnings found, each with a stable code, the path of the offending element and a fix suggestion. Empty when the plan is clean.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "stats": {
            "$ref": "#/components/schemas/DashboardPlanStats"
          },
          "summary": {
            "type": "string",
            "description": "Human-readable markdown summary of the proposed queries, charts and\ndashboards, present when the plan is valid. Show this to the user\nfor confirmation before applying.\n"
          },
          "planId": {
            "type": "string",
            "description": "The stored draft of the document just validated, applicable by id for 30 minutes."
          },
          "planHash": {
            "type": "string",
            "description": "Content hash of that document (key order ignored)."
          }
        }
      },
      "DashboardPlanCreatedRef": {
        "type": "object",
        "description": "One object the apply step created, keyed back to its plan ref.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "ref": {
            "type": "string",
            "description": "The plan-local ref that produced it (absent for dashboards)"
          },
          "id": {
            "description": "Server-assigned id of the object that was created; the id its own endpoints take from now on.",
            "type": "string"
          },
          "name": {
            "description": "The object's name as stored, after any server normalisation of what the plan proposed.",
            "type": "string"
          }
        }
      },
      "DashboardPlanApplyResult": {
        "description": "Response of `POST /dashboard-plans/apply`: whether the plan was applied, the validation issues found, and the saved queries, charts and dashboards the apply created. Everything is created in one transaction or nothing is.",
        "type": "object",
        "required": [
          "applied",
          "issues",
          "stats"
        ],
        "properties": {
          "applied": {
            "description": "True when the plan passed validation and every object was created; false when validation refused it and nothing was written — read `issues` to learn why.",
            "type": "boolean"
          },
          "issues": {
            "description": "Validation findings from the apply-time revalidation. Errors mean `applied` is false; warnings may accompany a successful apply.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "stats": {
            "$ref": "#/components/schemas/DashboardPlanStats"
          },
          "planId": {
            "type": "string",
            "description": "The draft that was applied, when the request named one."
          },
          "planHash": {
            "type": "string",
            "description": "Content hash of the document that was applied (or refused), for the record."
          },
          "createdQueries": {
            "description": "The saved queries created, each keyed back to its plan ref. Empty when nothing was applied or the plan only reused existing queries.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DashboardPlanCreatedRef"
            }
          },
          "createdCharts": {
            "description": "The saved charts created, each keyed back to its plan ref. Empty when nothing was applied or the plan only reused existing charts.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DashboardPlanCreatedRef"
            }
          },
          "createdDashboards": {
            "description": "The dashboards created (no plan-local ref; they are identified by id and name). Empty when nothing was applied.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DashboardPlanCreatedRef"
            }
          },
          "summary": {
            "type": "string",
            "description": "Human-readable summary of what was created"
          }
        }
      },
      "KnownQueryExportFormat": {
        "description": "File formats a query export job can produce: `csv` (RFC 4180, UTF-8 with BOM; the default) or `xlsx` (one typed worksheet, header row in the workspace's brand colour and font).",
        "type": "string",
        "enum": [
          "csv",
          "xlsx"
        ]
      },
      "QueryExportRequest": {
        "description": "Request body of `POST /query/exports`: the query to run on a worker, its variable values, and the file format to produce. Same admission rules as `POST /query`.",
        "type": "object",
        "required": [
          "sql"
        ],
        "properties": {
          "sql": {
            "type": "string",
            "description": "The single SELECT statement to export, exactly as it would be run."
          },
          "variables": {
            "$ref": "#/components/schemas/QueryVariableValues"
          },
          "format": {
            "type": "string",
            "enum": [
              "csv",
              "xlsx"
            ],
            "description": "The artifact's format; `csv` when omitted. A request-side vocabulary, so a format this build cannot write is refused with 400. A `xlsx` workbook is held in memory while it is built, so its row ceiling is the smaller of the workspace's export entitlement and 200,000 rows; the job reports `truncated` when either cut the result short."
          }
        }
      },
      "RecordExportRequest": {
        "description": "Request body of `POST /tables/{tableId}/exports`: which of the table's records to export, in what order, and with which columns. Every part is optional; an empty body exports every record the caller can read, oldest first, with every column they can read. The same grammar as the records list (`GET /tables/{tableId}/items`), and the same rules: the filter narrows the caller's row scope and never widens it, and only readable fields may be filtered, sorted or exported.",
        "type": "object",
        "properties": {
          "filter": {
            "$ref": "#/components/schemas/RecordFilter"
          },
          "sort": {
            "type": "array",
            "maxItems": 3,
            "description": "Sort keys, applied in turn (\"by stage, then by amount\"), in the vocabulary of the list's `sort` parameter. `id` is always the final tie-break. Oldest record first when omitted. A name the caller cannot read, or one that does not exist, is a 400.",
            "items": {
              "$ref": "#/components/schemas/SavedViewSort"
            }
          },
          "columns": {
            "type": "array",
            "maxItems": 1000,
            "description": "The field names to export, in this order, after the leading `id` column — typically the columns the view shows. Every column the caller can read when omitted. A name the caller cannot read, or one that does not exist, is a 400. A field masked from the caller after the export was requested is left out of the file rather than exported.",
            "items": {
              "type": "string",
              "maxLength": 255
            }
          }
        }
      },
      "KnownQueryExportJobStatus": {
        "description": "Lifecycle of a query CSV export job, as known to this build (open vocabulary): `queued` waiting for a runner, `running` being produced, `succeeded` (the download is available), `failed`.",
        "type": "string",
        "enum": [
          "queued",
          "running",
          "succeeded",
          "failed"
        ]
      },
      "QueryExportJob": {
        "type": "object",
        "description": "An asynchronous export job: of query results (#67), polled with\nGET /query/exports/{jobId}, or of a table's records (#923), polled with\nGET /tables/{tableId}/exports/{jobId}. Poll until `status` is terminal;\na succeeded job carries a short-lived `downloadUrl` until `expiresAt`.\n",
        "required": [
          "id",
          "status",
          "truncated",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the export job; poll the status operation of the export that created it (`GET /query/exports/{jobId}` or `GET /tables/{tableId}/exports/{jobId}`) with it.",
            "type": "string"
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownQueryExportJobStatus",
            "description": "Job lifecycle state (known values in KnownQueryExportJobStatus,\nopen by contract — clients MUST tolerate values they don't know).\n"
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "User-facing failure reason, set only when status is failed."
          },
          "format": {
            "type": "string",
            "x-known-values": "KnownQueryExportFormat",
            "description": "The artifact's format, as requested (`csv` for jobs created before formats existed)."
          },
          "rowCount": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Rows written to the artifact (set on success)."
          },
          "byteSize": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Artifact size in bytes (set on success)."
          },
          "truncated": {
            "type": "boolean",
            "description": "True when the export's row ceiling cut the result short: the `query.exportMaxRows` entitlement for a query export, `records.exportMaxRows` for a records export. Show it; the file holds only the first rows up to that ceiling."
          },
          "createdAt": {
            "description": "When the export was requested, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "startedAt": {
            "description": "When a worker began running the query, ISO-8601 UTC; null while the job is still queued.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "finishedAt": {
            "description": "When the job reached a terminal status (succeeded or failed), ISO-8601 UTC; null while queued or running.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the artifact stops being downloadable."
          },
          "downloadUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "Short-lived presigned download URL, present only while the job is\nsucceeded and unexpired. Re-fetch the job for a fresh one.\n"
          }
        }
      },
      "QueryDeliverySchedule": {
        "type": "object",
        "description": "A saved query delivered to workspace members on a cadence (#683). Each\nfiring runs the query as the schedule's creator, produces the same CSV\nexport an on-demand run would, and emails the recipients a link back\ninto the product once it lands.\n\nEveryone on `recipientUserIds` must be able to run the query\nthemselves — an active member of this workspace holding unrestricted\nrecord visibility — because the export is built without row filters.\nThat is checked when the schedule is written and again at every\ndelivery, so a recipient who later loses either silently stops\nreceiving.\n",
        "required": [
          "id",
          "workspaceId",
          "savedQueryId",
          "cron",
          "enabled",
          "skipWhenEmpty",
          "recipientUserIds",
          "createdBy",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the schedule; the `scheduleId` of the delivery endpoints.",
            "type": "string"
          },
          "workspaceId": {
            "description": "The workspace the schedule and its saved query belong to; recipients must be active members of it.",
            "type": "string"
          },
          "savedQueryId": {
            "type": "string",
            "description": "The saved query this schedule delivers."
          },
          "savedQueryName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Current name of that query, resolved on read. Null when the query has been deleted — the schedule then parks with a lastError."
          },
          "cron": {
            "type": "string",
            "description": "Standard 5-field cron expression, evaluated in UTC."
          },
          "enabled": {
            "description": "Whether the schedule fires. While `false` nothing is delivered and `nextRunAt` is null; the schedule can still be run on demand.",
            "type": "boolean"
          },
          "skipWhenEmpty": {
            "description": "When true, a firing whose query returns no rows emails nobody: the run is recorded in `lastRunAt` and `lastDeliveredAt` stays where it was. Suits a \"what needs doing\" list that should only arrive when there is something on it.",
            "type": "boolean"
          },
          "recipientUserIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Workspace member ids this report is delivered to."
          },
          "variables": {
            "$ref": "#/components/schemas/QueryVariableValues"
          },
          "nextRunAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Next UTC firing. Null while disabled, or if the stored expression stopped being parseable (see lastError)."
          },
          "lastRunAt": {
            "description": "When the schedule last fired (started an export), ISO-8601 UTC, whether or not that firing delivered; compare with `lastDeliveredAt`. Null before the first firing.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastDeliveredAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When this report last reached at least one recipient."
          },
          "lastExportJobId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The export behind the most recent delivery, and what recipients download."
          },
          "pendingExportJobId": {
            "type": [
              "string",
              "null"
            ],
            "description": "An export this schedule has started and not yet delivered."
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the last firing delivered nothing, or which recipients were skipped. Cleared by the next firing that succeeds."
          },
          "createdBy": {
            "type": "string",
            "description": "The report runs with this user's authority, re-proven at every firing."
          },
          "createdAt": {
            "description": "When the schedule was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the schedule row was last written, ISO-8601 UTC — by a settings change, or by a firing recording its outcome (`lastRunAt`, `lastError`, …).",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateQueryDeliveryScheduleRequest": {
        "description": "Request body of `POST /query/deliveries`: schedules a saved query to run as the caller on a cron and email the recipients a link to the result.",
        "type": "object",
        "required": [
          "savedQueryId",
          "cron",
          "recipientUserIds"
        ],
        "properties": {
          "savedQueryId": {
            "description": "The saved query to run and deliver on each firing. Must be a query of this workspace the caller can run.",
            "type": "string"
          },
          "cron": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Standard 5-field cron expression, evaluated in UTC. Rejected if it would fire more often than once an hour."
          },
          "enabled": {
            "description": "Whether the schedule fires. Defaults to true; create it disabled to set it up without sending anything yet.",
            "type": "boolean",
            "default": true
          },
          "skipWhenEmpty": {
            "description": "Send nothing when the query returns no rows. Defaults to false, which emails the recipients an empty report.",
            "type": "boolean",
            "default": false
          },
          "recipientUserIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "maxItems": 20,
            "description": "Workspace member ids. Each must be an active member who can run queries in this workspace; the request is refused otherwise."
          },
          "variables": {
            "$ref": "#/components/schemas/QueryVariableValues"
          }
        }
      },
      "UpdateQueryDeliveryScheduleRequest": {
        "type": "object",
        "description": "Only the supplied fields are changed.",
        "properties": {
          "cron": {
            "description": "Standard 5-field cron expression, evaluated in UTC, giving when the query runs and its results are sent. Rejected if it would fire more often than once an hour.",
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "enabled": {
            "description": "Whether the schedule fires. False pauses deliveries without deleting the schedule.",
            "type": "boolean"
          },
          "skipWhenEmpty": {
            "description": "Send nothing when the query returns no rows (true) or email the empty report (false).",
            "type": "boolean"
          },
          "recipientUserIds": {
            "description": "Full replacement of who receives the results: 1–20 workspace member ids, each an active member allowed to run queries here; the request is refused otherwise.",
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "maxItems": 20
          },
          "variables": {
            "$ref": "#/components/schemas/QueryVariableValues"
          }
        }
      },
      "QueryDeliveryDownload": {
        "type": "object",
        "description": "A short-lived download for a delivered report.",
        "required": [
          "downloadUrl",
          "rowCount",
          "truncated"
        ],
        "properties": {
          "downloadUrl": {
            "type": "string",
            "description": "Presigned URL, valid for a few minutes. Re-fetch for a fresh one."
          },
          "rowCount": {
            "description": "Number of data rows in the delivered CSV.",
            "type": "integer"
          },
          "truncated": {
            "description": "True when the export stopped at the row cap, so the file holds only the first `rowCount` rows of the result.",
            "type": "boolean"
          }
        }
      },
      "QueryRequest": {
        "description": "Request body of `POST /query` and `POST /query/exports`: a SQL-like query over workspace data, with values for any `{{variable}}` placeholders it declares.",
        "type": "object",
        "required": [
          "sql"
        ],
        "properties": {
          "sql": {
            "type": "string",
            "description": "SQL-like query string. Supported syntax:\n- SELECT * FROM tableName\n- SELECT field1, field2 FROM tableName WHERE field = 'value'\n- SELECT * FROM tableName WHERE field > 100 LIMIT 50\nThe backend parses this and executes against workspace data.\nThe SQL may contain {{variable}} placeholders and [[ ... ]]\noptional blocks; supply values via `variables`. Placeholders are\nsubstituted as escaped literals before validation and execution.\n"
          },
          "variables": {
            "$ref": "#/components/schemas/QueryVariableValues"
          }
        }
      },
      "RunSavedQueryRequest": {
        "type": "object",
        "description": "Values to bind when running a saved query. Anything omitted falls back\nto the value the query itself declares, so a caller that names only the\nvariables it cares about keeps picking up defaults its author changes\nlater.\n",
        "properties": {
          "variables": {
            "$ref": "#/components/schemas/QueryVariableValues"
          }
        }
      },
      "SchemaPlanRequest": {
        "type": "object",
        "description": "Exactly one of `plan` and `planId`. Validate stores the document it checked and returns its `planId`; apply with `{ \"planId\" }` runs exactly that document, so what was approved is what is applied. Neither or both is a 400 (`PLAN_INPUT_INVALID`, returned as a teaching issue in the usual result document); an unknown or expired id is a 404 (`PLAN_NOT_FOUND`).",
        "additionalProperties": false,
        "properties": {
          "plan": {
            "description": "Schema plan document (version 1) describing additive schema changes:\ncreateTables, addFields, addConstraints, automations, createViews and stageConfigs,\nplus `acknowledge`, the warning codes the author has considered and keeps.\nDeliberately untyped so malformed plans reach the validator and come back as teaching issues\n(code/path/message/suggestion) instead of opaque request-validation\nerrors.\n"
          },
          "planId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "A validated draft's id, from an earlier validate response. Drafts are held for 30 minutes. On apply, the draft runs as validated, in the mode it was validated under (a different `mode` is a 400)."
          },
          "patch": {
            "type": "array",
            "maxItems": 200,
            "items": {
              "$ref": "#/components/schemas/PlanPatchOperation"
            },
            "description": "Validate only, with `planId`: JSON Patch operations applied to the stored draft before validating it. The corrected document is stored as a new draft and its `planId` returned, so fixing two fields of a large plan costs a few operations, not a resend. A bad operation is a 400 (`PLAN_PATCH_INVALID` at `patch[i]`)."
          },
          "mode": {
            "type": "string",
            "enum": [
              "create",
              "reconcile"
            ],
            "description": "How an object the plan describes that ALREADY exists is treated.\nOmitted means `create`; with `planId` on apply, omitted means the\nmode the draft was validated under.\n\n`create` (the default, and the historical behaviour): every\nexisting table, field, constraint or view named by the plan is a\nhard validation error. Use it when the plan is meant to add\nsomething new.\n\n`reconcile`: an existing object whose definition matches the plan\nis skipped (counted in `stats.skipped`) and only the missing pieces\nare created — so a plan exported by `/schema-plans/export` can be\nre-applied to the workspace it came from, or to one that has\ndrifted behind it. An existing object that DIFFERS is still a hard\nerror naming the difference: reconcile never renames, retypes or\ndrops anything, so the additive-only guarantee holds in both modes.\n"
          }
        }
      },
      "ImportUploadRequest": {
        "description": "Request body of `POST /imports/uploads`: declares the CSV file about to be uploaded so the server can presign either a single PUT or a multipart upload sized to it.",
        "type": "object",
        "required": [
          "filename",
          "sizeBytes"
        ],
        "additionalProperties": false,
        "properties": {
          "filename": {
            "description": "Original name of the CSV as the user sees it, up to 255 characters. Kept for display; the server stores the upload under its own workspace-scoped key.",
            "type": "string",
            "maxLength": 255
          },
          "sizeBytes": {
            "description": "Exact size of the file in bytes, at least 1. Decides the upload mode (single PUT below the multipart threshold, multipart above it) and is refused with 400 when it exceeds the import size limit.",
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "ImportUploadResponse": {
        "description": "Response of `POST /imports/uploads`: where to PUT the file (one presigned URL for small files, or a multipart upload for large ones) and the `s3Key` every later import call uses to refer to it.",
        "type": "object",
        "required": [
          "s3Key"
        ],
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "Workspace-scoped key; the handle for analyze/import calls"
          },
          "contentType": {
            "type": "string",
            "description": "The media type the presigned URL was signed for — send exactly\nthis as the PUT's `Content-Type` or the signature will not match.\nDerived from the filename (`.json`, `.yaml`/`.yml`, else CSV), so\nthe client never has to decide what it is uploading.\n"
          },
          "uploadUrl": {
            "type": "string",
            "description": "Single-PUT presigned URL (small files)"
          },
          "multipart": {
            "type": "object",
            "description": "Present instead of uploadUrl for large files",
            "required": [
              "uploadId",
              "partSize",
              "partUrls"
            ],
            "properties": {
              "uploadId": {
                "type": "string",
                "description": "S3 multipart upload id; send it back, with the ETag of every part, to `POST /imports/uploads/complete`."
              },
              "partSize": {
                "type": "integer",
                "description": "Size in bytes of each part except the last: slice the file into consecutive chunks of this size and PUT the n-th chunk to the n-th URL."
              },
              "partUrls": {
                "description": "Presigned PUT URLs, one per part, in part-number order starting at 1. Each PUT's response ETag is needed to complete the upload.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ImportUploadCompleteRequest": {
        "description": "Request body of `POST /imports/uploads/complete`: finishes an S3 multipart upload begun by the import presign endpoint by listing the uploaded parts and their ETags. Single-PUT uploads need no completion call.",
        "type": "object",
        "required": [
          "s3Key",
          "uploadId",
          "parts"
        ],
        "additionalProperties": false,
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "The `s3Key` the presign response returned for this file; must belong to the caller's workspace or the upload is reported as not found."
          },
          "uploadId": {
            "type": "string",
            "description": "The S3 multipart `uploadId` from the presign response."
          },
          "parts": {
            "description": "Every uploaded part, so S3 can assemble the object; all parts must be listed.",
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "partNumber",
                "etag"
              ],
              "properties": {
                "partNumber": {
                  "type": "integer",
                  "minimum": 1,
                  "description": "1-based part number, matching the position in the presign response's `partUrls` (part N was PUT to index N-1)."
                },
                "etag": {
                  "type": "string",
                  "description": "The `ETag` response header S3 returned for that part's PUT, passed back verbatim."
                }
              }
            }
          }
        }
      },
      "ImportAnalyzeRequest": {
        "description": "Request body of `POST /imports/analyze`: the staged upload(s) to inspect, and whether the AI rule proposer may run over them. The analysis proposes tables, field types, relationships and column rules; nothing is written.",
        "type": "object",
        "required": [
          "files"
        ],
        "additionalProperties": false,
        "properties": {
          "files": {
            "description": "The uploads to analyse together (1–25); files analysed in one call can be related to each other. Each is a staged import upload, not an attachment.",
            "type": "array",
            "minItems": 1,
            "maxItems": 25,
            "items": {
              "type": "object",
              "required": [
                "s3Key",
                "filename"
              ],
              "properties": {
                "s3Key": {
                  "type": "string",
                  "description": "The storage key returned when the file was staged through `POST /imports/uploads`; identifies the uploaded bytes."
                },
                "filename": {
                  "type": "string",
                  "description": "The original file name. Its extension decides how the file is read (`.csv`, `.json`, `.yaml`/`.yml`, `.xlsx`) and seeds the proposed table name."
                },
                "sheets": {
                  "type": "array",
                  "maxItems": 200,
                  "description": "Excel workbooks only: what the user has said about the\nworkbook's sheets since the last analysis. A sheet not named\nhere is analysed as the workbook presents it — its table\nfound automatically, header row included. Send the list\nback on every re-analysis of the same upload: the analysis\nis stateless, and a choice not repeated is a choice undone.\n",
                  "items": {
                    "type": "object",
                    "required": [
                      "name"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "name": {
                        "type": "string",
                        "description": "The sheet's name, exactly as the workbook names it (`ImportFileAnalysis.sheet.name`)."
                      },
                      "headerRow": {
                        "type": "integer",
                        "minimum": 1,
                        "description": "The 1-based row to read the column names from, instead of the row the analysis detected. The data rows are the rows under it."
                      },
                      "include": {
                        "type": "boolean",
                        "description": "`false` leaves the sheet out of the analysis and so out of the import; omitted or `true`, the sheet is analysed."
                      }
                    }
                  }
                }
              }
            }
          },
          "ai": {
            "type": "boolean",
            "default": true,
            "description": "`false` forces the deterministic analysis: no model is asked for\nimport rules, whatever the organization's plan and settings allow.\nOmitted or `true`, the AI rule proposer runs where it is available\n— a model key on the deployment, the organization's\n`import.ruleProposer.enabled` entitlement on, and AI budget left —\nand otherwise the analysis is the deterministic one without any\nerror. Either way everything but the columns' `ruleProposal` is the\nsame: the proposer only decorates columns, never changes them.\n"
          },
          "adapter": {
            "type": "string",
            "enum": [
              "salesforce"
            ],
            "description": "Where the files come from, when the source platform's own metadata\ncan type them exactly instead of the analysis guessing from the\nvalues. `salesforce`: the uploads are Salesforce object exports\n(Data Export, Data Loader or the Bulk API, one CSV per object,\ncolumns named by API name) and `adapterMetadata` carries the\nobjects' describe documents. A column the metadata names gets the\nfield type, label, required, unique and picklist options Salesforce\nholds for it, a lookup to an object uploaded alongside becomes a\n`declared` relationship, and a column the metadata does not know\nis typed from its values as usual. Omitted, every column is typed\nfrom its values.\n"
          },
          "adapterMetadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "The adapter's metadata, in the shape that adapter defines; required\nwhen `adapter` is set and refused (400) when it does not parse.\nFor `salesforce`: `{ \"describes\": [ … ] }`, one entry per object,\neach the JSON that `sf sobject describe --sobject <Object> --json`\nprints (its `result` member or the whole output) or the body of\nthe REST `/sobjects/<Object>/describe` call. A describe is paired\nwith the upload whose file name, without its extension, is the\nobject's API name (`Account.csv`, `Custom_Object__c.csv`,\ncase-insensitively); with one describe and one file they pair\nregardless of the name.\n"
          }
        }
      },
      "ImportColumnAnalysis": {
        "description": "What the import analyser inferred about one column of an uploaded file: the field it proposes to create, the types that fit the values and how well, value statistics and any warnings. One entry per column in `ImportFileAnalysis.columns`.",
        "type": "object",
        "required": [
          "index",
          "header",
          "proposedField",
          "typeCandidates",
          "stats",
          "issues"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "description": "Zero-based position of the column in the file. The `path` of a column issue is `columns[<index>]`."
          },
          "header": {
            "type": "string",
            "description": "The column heading as it appears in the file's header row (or the JSON key), untrimmed. Empty when the file had none for this column."
          },
          "proposedField": {
            "description": "The field the analyser suggests creating for this column — a starting point the user can change before committing the import.",
            "type": "object",
            "required": [
              "name",
              "displayName",
              "type",
              "required",
              "unique"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "Sanitised, table-unique field name derived from `header` (snake_case; clashes get a numeric suffix). Becomes the column name if the proposal is accepted."
              },
              "displayName": {
                "type": "string",
                "description": "Label for the field: the trimmed header, or `name` when the header was blank."
              },
              "type": {
                "type": "string",
                "description": "Field type chosen for the column — the most specific type that at least 95% of non-empty values parse as, else `picklist` for a small vocabulary of short strings, else `text` or `textarea` by length. The same value as `typeCandidates[0].type`."
              },
              "required": {
                "type": "boolean",
                "description": "Whether to make the field required. Suggested only alongside `unique` (which implies it); a sample with no blanks is otherwise not taken as evidence."
              },
              "unique": {
                "type": "boolean",
                "description": "Whether to make the field unique: true when every row has a value and no two are the same, over the whole file. Never suggested for a list-valued column or when distinct tracking was capped."
              },
              "labelField": {
                "type": "boolean",
                "description": "True on at most one column per file: the first unique text or email column (never `source_id`), proposed as the table's display label. Omitted on every other column."
              },
              "config": {
                "type": "object",
                "description": "Per-type config the inference proposes. Today only a picklist's options.",
                "properties": {
                  "options": {
                    "type": "array",
                    "description": "The distinct sampled values, as a schema plan's picklist options.",
                    "items": {
                      "type": "object",
                      "required": [
                        "value",
                        "label"
                      ],
                      "properties": {
                        "value": {
                          "type": "string",
                          "description": "The stored option value, as it appears in the sampled column."
                        },
                        "label": {
                          "type": "string",
                          "description": "The label shown for the option; the sampled text as read."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "typeCandidates": {
            "description": "Every field type the column's values fit, most specific first, each with the share of non-empty values that parse as it. The first entry is the proposal; the rest are the alternatives to offer in a type picker.",
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "type",
                "confidence"
              ],
              "properties": {
                "type": {
                  "type": "string",
                  "description": "A field type the column could be imported as."
                },
                "confidence": {
                  "type": "number",
                  "description": "Share of non-empty values that parse as this type, 0–1 to three decimals. Only types scoring at least 0.95 are listed; below 1 the column also carries a `TYPE_MOSTLY_CONSISTENT` warning naming the offending rows."
                }
              }
            }
          },
          "stats": {
            "description": "Value statistics gathered over the sampled rows, for showing the user what the column holds and for explaining the proposal.",
            "type": "object",
            "required": [
              "nonEmpty",
              "empty",
              "distinctCapped",
              "maxLength",
              "sampleValues"
            ],
            "properties": {
              "nonEmpty": {
                "type": "integer",
                "description": "Rows with a value in this column after trimming whitespace."
              },
              "empty": {
                "type": "integer",
                "description": "Rows where the column was blank (or whitespace only)."
              },
              "distinct": {
                "type": "integer",
                "description": "Number of different non-empty values seen. Absent when `distinctCapped` is true, because the count is no longer exact."
              },
              "distinctCapped": {
                "type": "boolean",
                "description": "True when more than 10,000 distinct values were seen and tracking stopped; `distinct` is then absent and uniqueness or picklist proposals cannot be made for the column."
              },
              "maxLength": {
                "type": "integer",
                "description": "Length in characters of the longest trimmed value; above 255 the text fallback is `textarea` rather than `text`."
              },
              "sampleValues": {
                "description": "Up to five distinct non-empty values in the order first seen, to illustrate the column in the preview.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "issues": {
            "description": "Warnings about this column — a type most but not all values fit, a header that looks like money or a percentage, a renamed field — with the `path` set to `columns[<index>]`. Empty when nothing needs attention.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "ruleProposal": {
            "$ref": "#/components/schemas/ImportRuleProposal"
          },
          "sourceType": {
            "type": "string",
            "description": "The source platform's own type for the column (`picklist`, `reference`, `datetime`, …), present when the request's `adapter` typed it from the platform's metadata rather than from its values: `proposedField` is then that metadata's answer, with the value-based inference listed after it in `typeCandidates`."
          }
        }
      },
      "ImportRuleProposal": {
        "type": "object",
        "description": "Import rules proposed for this column, which the analysis did NOT apply:\nadopting them is the client's act. Copy `rules` into the column's\nmapping entry (`fieldName` is the field that entry names), and put\nevery entry of `fields` into the proposed plan, on the table the column\nloads into — its `createTables` entry when its fit is `create`, else\n`addFields` on the fitted table:\n\n- the column's own field (`name` equal to `fieldName`), which the plan\n  already declares, is RETYPED in place: it keeps every other property\n  (its display name, `required`, `unique`, `labelField`), and drops a\n  `config` that belonged to its old type — a picklist's options do not\n  survive becoming a boolean;\n- any other field replaces a same-named field of that entry, or is\n  added after its fields.\n\nThen preview the result with `POST /imports/preview` before running\nanything.\n\nAbsent on a column nothing was proposed for, which is most of them:\nonly columns the deterministic analysis left as text or a guessed\npicklist, or typed \"mostly consistently\", are ever asked about, and a\nproposal that does not parse, compile, stay inside the column's table\nor read most of its own sample is discarded rather than repaired.\n",
        "required": [
          "source",
          "fieldName",
          "rules",
          "fields",
          "rationale",
          "sampleCheck"
        ],
        "properties": {
          "source": {
            "type": "string",
            "x-known-values": "KnownImportRuleProposalSource",
            "description": "Who proposed these rules; the values known to this version are enumerated by the KnownImportRuleProposalSource schema (see x-known-values), and clients MUST tolerate values not yet listed. `ai`: a language model, from the column's header, a bounded sample of its distinct values and the candidate fields — show it as a suggestion to check, never as a finding."
          },
          "fieldName": {
            "type": "string",
            "description": "The field the chain was written for — the column's own target, as\nthe mapping entry names it (an existing field when the fit matched\nthe column, else the column's proposed field).\n"
          },
          "rules": {
            "$ref": "#/components/schemas/ImportColumnRules"
          },
          "fields": {
            "type": "array",
            "description": "Fields the chain writes that the import has yet to create, as the\nplan should declare them: an extra target (the comment a\n`remainder` keeps, the parts an `extract` names) and, when the plan\ncreates the column's own field, that field retyped (a `Y`/`No`\ncolumn becomes `boolean`). Empty when every target already exists.\nA chain can write several fields; the plan must know all of them or\nthe job is refused at enqueue.\n",
            "items": {
              "$ref": "#/components/schemas/ImportRuleProposalField"
            }
          },
          "rationale": {
            "type": "string",
            "description": "One line from the proposer on why these rules fit the sample."
          },
          "sampleCheck": {
            "type": "object",
            "description": "The chain run over the sample values the proposer was shown —\ncomputed here, not claimed by the model.\n",
            "required": [
              "checked",
              "failed",
              "failedValues"
            ],
            "properties": {
              "checked": {
                "type": "integer",
                "description": "Sample values the chain was run over."
              },
              "failed": {
                "type": "integer",
                "description": "Of those, how many a rule refused."
              },
              "failedValues": {
                "type": "array",
                "description": "Up to five refused values, so the user sees what the rules cannot read.",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ImportRuleProposalField": {
        "description": "A field the AI rule proposer wants a column's rule chain to write — typically a new field split out of a composite column (street, city, postcode from one address column). Item of `ImportRuleProposal.fields`.",
        "type": "object",
        "required": [
          "name",
          "displayName",
          "type"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Field name, already a valid identifier."
          },
          "displayName": {
            "type": "string",
            "description": "Human-readable label for the proposed field, as it would appear in the UI."
          },
          "type": {
            "$ref": "#/components/schemas/FieldType"
          }
        }
      },
      "ImportFileAnalysis": {
        "description": "What the import analyzer learned from one uploaded file (or one virtual table shredded out of a JSON/YAML document or an Excel workbook): its shape, a sample-based row estimate, rows it could not parse, a proposed table and per-column type inference, and how it fits any table already in the workspace. Item of `ImportAnalysis.files`.",
        "type": "object",
        "required": [
          "s3Key",
          "filename",
          "sizeBytes",
          "delimiter",
          "sampledRows",
          "sampled",
          "estimatedTotalRows",
          "malformedRows",
          "suggestedTable",
          "columns",
          "issues",
          "fit"
        ],
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "Handle of the uploaded file, as returned by the upload endpoint and passed to later import calls."
          },
          "filename": {
            "type": "string",
            "description": "The file's name as it was uploaded; used to label it in the wizard and to detect its format."
          },
          "sourcePath": {
            "type": "string",
            "description": "Document uploads only (JSON, YAML, Excel): where in the document\nthese rows come from — a JSON path such as\n`$.orders[*].line_items[*]`, or for a workbook the sheet region\nthe table occupies, `'Orders'!A3:H120` (the header row is the\nrange's first row, the data rows the rest). One such analysis per\nvirtual table the document shreds into, all sharing one `s3Key`\nand `filename`; absent for a CSV, which is one table by\nconstruction.\n"
          },
          "sheet": {
            "type": "object",
            "required": [
              "name",
              "headerRow"
            ],
            "description": "Excel workbooks only: the sheet this table was read from and the row its column names were taken from. Shown beside the table in the wizard; to read the headers from another row, or to leave the sheet out, analyse the file again with a `sheets` entry naming it.",
            "properties": {
              "name": {
                "type": "string",
                "description": "The sheet's name as the workbook names it; the key a `sheets` entry refers to it by."
              },
              "headerRow": {
                "type": "integer",
                "description": "The 1-based row the column names were read from, detected or as the caller chose it."
              }
            }
          },
          "adapter": {
            "type": "object",
            "required": [
              "key",
              "object",
              "typedColumns",
              "unknownColumns"
            ],
            "description": "Present when the request named an `adapter` and this table was paired with one of its metadata documents: which columns the platform's metadata typed and which it did not know. A table the metadata said nothing about has no `adapter` and is typed from its values.",
            "properties": {
              "key": {
                "type": "string",
                "description": "The adapter that typed the table, as the request named it (`salesforce`)."
              },
              "object": {
                "type": "string",
                "description": "The source platform's name for the object the table was paired with (`Account`)."
              },
              "typedColumns": {
                "type": "integer",
                "description": "How many of the file's columns the metadata typed; each carries `sourceType`."
              },
              "unknownColumns": {
                "type": "array",
                "description": "The headers the metadata did not name, typed from their values instead — a column added by hand to the export, or an export from a different org than the describe.",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "sizeBytes": {
            "type": "integer",
            "description": "Size of the uploaded file in bytes, as the upload declared it."
          },
          "delimiter": {
            "type": "string",
            "description": "The CSV column separator detected (or given): a comma, semicolon, tab or pipe. Comma for JSON, YAML and Excel documents, which have no delimiter."
          },
          "sampledRows": {
            "type": "integer",
            "description": "Data rows read in the sample"
          },
          "sampled": {
            "type": "boolean",
            "description": "True when the file extends beyond the analyzed sample"
          },
          "estimatedTotalRows": {
            "type": "integer",
            "description": "Exact when sampled is false; size-extrapolated otherwise"
          },
          "malformedRows": {
            "description": "Rows in the sample the CSV parser had to skip (unbalanced quotes, wrong column count), at most 100, so the user can fix the file before importing.",
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "line",
                "reason"
              ],
              "properties": {
                "line": {
                  "type": "integer",
                  "description": "1-based line number of the bad row within the file."
                },
                "reason": {
                  "type": "string",
                  "description": "The parser's one-line explanation of why the row could not be read."
                }
              }
            }
          },
          "suggestedTable": {
            "description": "The table the analyzer proposes to create for this file, derived from the filename (or the document path). Already present in the proposed plan; the wizard lets the user rename it.",
            "type": "object",
            "required": [
              "name",
              "displayName"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "Proposed table identifier, a valid snake_case name made unique across the files in this analysis."
              },
              "displayName": {
                "type": "string",
                "description": "Proposed human-readable table name."
              }
            }
          },
          "columns": {
            "description": "One entry per column of the file (or per key of the document's rows), with inferred type candidates, statistics and issues.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportColumnAnalysis"
            }
          },
          "combinedFields": {
            "description": "Values the analysis recognised as ONE field spread over several\ncolumns, or held whole by one: a latitude/longitude pair as a\n`geolocation` field, a nested list of day/open/close rows (or a\nday-keyed object) as an `openingHours` field. Each is a proposal the\nclient may decline. `proposedPlan` already ACCEPTS every entry: the\ncombined field stands in for the fields its columns would have\nhad, and a table it folds away (`foldedFileIndex`) is not created.\nAbsent when nothing was recognised.\n",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportCombinedField"
            }
          },
          "fit": {
            "$ref": "#/components/schemas/ImportTableFit"
          },
          "issues": {
            "description": "Warnings about this file as a whole (inconsistent rows, empty columns, truncated sample), in the same teaching-issue shape the plan validator uses.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          }
        }
      },
      "ImportCombinedField": {
        "description": "One field built from a table's columns (`ImportFileAnalysis.combinedFields`).\n\nAccepting it, which `proposedPlan` already does: map `columns[0]` to\n`field.name` with `rules` as its import-rule chain, leave every other\ncolumn of `columns` unmapped, and leave the table at\n`foldedFileIndex` (when present) out of the job. The plan declares\n`field` on the table in place of the fields those columns would have\nbeen.\n\nDeclining it gives the import it would have had without it: every\ncolumn of `columns` loads into its own proposed field, except a\n`derived` first column, which is skipped; and the folded table is\nimported as the nested table it is, linked to this one.\n",
        "type": "object",
        "required": [
          "kind",
          "field",
          "columns",
          "rules",
          "derived",
          "rationale"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "x-known-values": "KnownImportCombinedFieldKind",
            "description": "What was recognised; the values known to this version are enumerated by the KnownImportCombinedFieldKind schema (see x-known-values), and clients MUST tolerate values not yet listed — every instruction a client needs is in the other properties."
          },
          "field": {
            "type": "object",
            "description": "The field the combined value loads into, as the plan declares it (or as it already exists on the table the fit matched).",
            "required": [
              "name",
              "displayName",
              "type"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "Field name, a valid identifier, unique among the table's proposed fields."
              },
              "displayName": {
                "type": "string",
                "description": "Human-readable label for the field."
              },
              "type": {
                "$ref": "#/components/schemas/FieldType"
              }
            }
          },
          "columns": {
            "type": "array",
            "minItems": 1,
            "description": "The columns the value is read from. The first is the one the mapping entry names; the rest are read through its `rules` (a `combine`) or are the flattened parts of what the first holds whole, and are left unmapped.",
            "items": {
              "type": "string"
            }
          },
          "rules": {
            "$ref": "#/components/schemas/ImportColumnRules"
          },
          "derived": {
            "type": "boolean",
            "description": "True when `columns[0]` is not in the source as such: the reader built it for this field, holding a nested list or object whole as JSON. Declining leaves it unmapped."
          },
          "foldedFileIndex": {
            "type": "integer",
            "description": "Index in `files` of the nested table this field replaces (the opening-times rows a parent record carried as a list). While the field is accepted that table is not imported, and the link from it to this table is not made."
          },
          "rationale": {
            "type": "string",
            "description": "One line saying what was recognised, for the review screen."
          }
        }
      },
      "KnownImportCombinedFieldKind": {
        "description": "What an import analysis recognised as one field (`ImportCombinedField.kind`): `geolocation` — a latitude column and a longitude column with numbers on the globe; `openingHours` — a nested list of day/open/close rows or a day-keyed object of opening times. Known values of an open vocabulary — clients must tolerate a kind not listed here.",
        "type": "string",
        "enum": [
          "geolocation",
          "openingHours"
        ]
      },
      "ImportTableFit": {
        "type": "object",
        "description": "Whether this table already exists in the workspace, and what the\nimport should therefore do with it. Computed per analysed TABLE (so\none per virtual table of a JSON document, not one per upload) by\nmatching the proposed table name against existing tables' names and\ndisplay names — with the identifier rules the plan validator uses —\nand by overlapping the file's column values against a record-scoped\nSAMPLE of each candidate table's rows. A caller sees value evidence\nonly from rows their own row/field scope lets them read; where it\nlets them read none, the fit rests on names alone.\n\nNever applied silently: the score and the columns that matched are\nhere so the wizard can show its reasoning and the user can override\nit.\n",
        "required": [
          "outcome",
          "score",
          "matchedColumns",
          "unmatchedColumns",
          "sampled"
        ],
        "properties": {
          "outcome": {
            "type": "string",
            "x-known-values": "KnownImportFitOutcome",
            "description": "What to do with this table; the values known to this version are enumerated by the KnownImportFitOutcome schema (see x-known-values), and clients MUST tolerate values not yet listed. `create`: nothing in the workspace fits, so the plan creates the table as before and `table` is absent. `extend`: an existing table fits but does not carry every column — `unmatchedColumns` become `addFields` on it. `map`: it carries them all, so the plan proposes nothing and the rows load into it as they are."
          },
          "score": {
            "type": "number",
            "description": "Confidence in the matched table, 0 to 1 (3 dp): half the\ntable-name signal, half the share of the file's columns an\nexisting field covers. 0 when nothing cleared the threshold.\n"
          },
          "table": {
            "type": "object",
            "description": "The matched existing table; absent when the outcome is `create`.",
            "required": [
              "id",
              "name",
              "displayName"
            ],
            "properties": {
              "id": {
                "type": "string",
                "description": "Id of the existing table the file was matched to."
              },
              "name": {
                "type": "string",
                "description": "Internal name of the matched table — what the proposed plan addresses it by."
              },
              "displayName": {
                "type": "string",
                "description": "Display name of the matched table, for the wizard to show."
              }
            }
          },
          "matchedColumns": {
            "type": "array",
            "description": "File columns an existing field already covers, in column order.",
            "items": {
              "$ref": "#/components/schemas/ImportTableFitMatchedColumn"
            }
          },
          "unmatchedColumns": {
            "type": "array",
            "description": "Headers no existing field covers — the fields an `extend` adds.\nEvery header when the outcome is `create`.\n",
            "items": {
              "type": "string"
            }
          },
          "sampled": {
            "type": "boolean",
            "description": "True when the matched table's values came from a sample of its\nrows, so overlap is evidence rather than proof. False when the\nfit rests on names alone.\n"
          }
        }
      },
      "ImportTableFitMatchedColumn": {
        "type": "object",
        "description": "One file column and the existing field it maps onto.",
        "required": [
          "column",
          "fieldName",
          "basis"
        ],
        "properties": {
          "column": {
            "type": "string",
            "description": "The file column's header"
          },
          "fieldName": {
            "type": "string",
            "description": "The existing field it maps onto"
          },
          "basis": {
            "type": "string",
            "x-known-values": "KnownImportFitMatchBasis",
            "description": "What made the column and the field agree; the values known to this version are enumerated by the KnownImportFitMatchBasis schema (see x-known-values), and clients MUST tolerate values not yet listed. `name`: the names agree, through the identifier rules the plan validator uses. `values`: the sampled values overlap. `name+values`: both."
          },
          "valueOverlap": {
            "type": "number",
            "description": "Share of the column's distinct values the existing field's sample\nalready holds (3 dp). Absent when the match rests on the names\nalone — including when the caller could read no rows of the table.\n"
          }
        }
      },
      "ImportRelationship": {
        "description": "A parent–child relationship the analysis found between two uploaded files, either detected heuristically from overlapping values or read from nesting in a JSON/YAML document. Item of `ImportAnalysis.relationships`; a client turns the accepted ones into `ImportLinkSpec`s.",
        "type": "object",
        "required": [
          "childFileIndex",
          "childTable",
          "childColumn",
          "childFieldName",
          "parentFileIndex",
          "parentTable",
          "parentKeyColumn",
          "parentKeyFieldName",
          "containment",
          "confidence",
          "sampled",
          "salesforceIds",
          "alternatives"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "x-known-values": "KnownImportRelationshipKind",
            "description": "How the link was arrived at; the values known to this version are enumerated by the KnownImportRelationshipKind schema (see x-known-values), and clients MUST tolerate values not yet listed. `detected`, what every CSV link is: a heuristic match of one file's values against another file's key column, a suggestion carrying alternatives and a confidence. `nested`: the child records were nested inside the parent records in a JSON or YAML document, so the link is a fact about the file rather than a guess — show it as a fixed chip, not a picker. `declared`: the request's `adapter` read the link from the source platform's metadata (a Salesforce lookup whose target object is in the upload); as certain as `nested`."
          },
          "childFileIndex": {
            "type": "integer",
            "description": "Position in the analysed `files` array of the file holding the foreign-key column."
          },
          "childTable": {
            "type": "string",
            "description": "Sanitized name of the table the child file is proposed to load into."
          },
          "childColumn": {
            "type": "string",
            "description": "Header of the child file's column whose values are parent keys."
          },
          "childFieldName": {
            "type": "string",
            "description": "The proposed `fieldName` for `childColumn` on the child table — what becomes the reference field when the link is accepted."
          },
          "parentFileIndex": {
            "type": "integer",
            "description": "Position in the analysed `files` array of the file holding the key column. May equal `childFileIndex` for a self-reference (a parent-id column on the same table)."
          },
          "parentTable": {
            "type": "string",
            "description": "Sanitized name of the table the parent file is proposed to load into."
          },
          "parentKeyColumn": {
            "type": "string",
            "description": "Header of the parent file's column that uniquely identifies its rows and that the child values point at."
          },
          "parentKeyFieldName": {
            "type": "string",
            "description": "The proposed `fieldName` for `parentKeyColumn` on the parent table."
          },
          "containment": {
            "type": "number",
            "description": "Share of child values found in the parent key column"
          },
          "confidence": {
            "type": "number",
            "description": "How sure the detector is, 0–1: the containment share, boosted when the child header's stem names the parent table (`account_id` → `accounts`) or both sides look like Salesforce ids, capped at 1. Candidates are ranked by it; `nested` links report 1."
          },
          "sampled": {
            "type": "boolean",
            "description": "Detected from sampled values (capped distinct sets)"
          },
          "salesforceIds": {
            "type": "boolean",
            "description": "Both sides look like Salesforce IDs (18↔15 normalized)"
          },
          "alternatives": {
            "type": "array",
            "description": "Other qualifying parent keys, best first",
            "items": {
              "type": "object",
              "required": [
                "parentFileIndex",
                "parentTable",
                "parentKeyColumn",
                "parentKeyFieldName",
                "containment",
                "confidence"
              ],
              "properties": {
                "parentFileIndex": {
                  "type": "integer",
                  "description": "Position in `files` of this alternative parent's file."
                },
                "parentTable": {
                  "type": "string",
                  "description": "Sanitized name of this alternative parent table."
                },
                "parentKeyColumn": {
                  "type": "string",
                  "description": "Header of the key column in this alternative parent file."
                },
                "parentKeyFieldName": {
                  "type": "string",
                  "description": "The proposed `fieldName` for that key column on the alternative parent table."
                },
                "containment": {
                  "type": "number",
                  "description": "Share of child values found in this alternative's key column, 0–1."
                },
                "confidence": {
                  "type": "number",
                  "description": "This alternative's confidence, computed as for the chosen parent (0–1); alternatives are listed best first."
                }
              }
            }
          }
        }
      },
      "ImportAnalysis": {
        "description": "Response of `POST /imports/analyze`: what the server inferred from the uploaded files, the relationships between them, the columns it suggests skipping, and a ready-to-edit schema plan to create the tables, with the plan validator's issues.",
        "type": "object",
        "required": [
          "files",
          "relationships",
          "skipSuggestions",
          "proposedPlan",
          "issues"
        ],
        "properties": {
          "files": {
            "description": "One analysis per table the uploads shred into, in the order the files were given; a JSON or YAML document yields one per virtual table, sharing its `s3Key`.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportFileAnalysis"
            }
          },
          "relationships": {
            "description": "Parent-child links detected between files from shared key columns, each already reflected in `proposedPlan` as a reference field.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportRelationship"
            }
          },
          "skipSuggestions": {
            "description": "Columns the analysis recommends not importing, each with the reason; the proposed plan already leaves them out, and the wizard shows them so the user can bring one back.",
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "fileIndex",
                "column",
                "reason"
              ],
              "properties": {
                "fileIndex": {
                  "type": "integer",
                  "description": "Index into `files` of the analysis the column belongs to."
                },
                "column": {
                  "type": "string",
                  "description": "Header of the column to skip, exactly as it appears in the file."
                },
                "reason": {
                  "type": "string",
                  "description": "Human-readable explanation of why the column looks unimportable or redundant (for example, an export system's internal id)."
                }
              }
            }
          },
          "proposedPlan": {
            "description": "Ready-to-edit schema plan (version 1) creating one table per file\nwith detected relationships as optional reference fields.\nDeliberately untyped — it round-trips into /imports/jobs (and\n/schema-plans/validate) where the plan validator produces\nteaching issues.\n"
          },
          "issues": {
            "description": "Teaching issues the plan validator raised against `proposedPlan`, plus any from relationship detection. Warnings do not stop the import; errors must be fixed in the plan first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          }
        }
      },
      "ImportJobOptions": {
        "description": "Row-handling options shared by the import preview, the table-creating import job and the import into an existing table: whether invalid rows are skipped or fail the job, whether the job is all-or-nothing, which cell texts count as empty, what an unreadable cell does to its row, and what a user cell naming nobody in the workspace does.",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "skipInvalid": {
            "type": "boolean",
            "default": true,
            "description": "Skip and report invalid rows instead of failing the job"
          },
          "atomic": {
            "type": "boolean",
            "default": false,
            "description": "All-or-nothing in one transaction. Only accepted for jobs small\nenough to finish in a single worker slice (the atomic row cap,\ncounted against the file itself as it is read); larger jobs\nshould dryRun first instead.\n"
          },
          "nullTokens": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32
            },
            "description": "Cell texts read as an empty value before any type parsing,\ncompared case-insensitively after trimming. Absent: `NULL`, `\\N`,\n`N/A`, `#N/A` and `NaN` — what database and spreadsheet exports\nwrite for a missing value. Pass `[]` to take every cell literally.\n"
          },
          "onCellError": {
            "type": "string",
            "enum": [
              "skipRow",
              "blankCell"
            ],
            "default": "skipRow",
            "description": "What a cell that cannot be read as its field's type does to its\nrow. `skipRow`: the row is invalid and none of it is written.\n`blankCell`: that cell is stored empty, the rest of the row is\nwritten, and the cell is reported in the result's `blankedCells`.\nA required field still refuses the row either way.\n"
          },
          "unknownUsers": {
            "type": "string",
            "enum": [
              "error",
              "pending"
            ],
            "default": "error",
            "description": "What a user cell — a user reference resolved by email, or a\nprovenance column naming `created_by`, `updated_by` or `owned_by`\n— does when its email names nobody in the workspace. `error`: the\ncell is unreadable and follows `onCellError`. `pending`: the\nimport adds that person to the workspace as a pending member (a\nname the data can refer to, with no account, no seat and no\nemail sent), and the cell resolves to them; a cell written as\n`Name <email>` gives the pending member that name, a bare email\ngives them the address as their name. When the person later\njoins the workspace, their account claims the pending member by\nverified email, so everything imported as theirs stays theirs.\nRequires `org:members:manage` in the workspace's organization,\nchecked when the job is created and again when it runs; refused\nwith 403 otherwise.\n"
          },
          "writeAutonumber": {
            "type": "boolean",
            "default": false,
            "description": "Backfill mode for autonumber fields: write the file's numbers\ninto a mapped autonumber field instead of letting the field's\nsequence assign them, so records migrated from another system\nkeep their numbers. Without it an autonumber field cannot be\nmapped (auto-mapping skips it, and an explicit mapping fails the\njob). Each cell is read as the field's display format with the\nliteral text stripped (`JOB-16557` under `JOB-{00000}` is\n16557) or as a bare whole number; an empty or unreadable cell, a\nnumber below 1, or a number another record (deleted ones\nincluded) or an earlier row of the file already holds is a row\nerror. Numbers are written on insert only, so the option cannot\nbe combined with `update` duplicate handling or `atomic`. Before\neach batch is written the field's sequence is moved forward past\nthe batch's highest number (never back), so a record created\nafterwards gets the next unused number. Requires\n`records:backfillHistory`, checked when the job is created\n(403) and again when it runs. The preview reads the cells the\nway the job will.\n"
          }
        }
      },
      "ImportPreviewRequest": {
        "description": "Request body of `POST /imports/preview`: runs an import's column-to-field mapping, rules included, over a bounded sample of an uploaded file and returns the transformed rows and rule failures without writing anything. With `tableId`, every reference cell is also looked up against its referenced table the way the job will, so the preview shows which rows resolve, which need a decision and which match nothing.",
        "type": "object",
        "required": [
          "s3Key",
          "mapping"
        ],
        "additionalProperties": false,
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "Storage key of the uploaded file to preview, as returned by the import upload endpoints. Must belong to this workspace's upload area."
          },
          "delimiter": {
            "type": "string",
            "description": "CSV field separator to parse with (a single character such as `,`, `;` or a tab). Omit to use the delimiter the analysis detected."
          },
          "filename": {
            "type": "string",
            "description": "The upload's filename, as the analysis gave it. Required with\n`sourcePath`: a document is read as JSON, YAML or Excel by its\nextension, and its tables' names (and so the `<parent>_key` column\na child links through) are derived from it exactly as the analysis\nderived them.\n"
          },
          "sourcePath": {
            "type": "string",
            "description": "Document uploads only (JSON, YAML, Excel): which virtual table of\nthe document to preview, as `ImportFileAnalysis.sourcePath` gave it\n(`$.orders[*].line_items[*]`, or a sheet region `'Orders'!A3:H120`).\nThe same bounded sample the analysis read is shredded (a workbook:\nthat region read back) and that table's rows previewed. Absent for\na CSV.\n"
          },
          "tableId": {
            "type": "string",
            "description": "The existing table the mapping targets. Given, every transformed\ncell is coerced by its real field type and refusals read exactly as\nthe import's would. Omitted, the rules run and their text comes back\nuncoerced — the honest preview for a table that does not exist yet.\n"
          },
          "mapping": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "description": "The same column → field mapping an import takes, rules included.",
            "items": {
              "type": "object",
              "required": [
                "column",
                "fieldName"
              ],
              "properties": {
                "column": {
                  "type": "string",
                  "description": "Header of the source column in the file, exactly as the analysis reported it."
                },
                "fieldName": {
                  "type": "string",
                  "description": "Name of the target field this column fills, after any `rules` have transformed the value."
                },
                "rules": {
                  "$ref": "#/components/schemas/ImportColumnRules"
                }
              }
            }
          },
          "options": {
            "$ref": "#/components/schemas/ImportJobOptions"
          },
          "maxRows": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 20,
            "description": "Sample rows to return. The rule failure counts cover every row read, not just these."
          }
        }
      },
      "ImportPreviewResponse": {
        "description": "Response of `POST /imports/preview`: a sample of the rows one file mapping would produce, with every cell the mapping could not read counted and explained, so a mapping can be checked before a job is committed.",
        "type": "object",
        "required": [
          "sampledRows",
          "rows",
          "fields",
          "ruleFailures",
          "cellFailureCount"
        ],
        "properties": {
          "sampledRows": {
            "type": "integer",
            "description": "Data rows read from the sample — what the failure counts are out of."
          },
          "sampled": {
            "type": "boolean",
            "description": "True when the file extends beyond the sample that was read."
          },
          "fields": {
            "type": "array",
            "description": "Every field this mapping writes, in write order — a rule chain's\nextra targets included, so the caller learns that one address column\nfills three fields.\n",
            "items": {
              "type": "string"
            }
          },
          "rows": {
            "description": "The sampled data rows, each with the values the mapping produced and any cell errors, in file order.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportPreviewRow"
            }
          },
          "ruleFailures": {
            "type": "array",
            "description": "One entry per rule that refused at least one cell, with how often and the first reason.",
            "items": {
              "$ref": "#/components/schemas/ImportPreviewRuleFailure"
            }
          },
          "cellFailureCount": {
            "type": "integer",
            "description": "Cells the mapping could not read across every row of the sample —\nrule failures and coercion failures together. Under the job's\n`onCellError` these either sink their rows or are stored empty.\n"
          },
          "references": {
            "type": "array",
            "description": "One entry per reference field the mapping writes, with the lookup\neach cell ran and how many resolved, need a decision or matched\nnothing across the whole sample. Present only when `tableId` was\ngiven; the per-cell outcomes are on each row's `references`.\n",
            "items": {
              "$ref": "#/components/schemas/ImportPreviewReferenceSummary"
            }
          }
        }
      },
      "ImportPreviewRow": {
        "description": "One data row as the mapping would load it: the values each target field would receive and any cells that could not be read. Item of `ImportPreviewResponse.rows`.",
        "type": "object",
        "required": [
          "rowNumber",
          "values"
        ],
        "properties": {
          "rowNumber": {
            "type": "integer",
            "description": "1-based data row number within the file."
          },
          "values": {
            "type": "object",
            "description": "Target field name → the value the mapping produced. Coerced to the\nfield's type when `tableId` was given, otherwise the rules' text. A\nfield absent from the object is one this row produced nothing for.\n",
            "additionalProperties": true
          },
          "errors": {
            "type": "array",
            "description": "Why a cell of this row could not be read, each naming the column or field.",
            "items": {
              "type": "string"
            }
          },
          "references": {
            "type": "object",
            "description": "Reference field name → how that cell resolved against the\nreferenced table, for every reference cell of the row that held\na value. Present only when `tableId` was given; a cell that\nresolved also has the record's id in `values`.\n",
            "additionalProperties": {
              "$ref": "#/components/schemas/ImportPreviewReferenceCell"
            }
          }
        }
      },
      "ImportPreviewReferenceCell": {
        "description": "One reference cell of an import preview row, looked up against the referenced table the way the job will look it up: the record it resolved to, or why it did not.",
        "type": "object",
        "required": [
          "key",
          "status"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "The text the cell holds — the key value the lookup ran, or a record id."
          },
          "status": {
            "type": "string",
            "enum": [
              "resolved",
              "possible",
              "unmatched"
            ],
            "description": "`resolved`: exactly one record, in `recordId`. `possible`: several\nrecords fit, or (similarity) only records below the threshold —\nthe job holds the row for a decision. `unmatched`: no record\nfits; held for a decision when the rule names a `mode`, a row\nerror otherwise.\n"
          },
          "recordId": {
            "type": "string",
            "description": "The record the cell resolved to, for a `resolved` cell."
          },
          "score": {
            "type": "number",
            "description": "The match score of the resolved record (1 for an exact or normalised hit)."
          },
          "reason": {
            "type": "string",
            "enum": [
              "ambiguous",
              "below_threshold"
            ],
            "description": "For a `possible` cell, why — several records at or above the threshold, or none above it."
          },
          "candidates": {
            "type": "array",
            "description": "For a `possible` cell, the records that fit, best first, at most five.",
            "items": {
              "$ref": "#/components/schemas/ImportMatchCandidate"
            }
          },
          "message": {
            "type": "string",
            "description": "For an `unmatched` cell of a key resolved exactly (no `mode`), the\nrow error the job would report for it, naming the key.\n"
          }
        }
      },
      "ImportPreviewReferenceSummary": {
        "description": "How one reference field's cells resolved across the whole previewed sample: the lookup that ran and a tally of its outcomes. Item of `ImportPreviewResponse.references`.",
        "type": "object",
        "required": [
          "field",
          "keyField",
          "mode",
          "resolved",
          "possible",
          "unmatched"
        ],
        "properties": {
          "field": {
            "type": "string",
            "description": "The reference field, by field name."
          },
          "table": {
            "type": "string",
            "description": "Sanitized name of the referenced table; absent for a reference to workspace members."
          },
          "keyField": {
            "type": "string",
            "description": "The referenced table's field the cells were compared with (`email` for members)."
          },
          "mode": {
            "$ref": "#/components/schemas/ImportMatchMode"
          },
          "scope": {
            "type": "string",
            "description": "The referenced table's field candidates had to agree with the row on, when the rule named a scope."
          },
          "resolved": {
            "type": "integer",
            "description": "Sampled cells that resolved to exactly one record."
          },
          "possible": {
            "type": "integer",
            "description": "Sampled cells the job would hold for a decision — several records fit, or only records below the threshold."
          },
          "unmatched": {
            "type": "integer",
            "description": "Sampled cells no record fits."
          }
        }
      },
      "ImportPreviewRuleFailure": {
        "description": "One transformation rule that refused at least one cell during an import preview, with how often and the first reason. Item of `ImportPreviewResponse.ruleFailures`.",
        "type": "object",
        "required": [
          "column",
          "rule",
          "ruleIndex",
          "count",
          "example"
        ],
        "properties": {
          "column": {
            "type": "string",
            "description": "The source column whose chain refused."
          },
          "rule": {
            "type": "string",
            "description": "The rule kind that refused, e.g. `extract`."
          },
          "ruleIndex": {
            "type": "integer",
            "description": "1-based position of the rule in the column's chain."
          },
          "count": {
            "type": "integer",
            "description": "Rows of the sample this rule refused."
          },
          "example": {
            "type": "string",
            "description": "The first refusal's reason, quoting the cell it could not read."
          }
        }
      },
      "ImportColumnRules": {
        "type": "array",
        "maxItems": 8,
        "description": "Import rules applied to this column's cells BEFORE the value is read as\nthe target field's type: a closed vocabulary of pure transforms —\n`nullTokens`, `mapValues`, `split`, `extract`, `remainder`,\n`dateFormat`, `combine`, `cast`, `resolveReference`, `constant`. They\nchain in order, and a chain may write SEVERAL fields from one column\n(an address into street, city and postcode). A column without rules\nbehaves exactly as it did before they existed.\n\n`nullTokens` (`{ \"rule\": \"nullTokens\", \"tokens\": [\"-\", \"n/a\"] }`)\nnames the cell texts this column reads as empty, in place of the\njob's `nullTokens`: compared case-insensitively after trimming, so a\ncolumn whose `-` means \"none\" gets its own list without every other\ncolumn losing a real `-`. An empty list takes every cell literally.\n\n`mapValues` (`{ \"rule\": \"mapValues\", \"values\": [{ \"from\": [\"Y\",\n\"yes\"], \"to\": \"true\" }, { \"from\": [\"N\", \"no\"], \"to\": \"false\" }],\n\"unmatched\": \"error\" }`) is a closed vocabulary: each `from` text\n(case-insensitive, trimmed) becomes `to`, which is text so the\nfield's own coercion settles it (`\"true\"` into a boolean, a stage\nword into a picklist). `default` is what an unmatched cell means;\nwithout one, `unmatched` is `error` (the default, the cell fails) or\n`empty`. With a `remainder` after it, a cell such as `No - some\ncomment` matches `No` at the word boundary and the rest flows on.\n\n`split` (`{ \"rule\": \"split\", \"delimiter\": \";\", \"targets\": [\"street\",\n\"city\", \"postcode\"] }`) cuts one cell into the named target fields in\norder, by a literal `delimiter` or a regular-expression `pattern`\n(never both). Fewer parts leave the later targets empty; more parts\nfail the cell. `\"into\": \"list\"` with one target collects every part\ninto it as a list, which is what a multipicklist stores (`{ \"rule\":\n\"split\", \"delimiter\": \";\", \"targets\": [\"tags\"], \"into\": \"list\" }`).\n`trim` (default true) trims each part.\n\n`extract` (`{ \"rule\": \"extract\", \"pattern\": \"(?<street>.+),\n(?<city>[^,]+), (?<postcode>[A-Z0-9 ]+)\", \"targets\": { \"street\":\n\"street\", \"city\": \"city\", \"postcode\": \"postcode\" } }`) cuts one cell\nby an anchored regular expression with named groups, `targets`\nmapping each group name to a field; a group with no entry is\ndropped. A cell the expression does not match whole is a cell\nfailure naming the pattern. The pattern is bounded in length and\nrefused when it could backtrack catastrophically.\n\n`remainder` (`{ \"rule\": \"remainder\", \"target\": \"comment\", \"onEmpty\":\n\"empty\" }`) writes what the `extract` or `mapValues` just before it\ndid not consume — the text outside every captured group, or the\ntext after the leading value matched — into `target`. `onEmpty` is\n`empty` (nothing stored, the default) or `error`; `trim` (default\ntrue) also drops a leading separator run.\n\n`dateFormat` (`{ \"rule\": \"dateFormat\", \"pattern\": \"DD/MM/YYYY\" }`)\nreads a date written in a known layout into the ISO form the\ncoercion takes, so `03/04/2026` is the 3rd of April rather than a\nguess. Tokens: `YYYY`, `YY`, `MM`, `MON`, `DD`, `HH24`, `MI`, `SS`;\nany other character is literal. Time tokens give an ISO date-time in\nUTC, otherwise a plain ISO date.\n\n`combine` (`{ \"rule\": \"combine\", \"columns\": [\"First name\", \"Last\nname\"], \"separator\": \" \", \"skipEmpty\": true }`) joins several source\ncolumns, named by their headers in order, into this entry's target —\nthe one rule that reads the row beyond its own column. `separator`\ndefaults to a single space; `skipEmpty` (default true) leaves empty\ncells out rather than doubling the separator.\n\n`cast` (`{ \"rule\": \"cast\", \"fieldType\": \"boolean\" }`) reads the text\nflowing through the chain as a value of the named field type —\ntoday's coercion, said out loud; a target the chain casts is\nsettled, so the executor writes the value rather than coercing the\ntext a second time.\n\n`constant` (`{ \"rule\": \"constant\", \"value\": \"EMEA\" }`) gives every row\nthe same value whatever the cell holds; it must come first, and the\nentry's `column` is then only a label the file need not have. The\nvalue is read like a cell: coerced by the field's type and checked\nagainst its value contract on every row.\n\n`resolveReference` (`{ \"rule\": \"resolveReference\", \"table\": \"logos\",\n\"keyField\": \"company_name\", \"mode\": \"similar\", \"threshold\": 0.8,\n\"scope\": { \"field\": \"market_model\" } }`) looks a cell up in another\ntable by one of its fields. `mode` compares the way an import's own\nduplicate key does (`ImportMatchMode`); naming one also holds the\nuncertain and unmatched cells as possible matches of the row, settled\nby `matchDecisions` entries carrying the field's name. `scope`\nnarrows the candidates to records agreeing with the row on a field.\n\nA rule failure is a CELL failure: it honours the job's `onCellError`\njust as an unreadable number does, so it sinks its row or stores the\ncell empty and is reported.\n\nEach item is deliberately left untyped here, for the same reason\n`SchemaPlanRequest.plan` is: a malformed chain should reach the backend\nvalidator and come back naming the rule and the parameter, not as an\nopaque request-validation error from the edge. The document's shape is\nTypeScript in `@taskexchange/api-spec` (`importRules.ts`), with the\nbackend Zod schemas as the runtime authority and a drift guard between\nthem. Use `POST /imports/preview` to see what a chain does to real rows\nbefore running it.\n",
        "items": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "ImportFileSpec": {
        "description": "One file (or one virtual table of a JSON/YAML document or an Excel workbook) in an import job, and how it loads: which table it targets, how each column maps to a field, and how duplicates are handled. Item of `ImportJobRequest.files`.",
        "type": "object",
        "required": [
          "s3Key",
          "filename",
          "targetTable",
          "mapping"
        ],
        "additionalProperties": false,
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "The storage key of the staged upload, as returned when it was uploaded and echoed by the analysis."
          },
          "filename": {
            "type": "string",
            "description": "The original file name, carried for job reporting; its extension decides how the file is read."
          },
          "sourcePath": {
            "type": "string",
            "description": "Document uploads only (JSON, YAML, Excel): which virtual table of\nthe document this entry loads, as `ImportFileAnalysis.sourcePath`\ngave it (`$.orders[*].line_items[*]`, or a sheet region\n`'Orders'!A3:H120`). Several entries then share one `s3Key`, each\nwith its own `sourcePath`, `targetTable` and mapping — the job's\n`shredding` phase writes one derived CSV per entry and the load\nproceeds as it does for any CSV. Required on a\n`.json`/`.yaml`/`.yml`/`.xlsx` file and refused on anything else.\n"
          },
          "sizeBytes": {
            "type": "integer",
            "description": "Size of the uploaded file in bytes, as reported at staging; lets the job plan reads and enforce the per-format size cap before opening the object. Treated as 0 when omitted."
          },
          "targetTable": {
            "type": "string",
            "description": "Sanitized name of the table this file loads into — either one the\njob's `plan` creates, or one that already exists (what an\n`ImportTableFit` outcome of `extend` or `map` proposes). Fields\nthe plan adds to an existing table are mappable in the same job.\n"
          },
          "delimiter": {
            "type": "string",
            "description": "CSV field separator (`,`, `;`, tab, …), normally the one the analysis sniffed for this file. Defaults to `,` when omitted; ignored for JSON/YAML/XLSX entries."
          },
          "duplicateHandling": {
            "type": "string",
            "enum": [
              "append",
              "skip",
              "update"
            ],
            "default": "append",
            "description": "Existing-table targets only. `append`: every row inserts.\n`skip`/`update`: rows that match an existing record on the key\n(`match`, or the single `matchFieldName`) are skipped, or\noverwrite that record's mapped fields. `update` additionally\nrequires records:update and the caller's write scope over every\nfield this file writes.\n"
          },
          "matchFieldName": {
            "type": "string",
            "description": "The one field whose value identifies an existing record, compared\nexactly: the same as `match` with that field alone in `exact`\nmode, and ignored when `match` is given. One of the two is\nrequired with `duplicateHandling` `skip` or `update`; the field\nmust already exist on the target table (a field the plan is adding\ncannot identify a record that predates it) and must be written by\nthis file.\n"
          },
          "match": {
            "$ref": "#/components/schemas/ImportMatchSpec"
          },
          "matchDecisions": {
            "type": "array",
            "maxItems": 2000,
            "description": "A reviewer's decisions for rows the match would otherwise report\nas possible matches, by row number — what `POST /imports/matches`\nshowed them. A decision on any row is honoured as given.\n",
            "items": {
              "$ref": "#/components/schemas/ImportMatchDecision"
            }
          },
          "provenance": {
            "$ref": "#/components/schemas/ImportProvenanceSpec"
          },
          "mapping": {
            "type": "array",
            "description": "CSV column → field name; unmapped columns are skipped",
            "items": {
              "type": "object",
              "required": [
                "column",
                "fieldName"
              ],
              "properties": {
                "column": {
                  "type": "string",
                  "description": "A column header exactly as it appears in the file (or the flattened key of a JSON/YAML attribute)."
                },
                "fieldName": {
                  "type": "string",
                  "description": "The `fieldName` on the target table that receives this column's values — an existing field, or one the job's `plan` creates."
                },
                "rules": {
                  "$ref": "#/components/schemas/ImportColumnRules"
                }
              }
            }
          }
        }
      },
      "ImportProvenanceSpec": {
        "description": "Which columns of the file carry each record's original provenance —\nwhen it was created and last changed, by whom, and who owns it — so a\nmigration keeps its history instead of stamping every record with the\nimport's own time and user (#944). Requires the\n`records:importProvenance` permission, held by workspace admins; it\nis checked when the job is submitted and again, from a fresh\npermission snapshot, when the job runs. Each entry names a column of\nthe file and may carry import rules, read exactly as a mapping\nentry's are (a `mapValues` chain from a legacy user id to an email,\na `dateFormat`); the chain must settle a single value.\n\nA time cell is read as a datetime (ISO 8601, or a date at midnight\nUTC). A user cell is an active workspace member's id or email. An\nempty cell keeps the default (the import's time, or the importing\nuser) and is counted as `defaulted` in the result's\n`provenanceByTable`; a cell that is not a datetime, or names nobody\nwho is an active member, is a cell failure and follows the job's\n`onCellError` like an unreadable number (skip the row, or store the\ndefault and report the cell). `createdAt` and `createdBy` apply only\nto rows the import inserts; `updatedAt`, `updatedBy` and `ownedBy`\nalso apply to rows it overwrites under `duplicateHandling` `update`.\nThe job's `input`, kept with the job, records which columns set\nthem. A dry run tallies the same counts without writing.\n",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "createdAt": {
            "$ref": "#/components/schemas/ImportProvenanceColumn"
          },
          "updatedAt": {
            "$ref": "#/components/schemas/ImportProvenanceColumn"
          },
          "createdBy": {
            "$ref": "#/components/schemas/ImportProvenanceColumn"
          },
          "updatedBy": {
            "$ref": "#/components/schemas/ImportProvenanceColumn"
          },
          "ownedBy": {
            "$ref": "#/components/schemas/ImportProvenanceColumn"
          }
        }
      },
      "ImportProvenanceColumn": {
        "description": "One provenance source: the file column that holds the value, and the import rules that turn its cells into a datetime or a member id or email before they are read. Value of an `ImportProvenanceSpec` entry.",
        "type": "object",
        "required": [
          "column"
        ],
        "additionalProperties": false,
        "properties": {
          "column": {
            "type": "string",
            "minLength": 1,
            "description": "A column header exactly as it appears in the file."
          },
          "rules": {
            "$ref": "#/components/schemas/ImportColumnRules"
          }
        }
      },
      "ImportProvenanceSummary": {
        "description": "How an import file's provenance override fared on one table: per system column it set, how many written rows took the file's value and how many fell back to the default. Value of `ImportJobResult.provenanceByTable`.",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "createdAt": {
            "$ref": "#/components/schemas/ImportProvenanceCount"
          },
          "updatedAt": {
            "$ref": "#/components/schemas/ImportProvenanceCount"
          },
          "createdBy": {
            "$ref": "#/components/schemas/ImportProvenanceCount"
          },
          "updatedBy": {
            "$ref": "#/components/schemas/ImportProvenanceCount"
          },
          "ownedBy": {
            "$ref": "#/components/schemas/ImportProvenanceCount"
          }
        }
      },
      "ImportProvenanceCount": {
        "description": "Rows written with a provenance value taken from the file (`preserved`) against rows written with the default — the import's own time or user — because the cell was empty or, under `onCellError` `blankCell`, unreadable (`defaulted`). Item of `ImportProvenanceSummary`.",
        "type": "object",
        "required": [
          "preserved",
          "defaulted"
        ],
        "properties": {
          "preserved": {
            "type": "integer",
            "description": "Rows whose value came from the file."
          },
          "defaulted": {
            "type": "integer",
            "description": "Rows that kept the default because the cell was empty or stored empty."
          }
        }
      },
      "ImportLinkSpec": {
        "description": "One parent–child link an import job resolves after loading: the reference field on the child table is populated by matching the child file's foreign-key column against the parent file's key column. Item of `ImportJobRequest.links`.",
        "type": "object",
        "required": [
          "childTable",
          "childColumn",
          "parentTable",
          "parentKeyColumn",
          "referenceFieldName"
        ],
        "additionalProperties": false,
        "properties": {
          "childTable": {
            "type": "string",
            "description": "Sanitized name of the table whose reference field is populated (the table the child file loads into)."
          },
          "childColumn": {
            "type": "string",
            "description": "CSV column on the child file holding the parent's source key"
          },
          "parentTable": {
            "type": "string",
            "description": "Sanitized name of the table the reference points at (the table the parent file loads into)."
          },
          "parentKeyColumn": {
            "type": "string",
            "description": "CSV column on the parent file holding its source key"
          },
          "referenceFieldName": {
            "type": "string",
            "description": "Reference field on the child table to populate"
          },
          "salesforceIds": {
            "type": "boolean",
            "description": "Normalize 18↔15-char Salesforce IDs when matching"
          }
        }
      },
      "ImportJobRequest": {
        "description": "Request body of `POST /imports/jobs`: the uploaded files to load, each mapped to a target table, with an optional schema plan to apply first, cross-file links to resolve, and job options.",
        "type": "object",
        "required": [
          "files"
        ],
        "additionalProperties": false,
        "properties": {
          "files": {
            "description": "The uploaded files to load, up to 25, each naming its target table and column mapping. A JSON/YAML/XLSX upload appears once per virtual table it feeds, sharing one `s3Key`. May be empty only when the job carries a post-load file (`activityLinks`, `attachments` or `stageHistory`) for rows that are already loaded.",
            "type": "array",
            "minItems": 0,
            "maxItems": 25,
            "items": {
              "$ref": "#/components/schemas/ImportFileSpec"
            }
          },
          "plan": {
            "description": "Schema plan (version 1) applied before loading — untyped, validated\nserver-side with teaching issues. Omit it when every file loads\ninto a table that already exists (an analysis where every `fit` is\n`map`): the import then changes no schema.\n"
          },
          "links": {
            "description": "Cross-file relationships to resolve after rows are inserted: which child column holds a parent's source key, and which reference field to fill with the matched parent record. Omit when files reference nothing in each other.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportLinkSpec"
            }
          },
          "activityLinks": {
            "$ref": "#/components/schemas/ImportActivityLinksSpec"
          },
          "attachments": {
            "$ref": "#/components/schemas/ImportAttachmentsSpec"
          },
          "stageHistory": {
            "$ref": "#/components/schemas/ImportStageHistorySpec"
          },
          "options": {
            "$ref": "#/components/schemas/ImportJobOptions"
          },
          "dryRun": {
            "type": "boolean",
            "default": false,
            "description": "Validate everything, write nothing"
          },
          "estimatedTotalRows": {
            "type": "integer",
            "description": "Analyze-time estimate, used for progress display"
          }
        }
      },
      "ImportActivityLinksSpec": {
        "description": "An uploaded CSV of activity → record links the job attaches after its rows are loaded (`ImportJobRequest.activityLinks`): each row names an activity of an activities table (`activitiesTable`) and one record of any table by a key field each (a Salesforce `Id` kept in `source_id`, say), and the job resolves both server-side and creates the link, the way `POST /tables/{tableId}/items/{itemId}/activities` does one at a time. A row whose activity or record is not found, is outside the caller's scope, or names a table without the key field is reported in `rowErrors` and skipped; a link that already exists is counted, not duplicated; an activity at its link cap keeps the links it has. Needs `records:update` on the activities table, as attaching does. Not available on an atomic job.",
        "type": "object",
        "required": [
          "s3Key",
          "filename",
          "activityKeyColumn",
          "activityKeyField",
          "tableColumn",
          "recordKeyColumn",
          "recordKeyField"
        ],
        "additionalProperties": false,
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "Handle of the uploaded links CSV, as returned by `POST /imports/uploads`; must belong to this workspace."
          },
          "filename": {
            "type": "string",
            "description": "The file's name, used in row errors"
          },
          "sizeBytes": {
            "type": "integer",
            "description": "Upload size in bytes, for progress display"
          },
          "delimiter": {
            "type": "string",
            "description": "Column delimiter when the file is not comma-separated"
          },
          "activitiesTable": {
            "type": "string",
            "description": "Sanitized name of the activities table (one created with `baseType: activities`) whose rows the activity keys are matched against, named the way `ImportFileSpec.targetTable` names a table. May be left out while the workspace has exactly one live activities table; required once it has several, so the job never guesses which one the keys belong to. A name that is not a live activities table refuses the job."
          },
          "activityKeyColumn": {
            "type": "string",
            "description": "CSV column holding the activity's key value"
          },
          "activityKeyField": {
            "type": "string",
            "description": "Field of the activities table whose value the activity key is matched against (`source_id` for a Salesforce export)."
          },
          "tableColumn": {
            "type": "string",
            "description": "CSV column naming the table of the record to link, by its sanitized table name"
          },
          "recordKeyColumn": {
            "type": "string",
            "description": "CSV column holding the record's key value"
          },
          "recordKeyField": {
            "type": "string",
            "description": "Field every named table carries whose value the record key is matched against (`source_id` for a Salesforce export); a row naming a table without it is reported."
          },
          "salesforceIds": {
            "type": "boolean",
            "description": "Match keys on their first 15 characters, so 15- and 18-character Salesforce Ids agree"
          }
        }
      },
      "ImportAttachmentsSpec": {
        "description": "An uploaded manifest of file bodies the job files into attachment fields after its rows are loaded (`ImportJobRequest.attachments`): each row names a record of any table by a key field, the attachment field to fill, and a body uploaded earlier through `POST /imports/uploads` (its `s3Key`), with the name and media type to keep. The job resolves the record under the caller's update scope, checks the body against the field's size cap and media-type allowlist exactly as an upload through `POST /tables/{tableId}/items/{itemId}/fields/{fieldId}/attachments` is checked, copies it server-side to the record's own storage key and writes the field, with the record's history and events as for any update. A row whose record, field or body is not found, or whose body the field refuses, is reported in `rowErrors` and skipped; a field that already holds a file is left as is unless `onExisting` is `replace`. Needs `records:update`. Not available on an atomic job.",
        "type": "object",
        "required": [
          "s3Key",
          "filename",
          "tableColumn",
          "recordKeyColumn",
          "recordKeyField",
          "fieldColumn",
          "objectKeyColumn",
          "filenameColumn",
          "mimeTypeColumn"
        ],
        "additionalProperties": false,
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "Handle of the uploaded manifest CSV, as returned by `POST /imports/uploads`; must belong to this workspace."
          },
          "filename": {
            "type": "string",
            "description": "The manifest's name, used in row errors"
          },
          "sizeBytes": {
            "type": "integer",
            "description": "Upload size in bytes, for progress display"
          },
          "delimiter": {
            "type": "string",
            "description": "Column delimiter when the manifest is not comma-separated"
          },
          "tableColumn": {
            "type": "string",
            "description": "CSV column naming the record's table, by its sanitized table name"
          },
          "recordKeyColumn": {
            "type": "string",
            "description": "CSV column holding the record's key value"
          },
          "recordKeyField": {
            "type": "string",
            "description": "Field every named table carries whose value the record key is matched against (`source_id` for a Salesforce export); a row naming a table without it is reported."
          },
          "fieldColumn": {
            "type": "string",
            "description": "CSV column naming the attachment field to fill, by its field name"
          },
          "objectKeyColumn": {
            "type": "string",
            "description": "CSV column holding the body's upload handle: the `s3Key` of an upload through `POST /imports/uploads` in this workspace. An empty cell means the row has no body and is skipped without an error."
          },
          "filenameColumn": {
            "type": "string",
            "description": "CSV column holding the file name to store the body under"
          },
          "mimeTypeColumn": {
            "type": "string",
            "description": "CSV column holding the body's media type; the field's allowlist is checked against it"
          },
          "salesforceIds": {
            "type": "boolean",
            "description": "Match record keys on their first 15 characters, so 15- and 18-character Salesforce Ids agree"
          },
          "onExisting": {
            "type": "string",
            "enum": [
              "skip",
              "replace"
            ],
            "default": "skip",
            "description": "What to do when the field already holds a file: `skip` keeps it and counts the row under `existing`; `replace` files the manifest's body over it."
          }
        }
      },
      "ImportAttachmentsSummary": {
        "description": "What the `attachments` manifest of an import job came to (`ImportJobResult.attachments`): bodies filed into their fields, rows whose field already held a file and were left as is, rows with no body named, and rows that resolved to nothing or were refused and were reported in `rowErrors`. On a dry run `attached` is the bodies that would be filed; nothing is copied.",
        "type": "object",
        "required": [
          "attached",
          "existing",
          "withoutBody",
          "unresolved"
        ],
        "properties": {
          "attached": {
            "type": "integer",
            "description": "Bodies copied into a record's attachment field (or, on a dry run, that would be)"
          },
          "existing": {
            "type": "integer",
            "description": "Rows skipped because the field already held a file (`onExisting` `skip`)"
          },
          "withoutBody": {
            "type": "integer",
            "description": "Rows whose body cell was empty, skipped without an error"
          },
          "unresolved": {
            "type": "integer",
            "description": "Rows skipped because the table, record, field or body was not found or the body was refused; each is in `rowErrors`"
          }
        }
      },
      "ImportActivityLinksSummary": {
        "description": "What the `activityLinks` file of an import job came to (`ImportJobResult.activityLinks`): links created, links that already existed, rows that resolved to nothing and were reported in `rowErrors`, and links refused because the activity had reached its cap. On a dry run `created` is the links that would be created and `capped` is not computed.",
        "type": "object",
        "required": [
          "created",
          "existing",
          "unresolved",
          "capped"
        ],
        "properties": {
          "created": {
            "type": "integer",
            "description": "Links written (or, on a dry run, that would be)"
          },
          "existing": {
            "type": "integer",
            "description": "Rows whose link was already there, left as is"
          },
          "unresolved": {
            "type": "integer",
            "description": "Rows skipped because the activity, the table or the record was not found; each is in `rowErrors`"
          },
          "capped": {
            "type": "integer",
            "description": "Links refused because the activity already links to the most records it may"
          }
        }
      },
      "ImportStageHistorySpec": {
        "description": "An uploaded CSV of past stage moves the job writes as history after its rows are loaded (`ImportJobRequest.stageHistory`; phase `backfilling_history`): each row says that one record, named by a key field, entered a value of one of its designated stage fields at an instant in the past. Rows of one record and field must be contiguous and in time order; the job seeds each record's chain the way `POST /tables/{tableId}/stage-transitions/seed` does with `source` `import` — chained from nothing, checked against the field's transition matrix, strictly increasing in time, ending on the value the record holds now — so the log and the row can never disagree. With this file present the job writes no import-time `null → current` baseline for the records it loads: the seeded chain is their baseline, and a record the file says nothing about has no history until a stage-config snapshot dates it. A record that already has history for the field is left as it is (counted under `existing`), which makes a re-run write nothing twice — unless `replace` is set; a chain the rules refuse, or a row naming a table, field or record that is not found, is reported in `rowErrors` and skipped. The stage field must be designated before the job runs (a plan's `stageConfigs` applied without `snapshotExisting`), and the submitting principal needs `records:backfillHistory`. Not available on an atomic job.",
        "type": "object",
        "required": [
          "s3Key",
          "filename",
          "tableColumn",
          "recordKeyColumn",
          "recordKeyField",
          "fieldColumn",
          "toValueColumn",
          "occurredAtColumn"
        ],
        "additionalProperties": false,
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "Handle of the uploaded history CSV, as returned by `POST /imports/uploads`; must belong to this workspace."
          },
          "filename": {
            "type": "string",
            "description": "The file's name, used in row errors"
          },
          "sizeBytes": {
            "type": "integer",
            "description": "Upload size in bytes, for progress display"
          },
          "delimiter": {
            "type": "string",
            "description": "Column delimiter when the file is not comma-separated"
          },
          "tableColumn": {
            "type": "string",
            "description": "CSV column naming the record's table"
          },
          "recordKeyColumn": {
            "type": "string",
            "description": "CSV column holding the record's key value"
          },
          "recordKeyField": {
            "type": "string",
            "description": "Field of each named table whose value the record key is matched against (`source_id` for a Salesforce export)"
          },
          "fieldColumn": {
            "type": "string",
            "description": "CSV column naming the designated stage field the move belongs to"
          },
          "toValueColumn": {
            "type": "string",
            "description": "CSV column holding the stage value entered; an empty cell is a clear"
          },
          "occurredAtColumn": {
            "type": "string",
            "description": "CSV column holding when the record entered the value, ISO-8601 (UTC when no offset)"
          },
          "salesforceIds": {
            "type": "boolean",
            "description": "Match record keys on their first 15 characters, so 15- and 18-character Salesforce Ids agree"
          },
          "replace": {
            "type": "boolean",
            "description": "Sandbox workspaces only. Overwrite instead of skipping: for each record chain in the file, the record's existing history for the field written by an import or a seed (`source` `import` or `seeded`, such as the import-time baseline) is removed in the same transaction before the chain is written — the file form of the seed endpoint's `replace`. History a live write produced (`api`, `automation`, …) is never removed; a chain that would have to precede it is refused as out of order and reported in `rowErrors`. A dry run counts the rows that would be removed under `replaced`. Refused with 400 `SANDBOX_ONLY` on any other workspace."
          }
        }
      },
      "ImportStageHistorySummary": {
        "description": "What the `stageHistory` file of an import job came to (`ImportJobResult.stageHistory`): transition rows written, records given a timeline, records left alone because they already had history for the field, and record chains refused or unresolved and reported in `rowErrors`; with `replace`, also the import-written rows removed. On a dry run `transitions`, `records` and `replaced` are what would be written or removed.",
        "type": "object",
        "required": [
          "transitions",
          "records",
          "existing",
          "refused"
        ],
        "properties": {
          "transitions": {
            "type": "integer",
            "description": "Transition rows written (or, on a dry run, that would be)"
          },
          "records": {
            "type": "integer",
            "description": "Record-and-field chains written in full"
          },
          "existing": {
            "type": "integer",
            "description": "Chains skipped because the record already had history for the field"
          },
          "refused": {
            "type": "integer",
            "description": "Chains skipped because a rule refused them or the table, field or record was not found; each is in `rowErrors`"
          },
          "replaced": {
            "type": "integer",
            "description": "Present when the file was submitted with `replace`: existing import-written or seeded transition rows removed before the chains were written (or, on a dry run, that would be). Live history is never counted here, because it is never removed."
          }
        }
      },
      "TableImportRequest": {
        "description": "Starts an import of one uploaded CSV into an existing table: the uploaded file, how its columns map to fields, how rows that match existing records are handled, and whether to only validate. Request body of `POST /tables/{tableId}/import`.",
        "type": "object",
        "required": [
          "s3Key"
        ],
        "additionalProperties": false,
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "Handle of the uploaded CSV, as returned by `POST /imports/uploads`; must belong to the caller's workspace."
          },
          "filename": {
            "type": "string",
            "description": "The file's original name, used to label the job and to recognise its format; defaults to the key when omitted."
          },
          "sizeBytes": {
            "type": "integer",
            "description": "Size of the uploaded file in bytes, as the upload declared it; recorded on the job."
          },
          "delimiter": {
            "type": "string",
            "description": "The CSV column separator, when known; omit to have it detected from the header."
          },
          "mapping": {
            "type": "array",
            "description": "CSV column → field name. Omit it to map every column by name\n(see autoMap); give it to name the exceptions, or the whole\nmapping. A column it names must exist in the file's header.\n",
            "items": {
              "type": "object",
              "required": [
                "column",
                "fieldName"
              ],
              "properties": {
                "column": {
                  "type": "string",
                  "description": "Exact header text of the CSV column being mapped; must exist in the file."
                },
                "fieldName": {
                  "type": "string",
                  "description": "The target table field (its `fieldName`) the column loads into."
                },
                "matchBy": {
                  "type": "string",
                  "description": "Reference fields only: the target table's unique field\nwhose value the cells hold, in place of the target's own\nreference key. The multi-file import (`POST /imports/jobs`)\nhas no `matchBy`: there the same lookup is a\n`resolveReference` rule in the column's `rules`, with this\nfield as its `keyField`. A cell that is a record id is\nalways taken as one. A reference to users resolves by the\nmember's `email` whether or not this says so; `email` is\nthe only value accepted there.\n"
                },
                "rules": {
                  "$ref": "#/components/schemas/ImportColumnRules"
                }
              }
            }
          },
          "autoMap": {
            "type": "boolean",
            "description": "Also map the columns `mapping` does not name: a header equal to\na field's name, else its display name (case-insensitive,\nwhitespace-trimmed). Implied when `mapping` is omitted; defaults\nto false when it is given, so an explicit mapping keeps skipping\nthe columns it leaves out. A header naming a computed, lookup,\nrollup, autonumber or attachment field is skipped and reported,\nnot an error.\n"
          },
          "ignoreColumns": {
            "type": "array",
            "description": "Columns (exact header text) auto-mapping must skip. Naming a column that `mapping` also uses is an error.",
            "items": {
              "type": "string"
            }
          },
          "options": {
            "$ref": "#/components/schemas/ImportJobOptions"
          },
          "duplicateHandling": {
            "type": "string",
            "enum": [
              "append",
              "skip",
              "update"
            ],
            "default": "append",
            "description": "What to do with a CSV row that matches an existing record on the\nkey (`match`, or the single `matchFieldName`). append: no\nmatching — every row inserts (a collision on a unique field is\nstill a row error). skip: matching rows are counted\n(duplicateCount) and not written. update: matching rows overwrite\nthe MAPPED fields of the matched record (unmapped fields keep\ntheir values); rows matching nothing insert. A row that matches a\nrecord the caller may not update, duplicates an earlier row's\nkey, or has an empty key is a row error; a row whose match is\nuncertain (several records, or a similarity below the threshold)\nis a possible match: reported for review, written only once a\n`matchDecisions` entry says how.\n"
          },
          "matchFieldName": {
            "type": "string",
            "description": "The one field identifying an existing record for skip/update,\ncompared exactly: the same as `match` with that field alone in\n`exact` mode, and ignored when `match` is given. One of the two is\nrequired for those modes; ignored for append. Must be one of the\nmapped fields and scalar-typed (JSON-object fields such as address\nor multipicklist cannot be matched on).\n"
          },
          "match": {
            "$ref": "#/components/schemas/ImportMatchSpec"
          },
          "matchDecisions": {
            "type": "array",
            "maxItems": 2000,
            "description": "A reviewer's decisions for rows the match would otherwise report\nas possible matches, by row number — what `POST /imports/matches`\nshowed them. A decision on any row is honoured as given.\n",
            "items": {
              "$ref": "#/components/schemas/ImportMatchDecision"
            }
          },
          "dryRun": {
            "description": "Validate the whole file and report what would happen (inserts, updates, duplicates, row errors) without writing anything.",
            "type": "boolean",
            "default": false
          },
          "estimatedTotalRows": {
            "description": "Row count the client expects, usually from the analysis; used to refuse an atomic import over the atomic row cap before it starts and to size progress. Optional: without it an atomic import is accepted and the cap is enforced against the file as it is read.",
            "type": "integer"
          },
          "wait": {
            "type": "boolean",
            "default": false,
            "description": "Hold the response until the job reaches a terminal status, for up\nto about 20 seconds: a job that finishes in time comes back as a\n200 with its result, so a small import needs no second call. A\njob still running at the cap comes back as the usual 202 and is\npolled like any other. Large files stay asynchronous either way.\n"
          }
        }
      },
      "ImportMappingResolution": {
        "type": "object",
        "description": "How a single-table import's CSV columns were mapped to fields, as\ndecided when the job was enqueued. Read it after a dry run to see\nwhat auto-mapping chose before committing.\n",
        "required": [
          "resolved",
          "ignoredColumns",
          "unmappedColumns",
          "unmappedRequiredFields"
        ],
        "properties": {
          "resolved": {
            "description": "Each CSV column that will load into a field, with how the pairing was decided and, for reference fields, how cells resolve to records.",
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "column",
                "fieldName",
                "source"
              ],
              "properties": {
                "column": {
                  "type": "string",
                  "description": "The CSV header, exactly as it appears in the file."
                },
                "fieldName": {
                  "type": "string",
                  "description": "Name of the target field the column's cells load into."
                },
                "source": {
                  "type": "string",
                  "enum": [
                    "mapping",
                    "fieldName",
                    "displayName"
                  ],
                  "description": "mapping — named in the request; fieldName / displayName — auto-mapped by that match."
                },
                "matchBy": {
                  "type": "string",
                  "description": "Reference fields only: how a cell resolves — the target\nfield whose value it may hold (the target's reference key,\nor the request's matchBy), `email` for a reference to\nusers (a cell names an active workspace member by email or\nby user id), or `id` when the target has no single-field\nkey and cells must be record ids. A record id is taken as\none either way.\n"
                }
              }
            }
          },
          "ignoredColumns": {
            "type": "array",
            "description": "Columns deliberately not loaded, each with the reason (listed in ignoreColumns; matches a read-only field; a later duplicate of a header already mapped).",
            "items": {
              "type": "object",
              "required": [
                "column",
                "reason"
              ],
              "properties": {
                "column": {
                  "type": "string",
                  "description": "The CSV header of the column that was not loaded."
                },
                "reason": {
                  "type": "string",
                  "description": "Why the column was left out: listed in `ignoreColumns`, matches a read-only field, or duplicates a header already mapped."
                }
              }
            }
          },
          "unmappedColumns": {
            "type": "array",
            "description": "Columns no field matched; their cells are not loaded.",
            "items": {
              "type": "string"
            }
          },
          "unmappedRequiredFields": {
            "type": "array",
            "description": "Required fields without a default that no column maps to. Outside\nupdate mode the job fails on them; in update mode only a row that\nwould insert is refused, per row.\n",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ImportRowError": {
        "description": "One source row an import could not write (or, in `blankedCells`, wrote with an emptied cell), located by file and 1-based row number with the messages explaining why.",
        "type": "object",
        "required": [
          "rowNumber",
          "errors"
        ],
        "properties": {
          "rowNumber": {
            "type": "integer",
            "description": "1-based data row number within its file"
          },
          "file": {
            "type": "string",
            "description": "Filename of the source file the row came from, so a multi-file job's errors can be told apart. Absent when the job had a single implicit source."
          },
          "errors": {
            "description": "One human-readable message per problem found on the row (which cell, what was expected).",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ImportJobResult": {
        "description": "The outcome of a finished import job (the `result` of an `ImportJob`): how many records each table received, how many rows were skipped, failed or blanked, the capped lists of row-level problems, and any job-level warnings. On a dry run the counts describe what would have happened.",
        "type": "object",
        "required": [
          "insertedByTable",
          "skippedCount",
          "errorCount",
          "rowErrors",
          "warnings"
        ],
        "properties": {
          "insertedByTable": {
            "description": "Records created per target table, keyed by table name. On a dry run: the rows that would have been inserted.",
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "updatedByTable": {
            "type": "object",
            "description": "Records overwritten by duplicateHandling update (absent for jobs\nwithout it). On a dry run: rows that WOULD update.\n",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "duplicateCount": {
            "type": "integer",
            "description": "Rows not written because they matched an existing record\n(duplicateHandling skip). On a dry run: rows that WOULD be\nskipped as duplicates.\n"
          },
          "skippedCount": {
            "type": "integer",
            "description": "Rows not written because they were invalid (a cell could not be read as its field's type, a required value was missing, or a reference could not be resolved) and `skipInvalid` let the job continue. Each skipped row is listed in `rowErrors` up to the cap."
          },
          "errorCount": {
            "type": "integer",
            "description": "Total invalid rows (rowErrors below is capped)"
          },
          "rowErrors": {
            "description": "The invalid rows, each with its file, 1-based row number and the messages explaining why it was not written. Capped; `errorCount` is the full number.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportRowError"
            }
          },
          "warnings": {
            "description": "Job-level notes that did not stop the import (for example a column nothing mapped to), as human-readable strings.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "provenanceByTable": {
            "type": "object",
            "description": "For each table a file with a `provenance` override loaded, how\nmany written rows took each system column's value from the file\nand how many kept the default. Absent for jobs without an\noverride. On a dry run: what WOULD have been preserved.\n",
            "additionalProperties": {
              "$ref": "#/components/schemas/ImportProvenanceSummary"
            }
          },
          "activityLinks": {
            "$ref": "#/components/schemas/ImportActivityLinksSummary"
          },
          "attachments": {
            "$ref": "#/components/schemas/ImportAttachmentsSummary"
          },
          "stageHistory": {
            "$ref": "#/components/schemas/ImportStageHistorySummary"
          },
          "sampled": {
            "type": "boolean",
            "description": "True when the counts rest on a sampled read of the input rather than every row, so they are estimates. Absent when the whole input was read, which is the normal case for a committed job."
          },
          "blankedCellCount": {
            "type": "integer",
            "description": "Cells stored empty under `onCellError` `blankCell` (blankedCells below is capped)."
          },
          "blankedCells": {
            "type": "array",
            "description": "The rows with a blanked cell, each message naming the field and\nwhy the cell could not be read; capped like rowErrors.\n",
            "items": {
              "$ref": "#/components/schemas/ImportRowError"
            }
          },
          "possibleMatchCount": {
            "type": "integer",
            "description": "Rows not written because their match was uncertain — several\nrecords, or a similarity in the band below the threshold — and no\n`matchDecisions` entry settled them. Re-run with decisions, or\nimport them another way; they are neither errors nor duplicates.\n"
          },
          "possibleMatches": {
            "type": "array",
            "description": "The uncertain rows with their candidate records, in file order; capped like rowErrors.",
            "items": {
              "$ref": "#/components/schemas/ImportPossibleMatch"
            }
          },
          "matchOutcomeCount": {
            "type": "integer",
            "description": "Rows the match settled — updated, skipped as a duplicate, or inserted by a reviewer's decision."
          },
          "matchOutcomes": {
            "type": "array",
            "description": "The settled rows, each naming the record and how the decision was\nreached (the rule, or a reviewer); capped like rowErrors. The\nsame facts are written to each updated record's history.\n",
            "items": {
              "$ref": "#/components/schemas/ImportMatchOutcome"
            }
          },
          "fetched": {
            "$ref": "#/components/schemas/ImportFetchedSource"
          },
          "revert": {
            "$ref": "#/components/schemas/ImportRevertSummary"
          }
        }
      },
      "ImportRevertSummary": {
        "description": "What a `revert` job did (`ImportJobResult.revert`): per table, how many of the import's records went to the recycle bin, how many it could not move, and how many records the import had updated and therefore left as they are. The bin batch of every moved record is the revert job's id, so restoring any one of them from a table's bin restores them all.",
        "type": "object",
        "required": [
          "tables",
          "cascaded"
        ],
        "properties": {
          "tables": {
            "description": "One entry per table the import created records in, in table-name order.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportRevertTableSummary"
            }
          },
          "cascaded": {
            "description": "Records in other tables that went to the bin with the import's records because a `cascade` reference pointed at one of them — exactly what deleting the record by hand would have taken along.",
            "type": "integer"
          }
        }
      },
      "ImportRevertTableSummary": {
        "description": "One table's share of a revert's outcome.",
        "type": "object",
        "required": [
          "tableId",
          "tableName",
          "reverted",
          "skipped",
          "updatesKept"
        ],
        "properties": {
          "tableId": {
            "type": "string",
            "description": "Identifier of the table."
          },
          "tableName": {
            "type": "string",
            "description": "The table's name, the key `insertedByTable` used for it."
          },
          "reverted": {
            "type": "integer",
            "description": "Records the import created that are now in the recycle bin."
          },
          "skipped": {
            "type": "integer",
            "description": "Records the import created that were not moved: already in the bin, permanently deleted since, or outside the delete scope of the member who reverted."
          },
          "updatesKept": {
            "type": "integer",
            "description": "Records the import overwrote in update mode. A revert does not restore their earlier values; they keep what the import wrote."
          }
        }
      },
      "ImportJobRevertRef": {
        "description": "The latest revert of an import (`ImportJob.revert`): which job it is and how far it has got, so the history shows \"reverted\" or \"reverting\" without a second read.",
        "type": "object",
        "required": [
          "jobId",
          "status"
        ],
        "properties": {
          "jobId": {
            "type": "string",
            "description": "Identifier of the revert job, readable through `GET /imports/jobs/{jobId}`."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownImportJobStatus",
            "description": "The revert job's lifecycle status. Open vocabulary (the KnownImportJobStatus schema lists the values this version knows); clients tolerate values not listed."
          }
        }
      },
      "ImportHttpSourceAuth": {
        "description": "How a request to an HTTP import source is authenticated. The credential is always a workspace secret named here and decrypted only inside the import worker; it is sent to the configured host and never anywhere else (a `next` link to another origin fails the job). A public source that needs no credential says `{ \"kind\": \"none\" }` and names no secret.",
        "type": "object",
        "required": [
          "kind"
        ],
        "additionalProperties": false,
        "properties": {
          "kind": {
            "description": "Where the secret goes: `bearer` as `Authorization: Bearer <secret>`; `header` as the value of `headerName`; `query` as the value of query parameter `paramName`; `basic` as HTTP Basic with `username` and the secret as the password; `none` sends no credential, for a public source.",
            "type": "string",
            "enum": [
              "bearer",
              "header",
              "query",
              "basic",
              "none"
            ]
          },
          "secretName": {
            "description": "The workspace secret (`POST /secrets`) holding the credential, by name. Required for every kind but `none`, which refuses one.",
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_]{0,63}$"
          },
          "headerName": {
            "description": "`header` only: the request header that carries the secret (for example `X-Api-Key`).",
            "type": "string",
            "maxLength": 100
          },
          "paramName": {
            "description": "`query` only: the query parameter that carries the secret.",
            "type": "string",
            "maxLength": 100
          },
          "username": {
            "description": "`basic` only: the user name; the secret is the password.",
            "type": "string",
            "maxLength": 200
          }
        }
      },
      "ImportHttpSourcePagination": {
        "description": "How the source pages its records, and so how the job asks for the next page. The job stops at an empty page, a page shorter than `pageSize` when `sizeParam` sent it, a missing cursor or next link, or the source's `maxRecords`, whichever comes first.",
        "type": "object",
        "required": [
          "kind"
        ],
        "additionalProperties": false,
        "properties": {
          "kind": {
            "description": "`none` reads one page; `page` sends a page number (`pageParam`, starting at `startPage`) and a page size (`sizeParam`); `offset` sends a record offset (`offsetParam`) and a limit (`limitParam`); `cursor` sends the cursor the previous response carried at `nextCursorPath` as `cursorParam`, or follows the absolute URL at `nextUrlPath` when that is what the source returns.",
            "type": "string",
            "enum": [
              "none",
              "page",
              "offset",
              "cursor"
            ]
          },
          "pageParam": {
            "description": "`page` only: the query parameter carrying the page number; defaults to `page`.",
            "type": "string",
            "maxLength": 100
          },
          "startPage": {
            "description": "`page` only: the first page's number, 0 or 1; defaults to 1.",
            "type": "integer",
            "minimum": 0,
            "maximum": 1
          },
          "sizeParam": {
            "description": "`page` and `offset`: the query parameter carrying the page size; omitted, no size is sent.",
            "type": "string",
            "maxLength": 100
          },
          "offsetParam": {
            "description": "`offset` only: the query parameter carrying the record offset; defaults to `offset`.",
            "type": "string",
            "maxLength": 100
          },
          "pageSize": {
            "description": "Records asked for per page, sent as `sizeParam`; defaults to 100. When `sizeParam` is named, a page shorter than this is the last one. Without it the source keeps its own page size, so only an empty page ends a `page` or `offset` pull.",
            "type": "integer",
            "minimum": 1,
            "maximum": 1000
          },
          "cursorParam": {
            "description": "`cursor` only: the query parameter the next page's cursor is sent as.",
            "type": "string",
            "maxLength": 100
          },
          "nextCursorPath": {
            "description": "`cursor` only: dotted path in the response body to the next page's cursor (for example `meta.next_cursor`); a null or missing value ends the job.",
            "type": "string",
            "maxLength": 200
          },
          "nextUrlPath": {
            "description": "`cursor` only, instead of `cursorParam`: dotted path to the absolute URL of the next page (for example `links.next`). It must be on the configured URL's origin.",
            "type": "string",
            "maxLength": 200
          }
        }
      },
      "ImportHttpSource": {
        "description": "An HTTP import source (#1078): a paginated JSON API the import worker pulls records from, with a workspace secret for authentication or, for a public source, none. Requests go through the same outbound guard the flows' HTTP step uses (HTTPS, public addresses only, no redirects, a bounded read per page). Every fetched record gains `_source` (the `source` label) and `_fetchedAt` (the fetch time) so lineage can be mapped onto fields like any other column.",
        "type": "object",
        "required": [
          "url",
          "auth",
          "pagination"
        ],
        "additionalProperties": false,
        "properties": {
          "url": {
            "description": "The absolute HTTPS URL of the records endpoint; its query may carry fixed filters.",
            "type": "string",
            "maxLength": 2000
          },
          "method": {
            "description": "The request method; `GET` by default. `POST` sends `body` as JSON. A page answered 429 is retried either way; a network failure or a 5xx is retried only for `GET`, since a `POST` may already have acted on the source.",
            "type": "string",
            "enum": [
              "GET",
              "POST"
            ],
            "default": "GET"
          },
          "query": {
            "description": "Fixed query parameters added to every request (filters such as a sector or a country).",
            "type": "object",
            "maxProperties": 50,
            "additionalProperties": {
              "type": "string",
              "maxLength": 500
            }
          },
          "headers": {
            "description": "Fixed request headers (an API version, an accept header). Credentials belong in `auth`, not here.",
            "type": "object",
            "maxProperties": 20,
            "additionalProperties": {
              "type": "string",
              "maxLength": 500
            }
          },
          "body": {
            "description": "`POST` only: the JSON body sent with every page request; pagination fields are added to the query, not the body.",
            "type": "object",
            "additionalProperties": true
          },
          "auth": {
            "$ref": "#/components/schemas/ImportHttpSourceAuth"
          },
          "pagination": {
            "$ref": "#/components/schemas/ImportHttpSourcePagination"
          },
          "recordsPath": {
            "description": "Dotted path from the response body to the array of records (for example `data` or `results.items`); omitted, the body itself must be the array.",
            "type": "string",
            "maxLength": 200
          },
          "maxRecords": {
            "description": "Stop after this many records; defaults to 10,000 and cannot exceed 50,000.",
            "type": "integer",
            "minimum": 1,
            "maximum": 50000
          },
          "source": {
            "description": "The lineage label written to every record's `_source` (for example `capiq`); defaults to the URL's host name.",
            "type": "string",
            "maxLength": 100
          }
        }
      },
      "ImportHttpSourceRequest": {
        "description": "Request body of `POST /imports/sources/http`: the source to pull from, and the file name the staged document is given.",
        "type": "object",
        "required": [
          "source"
        ],
        "additionalProperties": false,
        "properties": {
          "source": {
            "$ref": "#/components/schemas/ImportHttpSource"
          },
          "filename": {
            "description": "The name the fetched document is staged under, ending in `.json` and carrying no path separator; it seeds the proposed table name at analysis. Defaults to the source label.",
            "type": "string",
            "maxLength": 255,
            "pattern": "^[^/\\\\]+\\.json$"
          }
        }
      },
      "ImportFetchedSource": {
        "description": "What a `fetch_http` job produced: the staged JSON document, usable with `POST /imports/analyze`, `POST /imports/preview` and `POST /imports/jobs` exactly like an upload, and the lineage of the pull. The `s3Key` handle is returned only to the job creator and workspace admins — peers with `tables:read` still see pull lineage, but cannot open the credentialed document.",
        "type": "object",
        "required": [
          "filename",
          "sizeBytes",
          "rowsFetched",
          "pagesFetched",
          "source",
          "fetchedAt"
        ],
        "properties": {
          "s3Key": {
            "description": "The staged document's handle, in place of one from `POST /imports/uploads`. Omitted for callers who are neither the job creator nor a workspace admin; analyze/preview/import refuse the key for those callers even if reconstructed.",
            "type": "string"
          },
          "filename": {
            "description": "The document's file name, ending in `.json`.",
            "type": "string"
          },
          "sizeBytes": {
            "description": "Size of the staged document in bytes.",
            "type": "integer"
          },
          "rowsFetched": {
            "description": "Records pulled from the source across every page.",
            "type": "integer"
          },
          "pagesFetched": {
            "description": "Requests the pull took.",
            "type": "integer"
          },
          "source": {
            "description": "The lineage label every record carries as `_source`.",
            "type": "string"
          },
          "fetchedAt": {
            "description": "When the pull started, ISO-8601 UTC; every record carries it as `_fetchedAt`.",
            "type": "string",
            "format": "date-time"
          },
          "stoppedAtLimit": {
            "description": "True when the pull stopped at `maxRecords` with the source still offering more.",
            "type": "boolean"
          }
        }
      },
      "ImportMatchMode": {
        "type": "string",
        "enum": [
          "exact",
          "normalised",
          "similar"
        ],
        "description": "How a key's values compare. `exact`: the text forms are equal.\n`normalised`: equal after folding case, accents, whitespace and\npunctuation, reading `&` as \"and\", closing up dotted abbreviations\n(\"S.A.\" reads as \"SA\") and dropping a trailing legal form (Ltd, PLC,\nInc, GmbH, SA, B.V., …), so \"Barclays PLC\" and \"barclays plc.\" are\none key, and so are \"Banque Lutèce S.A.\" and \"Banque Lutece\".\n`similar`: the first key field compares by trigram similarity of the\nnormalised text, the others by normalised equality; a score at or\nabove `threshold` matches and the band below it is a possible match.\n"
      },
      "ImportMatchSpec": {
        "type": "object",
        "description": "The key that identifies an existing record for `duplicateHandling`\n`skip` or `update`: one to five mapped fields and how they compare.\nEvery field must exist on the target table, be written by the file,\nand be scalar (an address or a multipicklist has no text to match).\nIn `similar` mode the first field is the one compared by similarity;\nthe target table is read into memory for it, so a table past the\nsimilarity cap (50,000 records by default) is refused in that mode.\n",
        "required": [
          "fields"
        ],
        "additionalProperties": false,
        "properties": {
          "fields": {
            "type": "array",
            "minItems": 1,
            "maxItems": 5,
            "description": "The key's fields, by field name, in order; the first is the one `similar` compares by similarity.",
            "items": {
              "type": "string"
            }
          },
          "mode": {
            "$ref": "#/components/schemas/ImportMatchMode"
          },
          "salesforceIds": {
            "type": "boolean",
            "default": false,
            "description": "Compare every key value on its first 15 characters, so a\n15-character Salesforce Id and the 18-character form of the same\nrecord are one key (the last three characters are a checksum of\nthe first 15). Applies in `exact` and `normalised` modes, to the\nfile's rows and the table's records alike; a `similar` key\nignores it.\n"
          },
          "threshold": {
            "type": "number",
            "minimum": 0.5,
            "maximum": 1,
            "default": 0.8,
            "description": "`similar` only: the trigram similarity (0–1) at or above which a\nrecord is the match. Scores from 0.3 below it up to it are\nreported as possible matches for review.\n"
          }
        }
      },
      "ImportMatchDecision": {
        "type": "object",
        "description": "A reviewer's answer for one file row, made on the match preview:\nupdate the named record, insert the row as a new record, or skip it.\n`recordId` is required for `update` and must be a record the\nreviewer can see and update.\n\nWith `field`, the answer is for one REFERENCE CELL of the row\ninstead: a `resolveReference` rule that names a `mode` holds its\nuncertain and unmatched cells for a decision (`ImportPossibleMatch`\nwith the same `field`). `resolve` sets the cell to `recordId`, a\nrecord of the referenced table the reviewer can see; `skip` leaves\nthe cell empty. `update` and `insert` do not apply to a cell.\n",
        "required": [
          "rowNumber",
          "action"
        ],
        "additionalProperties": false,
        "properties": {
          "rowNumber": {
            "type": "integer",
            "minimum": 1,
            "description": "The 1-based data row the decision is for."
          },
          "field": {
            "type": "string",
            "description": "The reference field whose cell the decision settles, when it is\nfor a cell rather than for the row's own match. Absent for the row.\n"
          },
          "action": {
            "type": "string",
            "enum": [
              "update",
              "insert",
              "skip",
              "resolve"
            ],
            "description": "What the row does — overwrite `recordId`'s mapped fields, insert as\nnew, or not be written — or, with `field`, what the cell holds:\n`resolve` the named record, or `skip` to leave it empty.\n"
          },
          "recordId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The record to update (or, with `field`, to set the cell to), from the candidates; required when `action` is `update` or `resolve`."
          }
        }
      },
      "ImportMatchCandidate": {
        "type": "object",
        "description": "One existing record a row's key found, with how well it fits and the record's own key values.",
        "required": [
          "recordId",
          "score",
          "values"
        ],
        "properties": {
          "recordId": {
            "type": "string",
            "description": "The existing record's id."
          },
          "score": {
            "type": "number",
            "description": "1 for an exact or normalised hit; the trigram similarity for a similar one."
          },
          "values": {
            "type": "object",
            "description": "The record's values for the key fields, by field name, so a reviewer sees what matched.",
            "additionalProperties": true
          }
        }
      },
      "ImportPossibleMatch": {
        "type": "object",
        "description": "A row whose match was uncertain: several records fit, or the best\nsimilarity fell in the band below the threshold. Not written until a\n`matchDecisions` entry says how.\n\nWith `field`, it is one reference cell of the row that is uncertain:\na `resolveReference` rule naming a `mode` found several records,\nonly records below its threshold, or none at all (`unmatched`). The\nrow waits for a decision carrying the same `field`.\n",
        "required": [
          "rowNumber",
          "values",
          "candidates",
          "reason"
        ],
        "properties": {
          "rowNumber": {
            "type": "integer",
            "description": "1-based data row number within its file."
          },
          "file": {
            "type": "string",
            "description": "Filename of the source file the row came from."
          },
          "field": {
            "type": "string",
            "description": "The reference field whose cell is uncertain; absent when the row's own match key is."
          },
          "values": {
            "type": "object",
            "description": "The row's own key values, by field name, as the file gave them (for a cell, the key text it holds and any scope value).",
            "additionalProperties": true
          },
          "reason": {
            "type": "string",
            "enum": [
              "ambiguous",
              "below_threshold",
              "unmatched"
            ],
            "description": "Why it needs a decision — more than one record fits, the best\nscore is below the threshold, or (a reference cell only) no\nrecord of the referenced table fits at all.\n"
          },
          "candidates": {
            "type": "array",
            "description": "The records that fit, best first, at most five; empty for an `unmatched` cell.",
            "items": {
              "$ref": "#/components/schemas/ImportMatchCandidate"
            }
          }
        }
      },
      "ImportMatchOutcome": {
        "type": "object",
        "description": "One row the match settled, and how.",
        "required": [
          "rowNumber",
          "action",
          "decidedBy"
        ],
        "properties": {
          "rowNumber": {
            "type": "integer",
            "description": "1-based data row number within its file."
          },
          "file": {
            "type": "string",
            "description": "Filename of the source file the row came from."
          },
          "recordId": {
            "type": "string",
            "description": "The record the row matched; absent for a reviewer's `insert`."
          },
          "action": {
            "type": "string",
            "enum": [
              "update",
              "skip",
              "insert"
            ],
            "description": "What the row did — updated the record, was skipped as its duplicate, or was inserted by a reviewer's decision."
          },
          "score": {
            "type": "number",
            "description": "The match score (1 for exact and normalised); absent for a reviewer's `insert`."
          },
          "decidedBy": {
            "type": "string",
            "enum": [
              "rule",
              "reviewer"
            ],
            "description": "Whether the match rule settled the row on its own or a reviewer's decision did."
          }
        }
      },
      "ImportMatchPreviewRequest": {
        "type": "object",
        "description": "Request body of `POST /imports/matches`: run an import's key over the\nbounded sample of an uploaded file against an existing table and see\nwhich rows match, which are uncertain, and which records they fit —\nbefore anything is written. The caller's row scope applies, so a\nrecord they cannot see is never a candidate.\n",
        "required": [
          "s3Key",
          "tableId",
          "mapping",
          "match"
        ],
        "additionalProperties": false,
        "properties": {
          "s3Key": {
            "type": "string",
            "description": "Storage key of the uploaded file, as the upload endpoints returned it; must belong to this workspace's upload area."
          },
          "delimiter": {
            "type": "string",
            "description": "CSV field separator; omit to use the one the analysis detected."
          },
          "filename": {
            "type": "string",
            "description": "The upload's filename, required with `sourcePath` (a document is read by its extension)."
          },
          "sourcePath": {
            "type": "string",
            "description": "Document uploads only: which virtual table of the document to read, as the analysis named it."
          },
          "tableId": {
            "type": "string",
            "description": "The existing table the file loads into and whose records are matched."
          },
          "mapping": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "description": "The same column → field mapping the import takes, rules included.",
            "items": {
              "type": "object",
              "required": [
                "column",
                "fieldName"
              ],
              "properties": {
                "column": {
                  "type": "string",
                  "description": "Header of the source column in the file, exactly as the analysis reported it."
                },
                "fieldName": {
                  "type": "string",
                  "description": "Name of the target field this column fills, after any `rules` have transformed the value."
                },
                "rules": {
                  "$ref": "#/components/schemas/ImportColumnRules"
                }
              }
            }
          },
          "match": {
            "$ref": "#/components/schemas/ImportMatchSpec"
          },
          "options": {
            "$ref": "#/components/schemas/ImportJobOptions"
          },
          "maxRows": {
            "type": "integer",
            "minimum": 1,
            "maximum": 500,
            "default": 200,
            "description": "Sample rows to run the key over; the job itself reads every row."
          }
        }
      },
      "ImportMatchPreviewRow": {
        "type": "object",
        "description": "One sampled row that found at least one record, with the verdict the job would reach.",
        "required": [
          "rowNumber",
          "values",
          "verdict",
          "candidates"
        ],
        "properties": {
          "rowNumber": {
            "type": "integer",
            "description": "1-based data row number within the file."
          },
          "values": {
            "type": "object",
            "description": "The row's key values, by field name, as the mapping produced them.",
            "additionalProperties": true
          },
          "verdict": {
            "type": "string",
            "enum": [
              "match",
              "possible"
            ],
            "description": "`match`: the job would update or skip the one record; `possible`: it needs a decision."
          },
          "reason": {
            "type": "string",
            "enum": [
              "ambiguous",
              "below_threshold"
            ],
            "description": "For a `possible` verdict, why."
          },
          "candidates": {
            "type": "array",
            "description": "The records that fit, best first, at most five.",
            "items": {
              "$ref": "#/components/schemas/ImportMatchCandidate"
            }
          }
        }
      },
      "ImportMatchPreviewResponse": {
        "type": "object",
        "description": "Response of `POST /imports/matches`: the sampled rows that found a\nrecord, and a tally of the sample. Rows that found nothing are not\nlisted; they would insert.\n",
        "required": [
          "sampledRows",
          "sampled",
          "matched",
          "possible",
          "unmatched",
          "rows"
        ],
        "properties": {
          "sampledRows": {
            "type": "integer",
            "description": "Data rows read from the sample."
          },
          "sampled": {
            "type": "boolean",
            "description": "True when the file extends beyond the sample, so the job will see rows this preview did not."
          },
          "matched": {
            "type": "integer",
            "description": "Sampled rows with exactly one record at or above the threshold."
          },
          "possible": {
            "type": "integer",
            "description": "Sampled rows that need a decision."
          },
          "unmatched": {
            "type": "integer",
            "description": "Sampled rows that found no record and would insert."
          },
          "rows": {
            "type": "array",
            "description": "The matched and possible rows, in file order.",
            "items": {
              "$ref": "#/components/schemas/ImportMatchPreviewRow"
            }
          }
        }
      },
      "ImportMatchHistory": {
        "type": "object",
        "description": "How an import matched this record before updating it: the key's mode\nand fields, the score, and whether the rule or a reviewer decided.\n",
        "required": [
          "jobId",
          "mode",
          "fields",
          "score",
          "decidedBy"
        ],
        "properties": {
          "jobId": {
            "type": "string",
            "description": "The import job that made the change."
          },
          "mode": {
            "$ref": "#/components/schemas/ImportMatchMode"
          },
          "fields": {
            "type": "array",
            "description": "The key's fields, by field name.",
            "items": {
              "type": "string"
            }
          },
          "score": {
            "type": "number",
            "description": "The match score (1 for exact and normalised)."
          },
          "decidedBy": {
            "type": "string",
            "enum": [
              "rule",
              "reviewer"
            ],
            "description": "Whether the match rule settled the row or a reviewer's decision did."
          }
        }
      },
      "ImportJob": {
        "description": "One import run: its kind and lifecycle status, live progress, and on completion the result and, for a failed job, the terminal error. A job that failed because rows did not validate (an atomic import, or skipInvalid false) still carries a `result` with its `rowErrors`, so the rows to fix are read from the failed job rather than a second dry run. Returned when a job is created or cancelled, from the jobs list, and when polled by id.",
        "type": "object",
        "required": [
          "id",
          "kind",
          "status",
          "dryRun",
          "progress",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Identifier of the job, used to poll `GET /imports/jobs/{jobId}` and to cancel it."
          },
          "kind": {
            "type": "string",
            "x-known-values": "KnownImportJobKind",
            "description": "Lifecycle vocabulary: the values known to this version are enumerated by the KnownImportJobKind schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed (this set grows)."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownImportJobStatus",
            "description": "Lifecycle vocabulary: the values known to this version are enumerated by the KnownImportJobStatus schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed (this set grows)."
          },
          "dryRun": {
            "type": "boolean",
            "description": "True when the job only validates: it reports what would be inserted, updated or rejected and writes nothing."
          },
          "progress": {
            "description": "Where the job is right now, updated as it runs; final counts are in `result` once it finishes.",
            "type": "object",
            "required": [
              "phase",
              "processedRows"
            ],
            "properties": {
              "phase": {
                "type": "string",
                "x-known-values": "KnownImportJobPhase",
                "description": "Lifecycle vocabulary (job state machine): the values known to this version are enumerated by the KnownImportJobPhase schema (see x-known-values). Open by contract — clients MUST tolerate values not yet listed (this set grows)."
              },
              "processedRows": {
                "type": "integer",
                "description": "Rows consumed so far across the job's files, whether they were written, skipped or rejected."
              },
              "totalRows": {
                "type": "integer",
                "description": "Estimated until the file has been fully read once"
              },
              "currentFile": {
                "type": "string",
                "description": "Filename of the file being processed; absent before the job starts and for jobs with no file phase."
              }
            }
          },
          "result": {
            "$ref": "#/components/schemas/ImportJobResult"
          },
          "mapping": {
            "$ref": "#/components/schemas/ImportMappingResolution"
          },
          "error": {
            "type": "string",
            "description": "Terminal failure message (failed jobs only)"
          },
          "cancelRequested": {
            "type": "boolean",
            "description": "True once a cancel has been asked for. A job still queued is cancelled at once; a running one stops at its next checkpoint and then reports `cancelled`."
          },
          "createdBy": {
            "type": "string",
            "description": "User id of the member who started the import."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the job was queued, ISO-8601 UTC."
          },
          "startedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When a worker picked the job up, ISO-8601 UTC; absent while it is still queued."
          },
          "finishedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the job reached a terminal status (succeeded, failed or cancelled), ISO-8601 UTC; absent until then."
          },
          "revertableUntil": {
            "type": "string",
            "format": "date-time",
            "description": "Until when this import may be reverted (`POST /imports/jobs/{jobId}/revert`), ISO-8601 UTC: the job finished within the workspace's revert window, created at least one record, and has no revert queued, running or completed. Absent otherwise."
          },
          "revert": {
            "$ref": "#/components/schemas/ImportJobRevertRef"
          },
          "revertOfJobId": {
            "type": "string",
            "description": "On a `revert` job, the identifier of the import it reverts."
          }
        }
      },
      "ImportJobRejection": {
        "description": "The 400 body of `POST /imports/jobs` when nothing was enqueued: a human-readable reason and, when the schema plan was the problem, the teaching issues from plan validation.",
        "type": "object",
        "required": [
          "message"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "Human-readable reason nothing was enqueued (invalid plan, files or options), suitable for showing to the user."
          },
          "code": {
            "type": "string",
            "description": "A stable code for a refusal a client can act on without parsing the message: `FIELD_TYPE_NOT_IMPORTABLE` when a file maps a column onto a field type the import cannot write (a `polymorphicReference`); `SANDBOX_ONLY` when a `stageHistory` file asks to `replace` history on a workspace that is not a sandbox; `WRITE_AUTONUMBER_UNSUPPORTED` when `options.writeAutonumber` is combined with `atomic` or with `update` duplicate handling. Absent for other refusals."
          },
          "issues": {
            "type": "array",
            "description": "Plan-validation issues when the schema plan was invalid",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          }
        }
      },
      "Flow": {
        "description": "A flow's metadata row: name, enabled state, trigger kind, which version is published and which is the editable draft, and its recent run health. Does not carry the flow document itself; that lives on the versions. Returned by `PATCH /flows/{flowId}`, as the items of `FlowList`, and embedded in `FlowDetail` and `PublishFlowResult`.",
        "type": "object",
        "required": [
          "id",
          "apiName",
          "name",
          "enabled",
          "triggerKind",
          "runAsMode",
          "publishedVersion",
          "consecutiveFailures",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the flow, used in every `/flows/{flowId}` path.",
            "type": "string"
          },
          "apiName": {
            "$ref": "#/components/schemas/ApiName"
          },
          "name": {
            "description": "Display name of the flow.",
            "type": "string"
          },
          "description": {
            "description": "What the flow is for, in the author's words; null when none was given.",
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "description": "Whether the flow fires. False when an admin switched it off or the engine disabled it after repeated failures (see `disabledReason`); re-enabling resets the failure counter.",
            "type": "boolean"
          },
          "triggerKind": {
            "type": "string",
            "x-known-values": "KnownFlowTriggerKind",
            "description": "Denormalized from the published (or draft) trigger. Open vocabulary: clients must tolerate a kind this build does not know."
          },
          "tableId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The trigger table for record_event flows; null otherwise."
          },
          "runAsMode": {
            "type": "string",
            "x-known-values": "KnownFlowRunAsMode",
            "description": "Open vocabulary: clients must tolerate a mode this build does not know."
          },
          "publishedVersion": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The published version number, or null while only a draft exists."
          },
          "publishedVersionId": {
            "description": "The version whose document currently runs; null while the flow has only ever been a draft.",
            "type": [
              "string",
              "null"
            ]
          },
          "draftVersionId": {
            "description": "The version being edited. Always present: every flow has exactly one draft, and publishing it starts a new one.",
            "type": "string"
          },
          "inboundHookConfigured": {
            "type": "boolean",
            "description": "True when an inbound-webhook token is registered (the token itself is never returned after mint)."
          },
          "consecutiveFailures": {
            "description": "Failed runs in a row since the last success. Reaching the auto-disable threshold switches the flow off; a successful run or re-enabling resets it to 0.",
            "type": "integer"
          },
          "disabledReason": {
            "description": "Why the engine disabled the flow when it was not an admin: `auto_failures` after too many consecutive failed runs, `legacy_automation` for a flow carried over from the old automation system, `restored` for a flow that was on in a workspace backup and came back switched off in the restored workspace. Null when enabled, or disabled by hand.",
            "type": [
              "string",
              "null"
            ]
          },
          "lastRunAt": {
            "description": "When the flow last finished a run, ISO-8601 UTC; null until it has run at least once.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastError": {
            "description": "Message from the most recent failed run, truncated; null after a successful run or a re-enable.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdBy": {
            "description": "User id of the member who created the flow; null when not recorded.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the flow was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the flow's metadata last changed (rename, enable/disable, publish, run outcome), ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FlowDetail": {
        "description": "A flow with its mutable draft document attached — the shape the builder edits. Returned by `POST /flows` and `GET /flows/{flowId}`; list responses carry the plain `Flow` without the draft.",
        "allOf": [
          {
            "$ref": "#/components/schemas/Flow"
          },
          {
            "type": "object",
            "required": [
              "draftDocument"
            ],
            "properties": {
              "draftDocument": {
                "description": "The mutable draft FlowDocument. Deliberately untyped — the builder round-trips it and the Zod validator is the authority."
              }
            }
          }
        ]
      },
      "FlowList": {
        "description": "Every flow in the workspace. Response of `GET /flows`.",
        "type": "object",
        "required": [
          "flows"
        ],
        "properties": {
          "flows": {
            "description": "Every flow in the workspace, with its version summaries; no paging.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Flow"
            }
          }
        }
      },
      "CreateFlowRequest": {
        "description": "Request body of `POST /flows`: creates a flow together with its first draft version from the supplied FlowDocument.",
        "type": "object",
        "required": [
          "name",
          "runAsMode",
          "document"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "description": "Display name of the flow, unique within the workspace; up to 63 characters.",
            "type": "string",
            "minLength": 1,
            "maxLength": 63
          },
          "apiName": {
            "description": "The flow's API name. Omit it and one is derived from `name` and made unique. One another flow already has is refused with 409. It cannot be changed later.",
            "allOf": [
              {
                "$ref": "#/components/schemas/ApiName"
              }
            ]
          },
          "description": {
            "description": "Free-text note on what the flow does, shown in the flow list; null or omitted for none.",
            "type": [
              "string",
              "null"
            ]
          },
          "runAsMode": {
            "description": "Whose permissions runs use. `initiating_user`: the user whose action triggered the run, resolved at execution time (not allowed with a schedule trigger, which has no such user). `automation_identity`: the flow's own principal, with the roles granted to it.",
            "type": "string",
            "enum": [
              "initiating_user",
              "automation_identity"
            ]
          },
          "document": {
            "description": "The initial draft FlowDocument. Deliberately untyped; saved with lenient validation like the draft autosave (hard structural errors 400 with teaching issues)."
          }
        }
      },
      "UpdateFlowRequest": {
        "description": "Request body of `PATCH /flows/{flowId}`: a partial update of the flow's settings (omitted fields are unchanged). The trigger and blocks are edited on the draft version, not here.",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "description": "New name of the flow (1–63 characters).",
            "type": "string",
            "minLength": 1,
            "maxLength": 63
          },
          "description": {
            "description": "New free-text description; null clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "description": "Whether the flow may run. Sending `true` also resets `consecutiveFailures`, `disabledReason` and `lastError`, so a flow the platform auto-disabled starts clean; `false` stops new runs and clears `disabledReason`.",
            "type": "boolean"
          },
          "runAsMode": {
            "description": "Whose permissions a run resolves under: `initiating_user` — the user whose action triggered it (so it can only read and write what they can); `automation_identity` — the workspace's automation principal, independent of who triggered it.",
            "type": "string",
            "enum": [
              "initiating_user",
              "automation_identity"
            ]
          }
        }
      },
      "SaveFlowDraftRequest": {
        "description": "Request body of `PUT /flows/{flowId}/draft`: replace the flow's unpublished draft document. Saving a draft publishes nothing; the published version keeps running unchanged until the draft is published.",
        "type": "object",
        "required": [
          "document"
        ],
        "additionalProperties": false,
        "properties": {
          "document": {
            "description": "The draft FlowDocument to store. Deliberately untyped."
          }
        }
      },
      "FlowDraftSaveResult": {
        "description": "Response of `PUT /flows/{flowId}/draft`: the teaching issues found in the draft that was just saved. The save succeeded; the issues are for the builder to render.",
        "type": "object",
        "required": [
          "issues"
        ],
        "properties": {
          "issues": {
            "type": "array",
            "description": "Teaching issues for the saved draft — warnings save fine; hard structural errors 400 instead.",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          }
        }
      },
      "PublishFlowResult": {
        "description": "Outcome of publishing a flow draft: the flow as it now stands, the new immutable version number, any non-blocking warnings and, once only, a freshly minted inbound-webhook token. Response of `POST /flows/{flowId}/publish`.",
        "type": "object",
        "required": [
          "flow",
          "version",
          "issues"
        ],
        "properties": {
          "flow": {
            "$ref": "#/components/schemas/Flow"
          },
          "version": {
            "type": "integer",
            "description": "The newly published (immutable) version number."
          },
          "issues": {
            "type": "array",
            "description": "Non-blocking warnings that survived strict validation.",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "inboundToken": {
            "type": [
              "string",
              "null"
            ],
            "description": "Present exactly once, when this publish minted an inbound-webhook token (the flow became — or republished as — an inbound_webhook flow with no token yet). Only its hash is stored."
          },
          "inboundHookPath": {
            "type": [
              "string",
              "null"
            ],
            "description": "The full hook path for the freshly minted token; null otherwise."
          }
        }
      },
      "FlowVersionSummary": {
        "description": "One version of a flow without its document, an item of `FlowVersionList.versions`; a flow always has exactly one draft and zero or more published or archived versions.",
        "type": "object",
        "required": [
          "id",
          "version",
          "state",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of this version row; `Flow.publishedVersionId` and `Flow.draftVersionId` point at these.",
            "type": "string"
          },
          "version": {
            "description": "1-based version number within the flow, increasing by one with each publish.",
            "type": "integer"
          },
          "state": {
            "type": "string",
            "x-known-values": "KnownFlowVersionState",
            "description": "Open vocabulary: clients must tolerate a state this build does not know."
          },
          "publishedAt": {
            "description": "When the version was published and became immutable, ISO-8601 UTC; null while it is still the draft.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "description": "When the version row was created, ISO-8601 UTC — for a draft, when the previous version was published (or the flow created).",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FlowVersionList": {
        "description": "Response of `GET /flows/{flowId}/versions`: every version of the flow, newest first.",
        "type": "object",
        "required": [
          "versions"
        ],
        "properties": {
          "versions": {
            "description": "The flow's versions, newest first; each carries its number, state and publish time.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FlowVersionSummary"
            }
          }
        }
      },
      "FlowVersionDetail": {
        "description": "Response of `GET /flows/{flowId}/versions/{version}`: a version's summary together with its full FlowDocument.",
        "allOf": [
          {
            "$ref": "#/components/schemas/FlowVersionSummary"
          },
          {
            "type": "object",
            "required": [
              "document"
            ],
            "properties": {
              "document": {
                "description": "The version's FlowDocument (immutable once published). Untyped."
              }
            }
          }
        ]
      },
      "FlowTestRunRequest": {
        "description": "Request body of `POST /flows/{flowId}/test-runs`. All properties are optional and which ones apply depends on the flow's trigger: a record-event flow is run against a sample record, either replaying one of its recorded events or synthesizing one from its current state; an inbound-webhook flow is run against a sample payload.",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "sampleItemId": {
            "type": "string",
            "description": "For record_event flows — the record to run against, loaded under the CALLER's row visibility."
          },
          "sampleEventId": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$",
            "description": "For record_event flows — REPLAY a real recorded event on `sampleItemId` (an entry id from `GET /tables/{tableId}/items/{itemId}/history`). The run gets that event's own before/after states and type, so `changed`/`changedTo` conditions and `{{changes.*}}` references behave exactly as they did when it fired. Ignored without `sampleItemId`, and refused when the event is not one of that record's own."
          },
          "sampleEventType": {
            "type": "string",
            "enum": [
              "ItemCreated",
              "ItemUpdated",
              "ItemDeleted",
              "ApprovalRequested",
              "ApprovalDecided"
            ],
            "description": "For record_event flows — SYNTHESIZE an event of this type from the record's CURRENT state, when no recorded event is being replayed (default `ItemCreated`, else the trigger's first event type). The shape matches what that event really carries: a delete has only a before-state, an approval event has none. There is no *changed* before-state to invent, so a synthesized `ItemUpdated` carries the current values on both sides and cannot match `changed`/`changedTo` — replay a real event for that. Must be one of the trigger's own event types."
          },
          "samplePayload": {
            "description": "For inbound_webhook flows — the body a webhook caller would send. Untyped."
          }
        }
      },
      "FlowSampleRecord": {
        "type": "object",
        "required": [
          "id",
          "label"
        ],
        "description": "One candidate record to test a record-event flow against, labelled the way the app titles that record (the layout's title field, else the first readable text field, else the id).",
        "properties": {
          "id": {
            "description": "The record's id, to pass as `sampleItemId` in a test run.",
            "type": "string"
          },
          "label": {
            "description": "How the app titles this record (its title field, else the first readable text field, else the id), for the picker.",
            "type": "string"
          },
          "updatedAt": {
            "description": "When the record last changed, ISO-8601 UTC; recent records are the likeliest test subjects. Null when the record has never been updated.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "FlowSampleRecordList": {
        "description": "Response of `GET /flows/{flowId}/sample-records`: records of the flow's draft trigger table, most recently updated first, for the builder's test panel to pick from.",
        "type": "object",
        "required": [
          "options",
          "truncated"
        ],
        "properties": {
          "options": {
            "description": "Candidate records to test the flow against, most recently updated first and narrowed by `q`. Each carries the record id and the label the app titles it with.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FlowSampleRecord"
            }
          },
          "truncated": {
            "type": "boolean",
            "description": "True when more records match than were returned — narrow with `q`."
          }
        }
      },
      "FlowTestRunResult": {
        "description": "Response (202) of `POST /flows/{flowId}/test-runs` and `POST /flows/{flowId}/record-runs`: the identifier of the run just enqueued. The run executes asynchronously; follow it through the flow's runs endpoints.",
        "type": "object",
        "required": [
          "runId"
        ],
        "properties": {
          "runId": {
            "description": "Id of the enqueued flow run. Pass it to the flow's run endpoints to follow its progress and read its steps.",
            "type": "string"
          }
        }
      },
      "FlowRecordRunRequest": {
        "description": "Names the record a record-action flow should run against. Request body of `POST /flows/{flowId}/record-runs`, the manual \"run on this record\" button; the record is loaded under the caller's own row visibility.",
        "type": "object",
        "required": [
          "itemId"
        ],
        "additionalProperties": false,
        "properties": {
          "itemId": {
            "type": "string",
            "description": "The record to run the flow against, loaded under the CALLER's row visibility."
          }
        }
      },
      "FlowApprovalRequest": {
        "description": "An approval raised by a flow's `approval` block: the run parks until a routed approver decides or the block's timeout expires. Listed in the approvals inbox (`FlowApprovalRequestList`) and returned, updated, by `POST /flow-approvals/{approvalId}/decide`.",
        "type": "object",
        "required": [
          "id",
          "runId",
          "flowId",
          "title",
          "status",
          "createdAt",
          "canDecide"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the approval request; the `approvalId` of `POST /flow-approvals/{approvalId}/decide`.",
            "type": "string"
          },
          "runId": {
            "description": "The flow run parked on this approval; deciding wakes it.",
            "type": "string"
          },
          "flowId": {
            "description": "The flow whose `approval` block raised the request.",
            "type": "string"
          },
          "flowName": {
            "description": "The flow's current name, resolved on read; null if the flow has since been deleted.",
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "description": "Short heading for the inbox, rendered by the block from the run's masked context (so it may quote field values the run could read).",
            "type": "string"
          },
          "detail": {
            "description": "Longer explanation for the approver, rendered from the run's masked context like `title`; null when the block configured none.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownFlowApprovalStatus",
            "description": "Open vocabulary: clients must tolerate a status this build does not know (render it verbatim, and treat anything that is not `pending` as already settled)."
          },
          "decidedBy": {
            "description": "The user who approved or rejected it; null while `pending` and on an `expired` request.",
            "type": [
              "string",
              "null"
            ]
          },
          "decidedByName": {
            "description": "Display name of `decidedBy`, resolved on read; null when nobody decided.",
            "type": [
              "string",
              "null"
            ]
          },
          "comment": {
            "description": "The decider's optional note, given with the decision; null when none was given or no decision has been made.",
            "type": [
              "string",
              "null"
            ]
          },
          "expiresAt": {
            "description": "When the block's timeout lapses, ISO-8601 UTC; once past, a still-pending request becomes `expired` when the run wakes and the flow takes its timeout path. Null when the block has no timeout.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "description": "When the block raised the request and parked the run, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "decidedAt": {
            "description": "When the request left `pending` — by decision or by expiry — ISO-8601 UTC; null while pending.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "canDecide": {
            "type": "boolean",
            "description": "Whether the CALLING user matches the request's frozen approver route (drives the inbox buttons)."
          }
        }
      },
      "FlowApprovalRequestList": {
        "description": "Response of `GET /flow-approvals`: the flow approval requests routed to the caller (their approvals inbox), newest first.",
        "type": "object",
        "required": [
          "requests"
        ],
        "properties": {
          "requests": {
            "description": "The requests routed to the caller, newest first; filtered by the `status` query parameter when one was given.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FlowApprovalRequest"
            }
          }
        }
      },
      "FlowApprovalDecisionRequest": {
        "description": "Request body of `POST /flow-approvals/{approvalId}/decide`: the approver's verdict on a flow's pending approval request. Rejection is data to the flow, not a failure of the run.",
        "type": "object",
        "required": [
          "approved"
        ],
        "additionalProperties": false,
        "properties": {
          "approved": {
            "description": "True to approve, false to reject. Either way the parked run wakes; a rejection surfaces to the flow as `approved: false` rather than failing the run.",
            "type": "boolean"
          },
          "comment": {
            "description": "Optional note from the decider, stored with the decision and exposed to the flow and to anyone reading the request. An empty string is stored as no comment.",
            "type": "string",
            "maxLength": 2000
          }
        }
      },
      "FlowBlockTestRequest": {
        "description": "Request body of `POST /flows/{flowId}/blocks/test`: one pure or read-only block to dry-run synchronously under the caller's own permissions, with optional sample outputs standing in for earlier steps.",
        "type": "object",
        "required": [
          "block"
        ],
        "additionalProperties": false,
        "properties": {
          "block": {
            "description": "One block config to dry-run. Untyped; only pure/read-only kinds execute (code, condition, find_records, run_query) — anything else is refused with a teaching error."
          },
          "upstreamOutputs": {
            "description": "Optional map of step id → sample output, exposed as steps.* to the block's templates/conditions. Untyped."
          }
        }
      },
      "FlowBlockTestResult": {
        "description": "Response of `POST /flows/{flowId}/blocks/test`: the outcome of synchronously dry-running one pure or read-only block. `ok: true` carries the block's output; `ok: false` carries a teaching error, and for a block that did not parse the structured validation issues as well.",
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "description": "True when the block ran and `output` holds its result. False when it did not parse, failed, touched something the caller may not read, or has side effects and cannot be dry-tested; `error` says which.",
            "type": "boolean"
          },
          "output": {
            "description": "The block's output when ok. Untyped."
          },
          "error": {
            "description": "Human-readable explanation when `ok` is false, written to teach (what was wrong and what to do instead). Absent or null when `ok` is true.",
            "type": [
              "string",
              "null"
            ]
          },
          "issues": {
            "description": "Structured validation issues (code, path, message) when the block configuration itself did not parse. Absent when the block was well-formed.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          }
        }
      },
      "FlowRun": {
        "description": "One execution of a flow: what triggered it, the record it ran against, its lifecycle status and timing. Returned by `GET /flows/runs/{runId}` and `POST /flows/runs/{runId}/cancel`, and listed in `FlowRunList`.",
        "type": "object",
        "required": [
          "id",
          "flowId",
          "triggerSource",
          "status",
          "isTest",
          "stepsExecuted",
          "attempts",
          "createdAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the run; use it with `GET /flows/runs/{runId}` and the cancel endpoint.",
            "type": "string"
          },
          "flowId": {
            "description": "The flow this run executes.",
            "type": "string"
          },
          "flowVersionId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The pinned published version; null for draft test runs."
          },
          "triggerSource": {
            "type": "string",
            "x-known-values": "KnownFlowRunTriggerSource",
            "description": "Open vocabulary: clients must tolerate a source this build does not know."
          },
          "eventType": {
            "description": "For a `record_event` trigger, the record event that fired it (`ItemCreated`, `ItemUpdated`, `ItemDeleted`, ...). Null for scheduled, webhook, action and test runs.",
            "type": [
              "string",
              "null"
            ]
          },
          "tableId": {
            "description": "Table of the record the run is about; null when the trigger carries no record (a schedule, for example).",
            "type": [
              "string",
              "null"
            ]
          },
          "itemId": {
            "description": "The record the run is about; null when the trigger carries no record.",
            "type": [
              "string",
              "null"
            ]
          },
          "initiatingUserId": {
            "description": "User whose action caused the run (the record writer, the person who ran a record action or started a test); null when nothing a user did started it, such as a schedule or inbound webhook.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownFlowRunStatus",
            "description": "Open vocabulary: clients must tolerate a status this build does not know (render it verbatim, treat it as non-terminal)."
          },
          "skipReason": {
            "description": "Why the run ended as `skipped`: `condition` (the trigger condition was false), `permission` (the run principal could not read the record), `approval` (a pending approval blocked it), `stale` (the record changed after the event), or `disabled` (the flow was turned off). Null for any other status.",
            "type": [
              "string",
              "null"
            ]
          },
          "waitingKind": {
            "description": "While `status` is `waiting`, what the run is parked on: `wait` for a timed wait block, `approval` for an approval block. Open vocabulary; null when not waiting.",
            "type": [
              "string",
              "null"
            ]
          },
          "wakeAt": {
            "description": "When a waiting run resumes (or an approval wait times out), ISO-8601 UTC. Null when not waiting.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "isTest": {
            "description": "True for a run started from the builder against the draft document; test runs do not count toward the failure threshold that disables a flow.",
            "type": "boolean"
          },
          "stepsExecuted": {
            "description": "Number of distinct blocks the run has executed so far, from the run ledger; a block re-entered after a wait is counted once.",
            "type": "integer"
          },
          "executionMs": {
            "description": "Total time spent executing blocks, in milliseconds, excluding time parked in waits or approvals. Null until the run has executed something.",
            "type": [
              "integer",
              "null"
            ]
          },
          "attempts": {
            "description": "How many times a worker has claimed this run, including the current one. Grows when a crashed or stalled attempt is reclaimed; a run that keeps exceeding the limit fails terminally.",
            "type": "integer"
          },
          "lastError": {
            "description": "Message of the error that failed the run or its latest attempt. Null while nothing has failed.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When the run was enqueued, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "startedAt": {
            "description": "When a worker first began executing the run, ISO-8601 UTC. Null while still queued.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "finishedAt": {
            "description": "When the run reached a terminal status (succeeded, failed, skipped, cancelled), ISO-8601 UTC. Null while queued, running or waiting.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "FlowRunList": {
        "description": "A page of flow runs. Response of `GET /flows/{flowId}/runs` (one flow) and `GET /flows/runs` (across the workspace).",
        "type": "object",
        "required": [
          "runs"
        ],
        "properties": {
          "runs": {
            "description": "The runs matching the request, newest first, within the page the query parameters selected.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FlowRun"
            }
          }
        }
      },
      "FlowRunStep": {
        "description": "The execution ledger entry for one block of one flow run: its status, attempts, timing, masked input/output and any error. Item of the `FlowRunStepList` returned for a run.",
        "type": "object",
        "required": [
          "id",
          "runId",
          "stepPath",
          "blockId",
          "blockType",
          "status",
          "attempts"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of this ledger entry.",
            "type": "string"
          },
          "runId": {
            "description": "The flow run this step belongs to.",
            "type": "string"
          },
          "stepPath": {
            "description": "Where the block sits in the flow: its block id, prefixed by the ids of the enclosing branch/iterate blocks separated by `/`. Unique within a run, so a block inside a loop has one entry per iteration path.",
            "type": "string"
          },
          "blockId": {
            "description": "The id of the block in the flow version's document that this step executed.",
            "type": "string"
          },
          "blockType": {
            "description": "The block's kind (`condition`, `branch`, `iterate`, `wait`, `approval`, `send_email`, `code`, …), denormalized so the ledger reads without the flow document.",
            "type": "string"
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownFlowRunStepStatus",
            "description": "Open vocabulary: clients must tolerate a status this build does not know."
          },
          "attempts": {
            "description": "How many times the block has been tried, starting at 1; a failed attempt is retried with backoff until the per-step maximum, after which the step and the run fail.",
            "type": "integer"
          },
          "input": {
            "description": "Rendered step config (secret-scrubbed). Null once payload-pruned. Untyped."
          },
          "output": {
            "description": "Stored step output (post-mask). Null once payload-pruned. Untyped."
          },
          "error": {
            "description": "The last attempt's error message; null while the step is succeeding or waiting.",
            "type": [
              "string",
              "null"
            ]
          },
          "executionMs": {
            "description": "Wall-clock duration of the last attempt in milliseconds; null until an attempt has finished.",
            "type": [
              "integer",
              "null"
            ]
          },
          "startedAt": {
            "description": "When the first attempt began, ISO-8601 UTC; null if the step was skipped before it ran.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "finishedAt": {
            "description": "When the step reached a terminal status, ISO-8601 UTC; null while running or waiting.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "FlowRunStepList": {
        "description": "Response of `GET /flows/runs/{runId}/steps`: the step traces of one flow run in execution order.",
        "type": "object",
        "required": [
          "steps"
        ],
        "properties": {
          "steps": {
            "description": "The run's steps in execution order; per-step input/output payloads are present only for callers who hold `flows:update` or `flows:execute`.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FlowRunStep"
            }
          }
        }
      },
      "FlowStatsDay": {
        "description": "One day's run outcomes for a flow, an item of `FlowStats.days`: counts by terminal status plus the time spent executing, from the per-flow daily rollup.",
        "type": "object",
        "required": [
          "day",
          "succeeded",
          "failed",
          "skipped",
          "cancelled",
          "executionMs"
        ],
        "properties": {
          "day": {
            "description": "Calendar date (UTC) runs are attributed to by their creation time, `YYYY-MM-DD`.",
            "type": "string",
            "format": "date"
          },
          "succeeded": {
            "description": "Runs created that day that finished with status `succeeded`.",
            "type": "integer"
          },
          "failed": {
            "description": "Runs created that day that finished with status `failed`.",
            "type": "integer"
          },
          "skipped": {
            "description": "Runs created that day that finished with status `skipped` (the trigger fired but the run did nothing).",
            "type": "integer"
          },
          "cancelled": {
            "description": "Runs created that day that were cancelled before finishing.",
            "type": "integer"
          },
          "executionMs": {
            "description": "Total execution time of that day's finished runs, in milliseconds, summed across runs.",
            "type": "integer"
          }
        }
      },
      "FlowStats": {
        "description": "Response of `GET /flows/{flowId}/stats`: the flow's run outcomes bucketed by day over the requested window, oldest first, for the health view.",
        "type": "object",
        "required": [
          "days"
        ],
        "properties": {
          "days": {
            "description": "One entry per calendar day in the requested window, oldest first: counts of runs that succeeded, failed, were skipped or cancelled, and the total execution time in milliseconds.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FlowStatsDay"
            }
          }
        }
      },
      "InboundFlowHookResult": {
        "description": "Acknowledgement of an inbound webhook delivery: the run it was turned into. Response (202) of `POST /hooks/flows/{workspaceId}/{flowId}/{token}`.",
        "type": "object",
        "required": [
          "runId"
        ],
        "properties": {
          "runId": {
            "description": "Identifier of the run the delivery was enqueued as; readable at `GET /flows/runs/{runId}` by an authenticated member.",
            "type": "string"
          }
        }
      },
      "PlanIssue": {
        "description": "One finding from validating or applying a plan document (schema plan, dashboard plan, import analysis): where it is, what is wrong and, where known, how to fix it. Errors block an apply; warnings and info findings do not. A schema plan may acknowledge a warning or info code (`acknowledge` on the plan, `intentional: true` on a field) so re-validation stays quiet; an error can never be acknowledged.",
        "type": "object",
        "required": [
          "severity",
          "code",
          "path",
          "message"
        ],
        "properties": {
          "severity": {
            "description": "`error` — the plan cannot be applied until this is fixed; `warning` — advice the apply proceeds despite, worth a look; `info` — a shape the validator noticed but could not corroborate (the author's own description of the field says it is a different fact), reported so it can be acknowledged, never something to act on.",
            "type": "string",
            "enum": [
              "error",
              "warning",
              "info"
            ]
          },
          "code": {
            "type": "string",
            "description": "Stable machine-readable code, e.g. REF_LABEL_NOT_UNIQUE"
          },
          "path": {
            "type": "string",
            "description": "Location in the plan document, e.g. createTables[1].fields[2].reference.table"
          },
          "message": {
            "description": "Human-readable statement of the problem, written to teach: it names the offending value and what was expected.",
            "type": "string"
          },
          "suggestion": {
            "type": "string",
            "description": "How to fix the issue"
          }
        }
      },
      "ValidationIssue": {
        "description": "One problem found in a submitted document, located by path. Item of `ValidationErrorResponse.issues`.",
        "type": "object",
        "required": [
          "path",
          "message"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "Location of the problem in the submitted document, e.g. action.recipients[0]."
          },
          "message": {
            "description": "Human-readable explanation of what is wrong at `path` and how to fix it, suitable for showing beside the offending field.",
            "type": "string"
          }
        }
      },
      "ValidationErrorResponse": {
        "description": "400 body when a submitted document fails validation, listing each problem by its location so the client can point at the offending field. Returned by the approval-rule endpoints.",
        "type": "object",
        "required": [
          "error",
          "issues"
        ],
        "properties": {
          "error": {
            "description": "Short human-readable summary of the failure (\"Invalid approval rule\"). The detail is in `issues`.",
            "type": "string"
          },
          "issues": {
            "type": "array",
            "description": "Per-field teaching issues explaining how to fix the request.",
            "items": {
              "$ref": "#/components/schemas/ValidationIssue"
            }
          }
        }
      },
      "SchemaPlanStats": {
        "description": "How many objects a schema plan creates (or would create), by kind; with `skipped`, the whole account of a reconcile apply. Carried on validation results, apply results and the assistant's proposed plans.",
        "type": "object",
        "required": [
          "newTables",
          "newFields",
          "newConstraints",
          "newAutomations",
          "newViews"
        ],
        "properties": {
          "newTables": {
            "description": "Tables the plan creates.",
            "type": "integer"
          },
          "newFields": {
            "description": "Fields the plan adds, across new and existing tables.",
            "type": "integer"
          },
          "newConstraints": {
            "description": "Constraints (unique, required, check) the plan adds.",
            "type": "integer"
          },
          "newAutomations": {
            "description": "Flows the plan creates. The legacy name is kept on the wire.",
            "type": "integer"
          },
          "newViews": {
            "description": "SQL views the plan creates.",
            "type": "integer"
          },
          "skipped": {
            "$ref": "#/components/schemas/SchemaPlanSkippedStats"
          }
        }
      },
      "SchemaPlanSkippedStats": {
        "type": "object",
        "description": "What the plan asked for that was already present and matched, so\nnothing was done for it. Present only for `mode: reconcile` — in\n`create` mode an existing object is an error, so there is nothing to\ncount. Together with the `new*` counts this is the whole account of an\napply: created plus skipped equals what the plan described.\n",
        "required": [
          "tables",
          "fields",
          "constraints",
          "automations",
          "views",
          "stageConfigs",
          "metadataTables"
        ],
        "properties": {
          "tables": {
            "type": "integer",
            "description": "Tables that already existed with a matching definition."
          },
          "fields": {
            "description": "Fields that already existed on their table with a matching definition.",
            "type": "integer"
          },
          "constraints": {
            "description": "Table constraints that already existed with a matching definition.",
            "type": "integer"
          },
          "automations": {
            "description": "Flows (the plan's `automations`) that already existed with a matching definition.",
            "type": "integer"
          },
          "views": {
            "description": "SQL views that already existed with a matching definition.",
            "type": "integer"
          },
          "stageConfigs": {
            "description": "Stage designations that were already in place and matched.",
            "type": "integer"
          },
          "metadataTables": {
            "description": "Metadata tables already declared on their host with a matching declaration.",
            "type": "integer"
          }
        }
      },
      "SchemaExportStats": {
        "description": "Counts of what the exported schema plan contains (`stats` of a `SchemaExportResult`), so a caller can tell at a glance how much of the workspace the plan describes before applying it elsewhere.",
        "type": "object",
        "required": [
          "tables",
          "fields",
          "constraints",
          "automations",
          "views",
          "stageConfigs",
          "metadataTables"
        ],
        "properties": {
          "tables": {
            "description": "Tables the plan would create.",
            "type": "integer"
          },
          "fields": {
            "description": "Fields across all those tables.",
            "type": "integer"
          },
          "constraints": {
            "description": "Table constraints (unique, no-overlap, check) across all those tables.",
            "type": "integer"
          },
          "automations": {
            "description": "Flows the plan carries (the legacy `automations` section of the plan document).",
            "type": "integer"
          },
          "views": {
            "description": "SQL views the plan would create.",
            "type": "integer"
          },
          "stageConfigs": {
            "description": "Lifecycle (stage) field designations the plan carries, one per designated table.",
            "type": "integer"
          },
          "metadataTables": {
            "description": "Metadata tables the plan declares, as `metadata` on their host's `createTables` entry.",
            "type": "integer"
          }
        }
      },
      "SchemaExportResult": {
        "description": "Response of `GET /schema-plans/export`: the workspace's schema as a version-1 schema-plan document, the gaps the format could not express, and counts of what was exported.",
        "type": "object",
        "required": [
          "plan",
          "warnings",
          "stats"
        ],
        "properties": {
          "plan": {
            "description": "The workspace's schema as a version-1 schema-plan document, ready\nto POST to /schema-plans/apply (use `mode: reconcile` to apply it\nback onto a workspace that already holds part of it). Untyped here\nfor the same reason SchemaPlanRequest.plan is: the plan document\nshape is shared TypeScript, not an OpenAPI schema, so that a\nmalformed plan reaches the validator and returns teaching issues.\n"
          },
          "warnings": {
            "type": "array",
            "description": "Coverage gaps: things this workspace holds that the plan format\ncannot express, each naming the object and the setting. An empty\narray means the export round-trips completely.\n",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "stats": {
            "$ref": "#/components/schemas/SchemaExportStats"
          }
        }
      },
      "KnownSchemaPartVisibility": {
        "type": "string",
        "description": "Who may find a schema part: `public` (every signed-in principal), `unlisted` (anyone with its id or link; never in listings or search) and `organization` (members of the publisher organization's workspaces). Open-enum: the visibility fields are open strings on the wire so a new audience never breaks generated clients; this schema is the vocabulary current servers emit.",
        "enum": [
          "public",
          "unlisted",
          "organization"
        ]
      },
      "KnownSchemaPartPublisherKind": {
        "type": "string",
        "description": "Who publishes a schema part: an `organization` (a tenant), or the `platform` itself for curated parts. Open-enum: `SchemaPartPublisher.kind` is an open string on the wire; this schema is the vocabulary current servers emit.",
        "enum": [
          "organization",
          "platform"
        ]
      },
      "KnownSchemaPartCategory": {
        "type": "string",
        "description": "The short platform taxonomy of processes a schema part is filed under, chosen by its publisher. Open-enum: the category fields are open strings on the wire so the taxonomy can grow without breaking generated clients; this schema is the vocabulary current servers emit.",
        "enum": [
          "sales",
          "operations",
          "people",
          "finance",
          "projects",
          "personal",
          "other"
        ]
      },
      "KnownSchemaPartLicence": {
        "type": "string",
        "description": "The licence a schema part is published under, granting installers its terms: `CC0-1.0` (the default), `CC-BY-4.0` or `MIT`. Open-enum: the licence fields are open strings on the wire; this schema is the vocabulary current servers emit.",
        "enum": [
          "CC0-1.0",
          "CC-BY-4.0",
          "MIT"
        ]
      },
      "KnownSchemaPartCredit": {
        "type": "string",
        "description": "How a part version credits its publisher: `named` shows the publishing member's display name on the version, `organization` shows the publisher alone. Open-enum: the credit fields on responses are open strings; this schema is the vocabulary current servers emit, and a client shows the publisher alone for a value it does not know.",
        "enum": [
          "named",
          "organization"
        ]
      },
      "KnownSchemaPartPeopleSlotKind": {
        "type": "string",
        "description": "What a part's people slot is bound to: `user`, a single workspace member, or `group`, a workspace group. Open-enum: the slot kind on responses is an open string; this schema is the vocabulary current servers emit, and a client offers no binding for a kind it does not know.",
        "enum": [
          "user",
          "group"
        ]
      },
      "KnownSchemaPartCompatibility": {
        "type": "string",
        "description": "A part version's standing against the current platform: `current` (validates cleanly), `attention` (validates with warnings its publisher should act on) or `stale` (no longer validates, so it cannot be installed). Open-enum: the compatibility fields are open strings on the wire; this schema is the vocabulary current servers emit.",
        "enum": [
          "current",
          "attention",
          "stale"
        ]
      },
      "KnownInstallModifyReason": {
        "type": "string",
        "description": "Why an install preview names an existing table under `willModify`: `external` (an external table slot is bound to it; a part may only add to one), `reconcile` (`mode: reconcile` reuses it as one of the part's own tables, identical to it, and then applies the part's companions to it) or `activities` (the part enables the built-in activities table, which this workspace already has, and applies its companions to it). Open-enum: the reason field is an open string on the wire; this schema is the vocabulary current servers emit.",
        "enum": [
          "external",
          "reconcile",
          "activities"
        ]
      },
      "KnownInstallModifyChange": {
        "type": "string",
        "description": "What an install applies to an existing table: `fieldsAdded` (new fields; existing ones are never altered), `settingsReplaced` (the part's table settings overwrite the table's comments, visibility or search settings), `layoutReplaced` (the part's record page layout replaces the table's), `lifecycleReplaced` (the part sets a field's lifecycle, replacing any the table has), `approvalRulesAdded` (approval rules start holding writes to the table), `automationsAdded` (automation rules start reacting to, or writing, the table's records), `constraintsAdded` (new constraints the table's records must then satisfy) and `rowsAdded` (the part's sample records, or their backdated stage history, are written into the table beside the installer's own; only when the request includes sample data). Open-enum: the change items are open strings on the wire; this schema is the vocabulary current servers emit.",
        "enum": [
          "fieldsAdded",
          "settingsReplaced",
          "layoutReplaced",
          "lifecycleReplaced",
          "approvalRulesAdded",
          "automationsAdded",
          "constraintsAdded",
          "rowsAdded"
        ]
      },
      "KnownSchemaPartInstallStatus": {
        "type": "string",
        "description": "Where an install job stands: `queued`, `running`, then `succeeded` or `failed`; a succeeded install whose tables have all gone from the workspace becomes `removed` (found nightly). Open-enum: `SchemaPartInstall.status` is an open string on the wire; this schema is the vocabulary current servers emit.",
        "enum": [
          "queued",
          "running",
          "succeeded",
          "failed",
          "removed"
        ]
      },
      "SchemaPartPublisher": {
        "description": "Who publishes a schema part and owns it: an organization, whose owners and admins control the part whoever is credited, or the platform for curated parts. Shown as the publisher line beside the part's name.",
        "type": "object",
        "required": [
          "kind",
          "name"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "x-known-values": "KnownSchemaPartPublisherKind",
            "description": "`organization` or `platform` (see KnownSchemaPartPublisherKind). Open contract: clients must tolerate kinds they do not know and show `name` alone."
          },
          "organizationId": {
            "type": "string",
            "description": "The publishing organization's id, present when `kind` is `organization`; the id the publisher page (`GET /library/publishers/{organizationId}`) is addressed by. Absent for the platform."
          },
          "name": {
            "type": "string",
            "description": "Display name of the publisher: the organization's name, or the platform's name for curated parts. Show it as given."
          }
        }
      },
      "SchemaPartPerson": {
        "description": "A person credited on a schema part or one of its versions, by display name only. Credit is display: it never confers control over the part.",
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The person's user id, stable across versions so a client can group what one person published."
          },
          "name": {
            "type": "string",
            "description": "The person's display name as it stands today (a removed account shows its stored placeholder name)."
          }
        }
      },
      "SchemaPartDeprecation": {
        "description": "Why a schema part's publisher no longer recommends it, and what to use instead. A deprecated part is hidden from the default listing but stays installable.",
        "type": "object",
        "required": [
          "at",
          "note"
        ],
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time",
            "description": "When the publisher deprecated the part, ISO-8601 UTC."
          },
          "note": {
            "type": "string",
            "description": "The publisher's explanation, shown beside the part as written."
          },
          "successorPartId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The part the publisher recommends instead, when they named one; link to it so an installer can move on. Absent or null when there is none."
          }
        }
      },
      "SchemaPartCounters": {
        "description": "The ranking signals a schema part carries, kept beside the part and moved with the rows they count. Display them; they are not exact audit figures.",
        "type": "object",
        "required": [
          "installs",
          "activeInstalls",
          "upvotes",
          "downvotes",
          "favourites",
          "comments"
        ],
        "properties": {
          "installs": {
            "type": "integer",
            "description": "Distinct workspaces the part has ever been installed into (re-installing in one workspace counts once)."
          },
          "activeInstalls": {
            "type": "integer",
            "description": "Distinct workspaces whose install still has its tables, recomputed nightly. What \"most installed\" and \"trending\" rank by."
          },
          "upvotes": {
            "type": "integer",
            "description": "Up votes the part has received."
          },
          "downvotes": {
            "type": "integer",
            "description": "Down votes the part has received."
          },
          "favourites": {
            "type": "integer",
            "description": "People who have favourited (and so follow) the part."
          },
          "comments": {
            "type": "integer",
            "description": "Visible comments on the part."
          }
        }
      },
      "SchemaPartStats": {
        "description": "How much a part version's document holds, by kind — what the listing renders as its stats line (\"5 tables · 2 views · 1 dashboard\"). Derived at publish, never written by hand.",
        "type": "object",
        "required": [
          "tables",
          "fields",
          "constraints",
          "automations",
          "views",
          "lifecycles",
          "savedViews",
          "flows",
          "recordLayouts",
          "approvalRules",
          "summaries",
          "dashboards",
          "sampleRows"
        ],
        "properties": {
          "tables": {
            "type": "integer",
            "description": "Tables the plan creates."
          },
          "fields": {
            "type": "integer",
            "description": "Fields the plan defines, across the tables it creates and the fields it adds."
          },
          "constraints": {
            "type": "integer",
            "description": "Table constraints the plan adds."
          },
          "automations": {
            "type": "integer",
            "description": "Declarative automation rules the plan adds."
          },
          "views": {
            "type": "integer",
            "description": "SQL views the plan creates."
          },
          "lifecycles": {
            "type": "integer",
            "description": "Stage (lifecycle) designations the plan makes."
          },
          "savedViews": {
            "type": "integer",
            "description": "Saved views the document carries."
          },
          "flows": {
            "type": "integer",
            "description": "Flows the document carries."
          },
          "recordLayouts": {
            "type": "integer",
            "description": "Record page layouts the document carries."
          },
          "approvalRules": {
            "type": "integer",
            "description": "Approval rules the document carries."
          },
          "summaries": {
            "type": "integer",
            "description": "Summary (\"totals\") rows the document carries."
          },
          "dashboards": {
            "type": "integer",
            "description": "Dashboards the document carries."
          },
          "sampleRows": {
            "type": "integer",
            "description": "Sample rows across every table, applied only when an installer asks for them."
          }
        }
      },
      "SchemaPartSlots": {
        "description": "What a part version needs from the installing workspace rather than bringing with it, each bound at install: tables it points at but does not create, people or groups its flows and approval rules name, and secrets its flows read. Derived from the document at publish; the publisher writes only each slot's purpose and suggested part.",
        "type": "object",
        "required": [
          "externalTables",
          "people",
          "secrets"
        ],
        "properties": {
          "externalTables": {
            "type": "array",
            "description": "Tables the part reads by name but does not create. The installer binds each to an existing table (`InstallRequest.externalTables`).",
            "items": {
              "type": "object",
              "required": [
                "name",
                "purpose"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "description": "The table name the part's document uses for it; the key an install binding names."
                },
                "purpose": {
                  "type": "string",
                  "description": "What the part uses the table for, shown to the installer beside the binding picker."
                },
                "suggestedPart": {
                  "type": "string",
                  "description": "Slug of a published part that provides such a table, offered as \"install this first\". Absent when the publisher named none."
                }
              }
            }
          },
          "people": {
            "type": "array",
            "description": "People or groups the part's flows and approval rules name. The installer binds each to a member or group (`InstallRequest.people`).",
            "items": {
              "type": "object",
              "required": [
                "key",
                "purpose",
                "kind"
              ],
              "properties": {
                "key": {
                  "type": "string",
                  "description": "The slot's key in the document; the key an install binding names."
                },
                "purpose": {
                  "type": "string",
                  "description": "What the person does in the part (for example who approves), shown beside the picker."
                },
                "kind": {
                  "type": "string",
                  "x-known-values": "KnownSchemaPartPeopleSlotKind",
                  "description": "Whether the slot is bound to a single member (`user`) or a group (`group`) (see KnownSchemaPartPeopleSlotKind). Open contract: clients must tolerate values they do not know and offer no binding for one."
                }
              }
            }
          },
          "secrets": {
            "type": "array",
            "description": "Secrets the part's flows read as `{{secrets.<name>}}`. The installer binds each to the name of a secret the workspace already holds (`InstallRequest.secrets`); a part never carries a secret value.",
            "items": {
              "type": "object",
              "required": [
                "name",
                "purpose"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "description": "The secret name the document uses; the key an install binding names."
                },
                "purpose": {
                  "type": "string",
                  "description": "What the flow uses the secret for, shown beside the binding picker."
                }
              }
            }
          }
        }
      },
      "SchemaPartCapabilities": {
        "description": "What installing a part version lets it do, read from its document: every outbound reach, every piece of code and SQL, the people and secrets it asks for. Rendered as the capability panel an installer reads before the install button.",
        "type": "object",
        "required": [
          "outboundHosts",
          "runtimeDecidedUrls",
          "sendsEmail",
          "codeBlocks",
          "sqlViews",
          "savedQueries",
          "needsActivities",
          "secretSlots",
          "peopleSlots",
          "sampleRows",
          "roles",
          "intakes",
          "privateFields"
        ],
        "properties": {
          "outboundHosts": {
            "type": "array",
            "description": "Hosts the part's HTTP request blocks call, sorted; show each as \"Calls <host>\".",
            "items": {
              "type": "string"
            }
          },
          "runtimeDecidedUrls": {
            "type": "integer",
            "description": "HTTP request blocks whose host is decided at run time (the address is itself a template). Show these prominently: the document does not say where they call."
          },
          "sendsEmail": {
            "type": "boolean",
            "description": "Whether any flow sends email."
          },
          "codeBlocks": {
            "type": "integer",
            "description": "Custom code blocks across the part's flows; a client offers each block's source for reading."
          },
          "sqlViews": {
            "type": "integer",
            "description": "SQL views the plan creates."
          },
          "savedQueries": {
            "type": "integer",
            "description": "Saved queries the part's dashboards create."
          },
          "needsActivities": {
            "type": "boolean",
            "description": "Whether installing enables the workspace's built-in activities table."
          },
          "secretSlots": {
            "type": "array",
            "description": "Names of the secret slots the installer must bind.",
            "items": {
              "type": "string"
            }
          },
          "peopleSlots": {
            "type": "array",
            "description": "Keys of the people slots the installer must bind.",
            "items": {
              "type": "string"
            }
          },
          "sampleRows": {
            "type": "integer",
            "description": "Sample rows the part offers, applied only on request."
          },
          "roles": {
            "type": "array",
            "description": "Names of the roles the part creates. A part that adds roles is flagged \"Adds roles\": a role is standing access, so installing one needs a person's review of what it can do and who holds it (`InstallPreview.roles`, `InstallRequest.acknowledgedRoles`).",
            "items": {
              "type": "string"
            }
          },
          "intakes": {
            "type": "array",
            "description": "Labels of the intakes the part creates and publishes.",
            "items": {
              "type": "string"
            }
          },
          "privateFields": {
            "type": "array",
            "description": "Fields the part makes private, as `table.field` by plan name: only admins (and roles with a grant on the field) can read them once installed.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SchemaPartPlatformPin": {
        "description": "What a part version records about the platform it was validated on: which platform understood the document, and the value-contract fingerprints of the field types it uses so a later change to one re-validates the version rather than trusting it.",
        "type": "object",
        "required": [
          "build",
          "builtAt",
          "documentFormat",
          "planFormat",
          "workspaceMigrationTag",
          "contractHashes"
        ],
        "properties": {
          "build": {
            "type": "string",
            "description": "The platform build that validated the version; shown as the platform it was built on."
          },
          "builtAt": {
            "type": "string",
            "description": "ISO-8601 date of that build, for \"Built on the platform of <date>\"."
          },
          "documentFormat": {
            "type": "integer",
            "description": "The part document format version the document was written in (1)."
          },
          "planFormat": {
            "type": "integer",
            "description": "The schema plan format version the document's plan was written in (1)."
          },
          "workspaceMigrationTag": {
            "type": "string",
            "description": "The workspace schema era current at publish. A workspace below it cannot install the version until it is migrated (409 `PART_WORKSPACE_ERA_BEHIND` at install)."
          },
          "contractHashes": {
            "type": "object",
            "description": "Field type → fingerprint of that type's value contract when the version was validated, for the field types the part uses.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "composedFrom": {
            "type": "array",
            "description": "Table names in the publisher's workspace the document was composed from, which the republish compose reads again. Absent for a document posted by hand.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SchemaPartLatestVersion": {
        "description": "The part's latest version as a listing shows it: its number and date, what it holds, what it needs and reaches for, and whether it still validates.",
        "type": "object",
        "required": [
          "number",
          "createdAt",
          "stats",
          "highlights",
          "slots",
          "capabilities",
          "compatibility"
        ],
        "properties": {
          "number": {
            "type": "integer",
            "description": "The version number, from 1."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the version was published, ISO-8601 UTC."
          },
          "stats": {
            "$ref": "#/components/schemas/SchemaPartStats"
          },
          "highlights": {
            "type": "array",
            "description": "Short phrases naming what is notable in the version (a lifecycle, a rollup, a dashboard), for the listing row.",
            "items": {
              "type": "string"
            }
          },
          "slots": {
            "$ref": "#/components/schemas/SchemaPartSlots"
          },
          "capabilities": {
            "$ref": "#/components/schemas/SchemaPartCapabilities"
          },
          "compatibility": {
            "type": "string",
            "x-known-values": "KnownSchemaPartCompatibility",
            "description": "The version's standing against the current platform (see KnownSchemaPartCompatibility). Open contract: clients must tolerate values they do not know and treat them as needing attention."
          }
        }
      },
      "SchemaPartSummary": {
        "description": "A schema part as a listing shows it: identity, publisher and credit, metadata, its state (deprecated, withdrawn), its ranking counters and its latest version. Item of `SchemaPartList` and of the organization's part list.",
        "type": "object",
        "required": [
          "id",
          "publisher",
          "slug",
          "name",
          "summary",
          "tags",
          "category",
          "licence",
          "visibility",
          "curated",
          "latestVersionNumber",
          "latestInstallableVersionNumber",
          "creditedUser",
          "deprecated",
          "withdrawn",
          "counters",
          "latestVersion"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The part's id; what every `/library/parts/{partId}` path names."
          },
          "publisher": {
            "$ref": "#/components/schemas/SchemaPartPublisher"
          },
          "slug": {
            "type": "string",
            "description": "The part's URL-safe name, unique within its publisher and fixed at creation."
          },
          "name": {
            "type": "string",
            "description": "The part's display name, editable by its publisher."
          },
          "summary": {
            "type": "string",
            "description": "One or two sentences on what the part is for, shown under its name."
          },
          "tags": {
            "type": "array",
            "description": "Lower-case tags the publisher chose, for filtering the listing (`tag`).",
            "items": {
              "type": "string"
            }
          },
          "category": {
            "type": "string",
            "x-known-values": "KnownSchemaPartCategory",
            "description": "The process category the publisher filed the part under (see KnownSchemaPartCategory). Open contract: clients must tolerate categories they do not know and show them as other."
          },
          "licence": {
            "type": "string",
            "x-known-values": "KnownSchemaPartLicence",
            "description": "The licence installers receive the part under (see KnownSchemaPartLicence). Open contract: clients must tolerate licences they do not know and show the identifier as given."
          },
          "visibility": {
            "type": "string",
            "x-known-values": "KnownSchemaPartVisibility",
            "description": "Who may find the part (see KnownSchemaPartVisibility). Open contract: clients must tolerate values they do not know and treat them as restricted."
          },
          "curated": {
            "type": "boolean",
            "description": "Whether the platform curates the part; curated parts are listed first."
          },
          "latestVersionNumber": {
            "type": "integer",
            "description": "The newest version's number."
          },
          "latestInstallableVersionNumber": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The newest version that is not `stale` — what \"Install\" installs. Null when every version is stale, in which case the part cannot be installed until its publisher republishes."
          },
          "creditedUser": {
            "description": "The person who published the latest version, when that version credits them by name. Null when it is credited to the organization alone, or for a platform part.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/SchemaPartPerson"
              },
              {
                "type": "null"
              }
            ]
          },
          "deprecated": {
            "description": "The publisher's deprecation, or null when the part is recommended.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/SchemaPartDeprecation"
              },
              {
                "type": "null"
              }
            ]
          },
          "withdrawn": {
            "type": "boolean",
            "description": "Whether the operator has withdrawn the part. Only its publisher ever sees a withdrawn part; it is hidden from everyone else."
          },
          "withdrawalReason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the operator withdrew the part. Present only on the organization's own list for a caller who manages its library; absent everywhere else."
          },
          "counters": {
            "$ref": "#/components/schemas/SchemaPartCounters"
          },
          "latestVersion": {
            "$ref": "#/components/schemas/SchemaPartLatestVersion"
          }
        }
      },
      "SchemaPartVersionEntry": {
        "description": "One version in a part's version list: its number, change note and credit, and its standing on the current platform. The document itself is read from `SchemaPartVersion`.",
        "type": "object",
        "required": [
          "number",
          "changeNote",
          "createdAt",
          "createdBy",
          "credit",
          "compatibility",
          "platform"
        ],
        "properties": {
          "number": {
            "type": "integer",
            "description": "The version number, from 1; what `/library/parts/{partId}/versions/{number}` names."
          },
          "changeNote": {
            "type": "string",
            "description": "The publisher's note on what changed in this version (empty for a first version without one)."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the version was published, ISO-8601 UTC."
          },
          "createdBy": {
            "description": "The member who published this version, when it credits them by name. Null when it is credited to the organization, for a platform version, or when the account is gone.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/SchemaPartPerson"
              },
              {
                "type": "null"
              }
            ]
          },
          "credit": {
            "type": "string",
            "x-known-values": "KnownSchemaPartCredit",
            "description": "`named` shows the publishing member's display name on the version; `organization` shows the publisher alone (see KnownSchemaPartCredit). Open contract: clients must tolerate values they do not know and show the publisher alone for one."
          },
          "compatibility": {
            "type": "string",
            "x-known-values": "KnownSchemaPartCompatibility",
            "description": "The version's standing against the current platform (see KnownSchemaPartCompatibility). Open contract: clients must tolerate values they do not know."
          },
          "platform": {
            "$ref": "#/components/schemas/SchemaPartPlatformPin"
          }
        }
      },
      "SchemaPartLineage": {
        "description": "The part version a fork was made from, named for the \"forked from\" line. The source is named as it stood when read; follow `partId` for its current state.",
        "type": "object",
        "required": [
          "partId",
          "number",
          "publisherName",
          "partName"
        ],
        "properties": {
          "partId": {
            "type": "string",
            "description": "The source part's id."
          },
          "number": {
            "type": "integer",
            "description": "The source version's number."
          },
          "publisherName": {
            "type": "string",
            "description": "The source part's publisher's display name."
          },
          "partName": {
            "type": "string",
            "description": "The source part's display name."
          }
        }
      },
      "SchemaPart": {
        "description": "Response of `GET /library/parts/{partId}`: a part's summary plus its readme, every version's entry, its fork lineage and how often it has been forked.",
        "allOf": [
          {
            "$ref": "#/components/schemas/SchemaPartSummary"
          },
          {
            "type": "object",
            "required": [
              "readme",
              "versions",
              "forkedFrom",
              "forkCount",
              "viewer"
            ],
            "properties": {
              "viewer": {
                "$ref": "#/components/schemas/SchemaPartViewer"
              },
              "readme": {
                "type": "string",
                "description": "The latest version's readme, plain text. Render it as paragraphs with line breaks kept and no markup."
              },
              "versions": {
                "type": "array",
                "description": "Every version, newest first.",
                "items": {
                  "$ref": "#/components/schemas/SchemaPartVersionEntry"
                }
              },
              "forkedFrom": {
                "description": "The version this part was forked from, or null when it is no fork.",
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/SchemaPartLineage"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "forkCount": {
                "type": "integer",
                "description": "How many parts have been forked from this one."
              }
            }
          }
        ]
      },
      "SchemaPartViewer": {
        "description": "The caller's own standing on a part: their vote and favourite, and which community actions are open to them. Never another person's.",
        "type": "object",
        "required": [
          "vote",
          "favourite",
          "canVote",
          "canComment",
          "canReplyAsPublisher"
        ],
        "properties": {
          "vote": {
            "type": "integer",
            "enum": [
              -1,
              0,
              1
            ],
            "description": "The caller's vote, `0` when they have not voted."
          },
          "favourite": {
            "type": "boolean",
            "description": "Whether the caller has favourited (and so follows) the part."
          },
          "canVote": {
            "type": "boolean",
            "description": "Whether the caller may vote: false for a member of the publishing organization and for anything but the person's own signed-in session. Hide the vote controls when false."
          },
          "canComment": {
            "type": "boolean",
            "description": "Whether the caller may comment, reply, favourite and report: false for anything but the person's own signed-in session."
          },
          "canReplyAsPublisher": {
            "type": "boolean",
            "description": "Whether the caller manages the publishing organization's library, and so may post as the publisher (`asPublisher`)."
          }
        }
      },
      "SchemaPartCommunity": {
        "description": "Response of a vote or favourite: the part's counters and the caller's standing after the change, for the part page to show at once.",
        "type": "object",
        "required": [
          "partId",
          "counters",
          "viewer"
        ],
        "properties": {
          "partId": {
            "type": "string",
            "description": "The part the change was made on."
          },
          "counters": {
            "$ref": "#/components/schemas/SchemaPartCounters"
          },
          "viewer": {
            "$ref": "#/components/schemas/SchemaPartViewer"
          }
        }
      },
      "SchemaPartVoteRequest": {
        "description": "Body of `PUT /library/parts/{partId}/vote`.",
        "type": "object",
        "required": [
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "value": {
            "type": "integer",
            "enum": [
              1,
              -1
            ],
            "description": "`1` votes the part up, `-1` down."
          }
        }
      },
      "KnownSchemaPartReportReason": {
        "type": "string",
        "description": "Why a part or comment is reported: `spam`, `abuse`, `malicious` (the part would do harm if installed), `licence` (published without the right to), `personal-data`, or `other`. Open-enum: `SchemaPartReport.reason` is an open string on the wire; this schema is the vocabulary current servers emit.",
        "enum": [
          "spam",
          "abuse",
          "malicious",
          "licence",
          "personal-data",
          "other"
        ]
      },
      "SchemaPartCommentAuthor": {
        "description": "Who wrote a comment, by display name only. A deleted account reads as its stored name (\"Deleted user\").",
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The author's display name."
          }
        }
      },
      "SchemaPartComment": {
        "description": "One comment on a part. Plain text: render it with line breaks kept and no markup.",
        "type": "object",
        "required": [
          "id",
          "parentId",
          "body",
          "hidden",
          "author",
          "asPublisher",
          "publisherName",
          "mine",
          "createdAt",
          "editedAt",
          "editableUntil"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The comment's id."
          },
          "parentId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The top-level comment this replies to, or null for a top-level comment."
          },
          "body": {
            "type": "string",
            "description": "The text; empty when the comment is hidden."
          },
          "hidden": {
            "type": "boolean",
            "description": "Whether the platform's operators hid the comment. Show a placeholder in its place (\"This comment was hidden\") and keep its replies."
          },
          "author": {
            "$ref": "#/components/schemas/SchemaPartCommentAuthor"
          },
          "asPublisher": {
            "type": "boolean",
            "description": "Whether the comment was posted as the publisher's reply; mark it so."
          },
          "publisherName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The publisher's name, for a comment posted as the publisher; otherwise null."
          },
          "mine": {
            "type": "boolean",
            "description": "Whether the caller wrote it, and so may delete it (and edit it while `editableUntil` is ahead)."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it was posted."
          },
          "editedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When its text was last edited, or null; show \"edited\" when set."
          },
          "editableUntil": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "For the caller's own visible comment, when the edit window closes; otherwise null."
          }
        }
      },
      "SchemaPartCommentThread": {
        "description": "A top-level comment with every reply to it, replies oldest first.",
        "allOf": [
          {
            "$ref": "#/components/schemas/SchemaPartComment"
          },
          {
            "type": "object",
            "required": [
              "replies"
            ],
            "properties": {
              "replies": {
                "type": "array",
                "description": "The replies, oldest first.",
                "items": {
                  "$ref": "#/components/schemas/SchemaPartComment"
                }
              }
            }
          }
        ]
      },
      "SchemaPartCommentPage": {
        "description": "Response of `GET /library/parts/{partId}/comments`.",
        "type": "object",
        "required": [
          "comments",
          "nextCursor"
        ],
        "properties": {
          "comments": {
            "type": "array",
            "description": "Top-level comments, newest first, each with its replies.",
            "items": {
              "$ref": "#/components/schemas/SchemaPartCommentThread"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass as `cursor` for the next, older page; null on the last page."
          }
        }
      },
      "SchemaPartCommentRequest": {
        "description": "Body of `POST /library/parts/{partId}/comments`.",
        "type": "object",
        "required": [
          "body"
        ],
        "additionalProperties": false,
        "properties": {
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "description": "The comment, plain text."
          },
          "parentId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The top-level comment to reply to; omit for a new top-level comment."
          },
          "asPublisher": {
            "type": "boolean",
            "description": "Post as the publisher's reply. Only a library manager of the publishing organization may; default false."
          }
        }
      },
      "SchemaPartCommentUpdate": {
        "description": "Body of `PATCH /library/parts/{partId}/comments/{commentId}`.",
        "type": "object",
        "required": [
          "body"
        ],
        "additionalProperties": false,
        "properties": {
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "description": "The comment's new text, plain text."
          }
        }
      },
      "SchemaPartReportRequest": {
        "description": "Body of `POST /library/parts/{partId}/reports`.",
        "type": "object",
        "required": [
          "reason",
          "detail"
        ],
        "additionalProperties": false,
        "properties": {
          "reason": {
            "type": "string",
            "enum": [
              "spam",
              "abuse",
              "malicious",
              "licence",
              "personal-data",
              "other"
            ],
            "description": "Why the part or comment is reported (see KnownSchemaPartReportReason)."
          },
          "detail": {
            "type": "string",
            "maxLength": 1000,
            "description": "What the operators should know, plain text; may be empty."
          },
          "commentId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The comment being reported; omit to report the part itself."
          }
        }
      },
      "SchemaPartReport": {
        "description": "A report the caller filed, as the operators will see it. The outcome reaches the reporter by notification once an operator acts on it.",
        "type": "object",
        "required": [
          "id",
          "partId",
          "commentId",
          "reason",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The report's id."
          },
          "partId": {
            "type": "string",
            "description": "The part reported, or whose comment is reported."
          },
          "commentId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The comment reported, or null when the report is of the part."
          },
          "reason": {
            "type": "string",
            "x-known-values": "KnownSchemaPartReportReason",
            "description": "Why it was reported (see KnownSchemaPartReportReason). Open contract: clients must tolerate values they do not know and show them as \"other\"."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it was filed."
          }
        }
      },
      "SchemaPartSuggestionRequest": {
        "description": "Body of `POST /library/suggest`.",
        "type": "object",
        "required": [
          "document"
        ],
        "additionalProperties": false,
        "properties": {
          "document": {
            "description": "The part document to describe, as the publish dialog holds it.\nUntyped here for the same reason PublishSchemaPartRequest.document\nis: the shared TypeScript shape is `SchemaPartDocument` in\n`@taskexchange/api-spec`, so a malformed document reaches the\nvalidator and comes back as teaching issues (400).\n"
          }
        }
      },
      "SchemaPartSuggestion": {
        "description": "Response of `POST /library/suggest`: a summary and tags drawn from the document, for the publisher to edit. Both already fit the listing's limits.",
        "type": "object",
        "required": [
          "summary",
          "tags"
        ],
        "properties": {
          "summary": {
            "type": "string",
            "maxLength": 280,
            "description": "A one-sentence summary of what the part sets up."
          },
          "tags": {
            "type": "array",
            "maxItems": 10,
            "description": "Lower-case tags (letters, digits and hyphens), at most 10.",
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9-]{1,32}$"
            }
          }
        }
      },
      "SchemaPartVersion": {
        "description": "Response of `GET /library/parts/{partId}/versions/{number}`: one immutable published version — its document, readme and change note, what was derived from the document at publish, and its standing on the current platform.",
        "type": "object",
        "required": [
          "partId",
          "number",
          "changeNote",
          "readme",
          "credit",
          "createdAt",
          "createdBy",
          "document",
          "documentSha256",
          "stats",
          "slots",
          "capabilities",
          "highlights",
          "platform",
          "featuresUsed",
          "compatibility",
          "compatibilityIssues",
          "compatibilityCheckedAt"
        ],
        "properties": {
          "partId": {
            "type": "string",
            "description": "The part this version belongs to."
          },
          "number": {
            "type": "integer",
            "description": "The version number, from 1."
          },
          "changeNote": {
            "type": "string",
            "description": "The publisher's note on what changed in this version."
          },
          "readme": {
            "type": "string",
            "description": "The version's readme, plain text; render it as paragraphs with line breaks kept and no markup."
          },
          "credit": {
            "type": "string",
            "x-known-values": "KnownSchemaPartCredit",
            "description": "`named` shows the publishing member's display name on the version; `organization` shows the publisher alone (see KnownSchemaPartCredit). Open contract: clients must tolerate values they do not know and show the publisher alone for one."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the version was published, ISO-8601 UTC."
          },
          "createdBy": {
            "description": "The member who published this version, when it credits them by name. Null when it is credited to the organization, for a platform version, or when the account is gone.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/SchemaPartPerson"
              },
              {
                "type": "null"
              }
            ]
          },
          "document": {
            "description": "The version's part document, canonicalised: the schema plan plus\nits companions (table settings, saved views, approval rules,\nsummaries, flows, record layouts, dashboards), its slots and its\nsample data. Untyped here for the same reason SchemaPlanRequest.plan\nis: the shared TypeScript shape is `SchemaPartDocument` in\n`@taskexchange/api-spec`, not an OpenAPI schema, so a malformed\ndocument reaches the validator and returns teaching issues. Offer\nit for download: it is the whole part.\n"
          },
          "documentSha256": {
            "type": "string",
            "description": "Hex SHA-256 of the canonical document; two versions of one part never share it."
          },
          "stats": {
            "$ref": "#/components/schemas/SchemaPartStats"
          },
          "slots": {
            "$ref": "#/components/schemas/SchemaPartSlots"
          },
          "capabilities": {
            "$ref": "#/components/schemas/SchemaPartCapabilities"
          },
          "highlights": {
            "type": "array",
            "description": "Short phrases naming what is notable in the version, for the part page.",
            "items": {
              "type": "string"
            }
          },
          "platform": {
            "$ref": "#/components/schemas/SchemaPartPlatformPin"
          },
          "featuresUsed": {
            "type": "array",
            "description": "The platform features the document uses, each namespaced by kind (`field:`, `constraint:`, `block:`, `trigger:`, `tile:`), for \"this part uses recurrence fields\".",
            "items": {
              "type": "string"
            }
          },
          "compatibility": {
            "type": "string",
            "x-known-values": "KnownSchemaPartCompatibility",
            "description": "The version's standing against the current platform (see KnownSchemaPartCompatibility); a `stale` version cannot be installed. Open contract: clients must tolerate values they do not know."
          },
          "compatibilityIssues": {
            "type": "array",
            "description": "The issues the last re-validation found; empty for a `current` version.",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "compatibilityCheckedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the version was last re-validated against the platform, or null when only at publish."
          }
        }
      },
      "SchemaPartList": {
        "description": "A page of schema parts, curated first in every sort. Response of `GET /library/parts` and `GET /library/publishers/{organizationId}`.",
        "type": "object",
        "required": [
          "items",
          "nextCursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "description": "The parts on this page, in the requested order.",
            "items": {
              "$ref": "#/components/schemas/SchemaPartSummary"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass as `cursor` to read the next page; null on the last page."
          }
        }
      },
      "SchemaPartDiffSection": {
        "description": "What changed in one kind of object between two part documents, by name or key: present only in the newer document, only in the older one, or in both but different.",
        "type": "object",
        "required": [
          "added",
          "removed",
          "changed"
        ],
        "properties": {
          "added": {
            "type": "array",
            "description": "Names (fields as `table.field`) or keys present only in the newer document.",
            "items": {
              "type": "string"
            }
          },
          "removed": {
            "type": "array",
            "description": "Names or keys present only in the older document.",
            "items": {
              "type": "string"
            }
          },
          "changed": {
            "type": "array",
            "description": "Names or keys present in both whose definitions differ.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SchemaPartDiff": {
        "description": "What changed between two part documents, in the canonical form's terms: the plan's objects by name and the companions by key. Order alone is never a change. Response of `GET /library/parts/{partId}/versions/{a}/diff/{b}`, and carried by the republish compose.",
        "type": "object",
        "required": [
          "plan",
          "companions"
        ],
        "properties": {
          "plan": {
            "type": "object",
            "description": "Changes to the schema plan, by kind of object.",
            "required": [
              "tables",
              "fields",
              "constraints",
              "automations",
              "views",
              "lifecycles"
            ],
            "properties": {
              "tables": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "fields": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "constraints": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "automations": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "views": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "lifecycles": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              }
            }
          },
          "companions": {
            "type": "object",
            "description": "Changes to the document's companions, by kind, each object named by its key (or table and name).",
            "required": [
              "tableSettings",
              "savedViews",
              "approvalRules",
              "summaries",
              "flows",
              "recordLayouts",
              "queries",
              "charts",
              "dashboards"
            ],
            "properties": {
              "tableSettings": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "savedViews": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "approvalRules": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "summaries": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "flows": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "recordLayouts": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "queries": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "charts": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              },
              "dashboards": {
                "$ref": "#/components/schemas/SchemaPartDiffSection"
              }
            }
          }
        }
      },
      "InstallRequestInclude": {
        "type": "object",
        "description": "Which companion kinds to install; each defaults to true except `sampleData`. The plan itself is always installed.",
        "properties": {
          "savedViews": {
            "type": "boolean",
            "description": "Install the part's saved views."
          },
          "recordLayouts": {
            "type": "boolean",
            "description": "Install the part's record page layouts."
          },
          "approvalRules": {
            "type": "boolean",
            "description": "Install the part's approval rules."
          },
          "summaries": {
            "type": "boolean",
            "description": "Install the part's summary rows."
          },
          "flows": {
            "type": "boolean",
            "description": "Install the part's flows (always created disabled)."
          },
          "dashboards": {
            "type": "boolean",
            "description": "Install the part's dashboards, with their queries and charts."
          },
          "sampleData": {
            "type": "boolean",
            "description": "Apply the part's sample rows and stage history (sandbox workspaces only). Defaults to false."
          },
          "roles": {
            "type": "boolean",
            "description": "Create the part's roles and assign them. Leaving them out needs no role review."
          },
          "intakes": {
            "type": "boolean",
            "description": "Create and publish the part's intakes."
          }
        }
      },
      "LibraryKitPart": {
        "type": "object",
        "description": "One part version a kit installs, in the kit's order. The version must be published, installable (not `stale`), not withdrawn and readable wherever the kit is.",
        "required": [
          "partId",
          "version"
        ],
        "properties": {
          "partId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The part's id."
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "The part version's number."
          },
          "include": {
            "$ref": "#/components/schemas/InstallRequestInclude"
          }
        }
      },
      "LibraryKitBinding": {
        "type": "object",
        "description": "Binds a later part's external-table slot to a table an earlier part of the same kit creates, so the person installing the kit is not asked to bind it. Parts are named by their index in `parts`, from 0.",
        "required": [
          "part",
          "slot",
          "toPart",
          "toTable"
        ],
        "properties": {
          "part": {
            "type": "integer",
            "minimum": 0,
            "description": "Index in `parts` of the part whose slot is bound."
          },
          "slot": {
            "type": "string",
            "maxLength": 64,
            "description": "The external-table slot's name in that part's version."
          },
          "toPart": {
            "type": "integer",
            "minimum": 0,
            "description": "Index in `parts` of an earlier part, which creates the table."
          },
          "toTable": {
            "type": "string",
            "maxLength": 64,
            "description": "The table's name in that earlier part's plan, before any rename at install."
          }
        }
      },
      "LibraryKitPlacement": {
        "type": "object",
        "description": "Where installing the kit places one of its extensions: an `extension` block on the record page of a table a kit part creates.",
        "required": [
          "extensionId",
          "table"
        ],
        "properties": {
          "extensionId": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{0,39}$",
            "description": "The extension's id in the source's `tessule.site.json`; it must target `record.block`."
          },
          "table": {
            "type": "string",
            "maxLength": 64,
            "description": "The table's name in the plan of the kit part that creates it."
          },
          "tab": {
            "type": "object",
            "description": "Places the block on a first tab of its own, with the table's field sections on a second tab. Absent: the block is added after the layout's existing content.",
            "required": [
              "title"
            ],
            "properties": {
              "title": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60,
                "description": "The tab's title."
              }
            }
          }
        }
      },
      "LibraryKitSourceUpload": {
        "type": "object",
        "description": "The site files a kit carries for its extensions: an archive in the format and within the limits of `POST /hosted-site/deployments/archive`, validated the same way, with where each extension is placed.",
        "required": [
          "format",
          "archive",
          "placements"
        ],
        "properties": {
          "format": {
            "$ref": "#/components/schemas/HostedSiteArchiveFormat"
          },
          "archive": {
            "type": "string",
            "format": "byte",
            "description": "The archive's bytes, base64-encoded (2.5 MB decoded at most)."
          },
          "placements": {
            "type": "array",
            "maxItems": 20,
            "description": "Where installing the kit places the extensions; an extension placed nowhere is still deployed.",
            "items": {
              "$ref": "#/components/schemas/LibraryKitPlacement"
            }
          }
        }
      },
      "LibraryKitSampleFiles": {
        "type": "object",
        "description": "A sample delivery's files by slot, each a path in the samples archive: the source (the PDF or photo the document was read from) and, when the document is staged rather than sent inline, the document. The install stages each on the intake's file fields as the installer.",
        "required": [
          "source"
        ],
        "additionalProperties": false,
        "properties": {
          "document": {
            "type": "string",
            "maxLength": 255,
            "description": "Archive path of the document file, staged as the delivery's `files.document`; left out when `document` names an inline one."
          },
          "source": {
            "type": "string",
            "maxLength": 255,
            "description": "Archive path of the source file, staged as the delivery's `files.source`."
          }
        }
      },
      "LibraryKitSampleDelivery": {
        "type": "object",
        "description": "One sample document a kit version carries, delivered to one of the kit's intakes when the installer asks for the samples (`KitInstallRequest.samples`), through that intake's own delivery path and as the installer.",
        "required": [
          "intake",
          "files"
        ],
        "additionalProperties": false,
        "properties": {
          "intake": {
            "type": "string",
            "maxLength": 63,
            "description": "The intake it is delivered to, by the name a part of the kit creates it under."
          },
          "document": {
            "type": "string",
            "maxLength": 255,
            "description": "Archive path of a JSON file sent as the delivery's inline `document`. Leave it out when the document is staged as `files.document`; exactly one of the two."
          },
          "files": {
            "$ref": "#/components/schemas/LibraryKitSampleFiles"
          }
        }
      },
      "LibraryKitSamplesUpload": {
        "type": "object",
        "description": "The sample documents a kit version carries: an archive of their files, in the format of `POST /hosted-site/deployments/archive` (2.5 MB decoded at most), and the deliveries made from them, in order.",
        "required": [
          "format",
          "archive",
          "deliveries"
        ],
        "properties": {
          "format": {
            "$ref": "#/components/schemas/HostedSiteArchiveFormat"
          },
          "archive": {
            "type": "string",
            "format": "byte",
            "description": "The archive's bytes, base64-encoded."
          },
          "deliveries": {
            "type": "array",
            "minItems": 1,
            "maxItems": 25,
            "description": "The deliveries, in the order the install makes them.",
            "items": {
              "$ref": "#/components/schemas/LibraryKitSampleDelivery"
            }
          }
        }
      },
      "LibraryKitSamples": {
        "type": "object",
        "description": "The sample documents a kit version carries, as read back.",
        "required": [
          "sha256",
          "sizeBytes",
          "deliveries"
        ],
        "properties": {
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "Digest of the samples archive."
          },
          "sizeBytes": {
            "type": "integer",
            "description": "The archive's size in bytes."
          },
          "deliveries": {
            "type": "array",
            "description": "The deliveries the install makes when asked, in order.",
            "items": {
              "$ref": "#/components/schemas/LibraryKitSampleDelivery"
            }
          }
        }
      },
      "PublishLibraryKitVersionRequest": {
        "type": "object",
        "description": "A kit version: its parts in install order, the bindings between them, the optional extension source and the readme written as a setup guide. Request body of `POST /organizations/{organizationId}/library/kits/{kitId}/versions`, and the version half of publishing a kit.",
        "required": [
          "parts",
          "readme"
        ],
        "properties": {
          "parts": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "description": "The part versions the kit installs, in order.",
            "items": {
              "$ref": "#/components/schemas/LibraryKitPart"
            }
          },
          "bindings": {
            "type": "array",
            "maxItems": 50,
            "description": "Slots of later parts bound to tables earlier parts create.",
            "items": {
              "$ref": "#/components/schemas/LibraryKitBinding"
            }
          },
          "source": {
            "$ref": "#/components/schemas/LibraryKitSourceUpload"
          },
          "samples": {
            "$ref": "#/components/schemas/LibraryKitSamplesUpload"
          },
          "readme": {
            "type": "string",
            "maxLength": 20000,
            "description": "Markdown setup guide shown on the kit page, including the steps an admin takes by hand."
          },
          "changeNote": {
            "type": "string",
            "maxLength": 1000,
            "description": "What changed since the previous version; empty for version 1."
          }
        }
      },
      "PublishLibraryKitRequest": {
        "type": "object",
        "description": "A new kit's metadata and its version 1. Request body of `POST /organizations/{organizationId}/library/kits`.",
        "required": [
          "slug",
          "name",
          "summary",
          "visibility",
          "version"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[a-z0-9][a-z0-9-]*$",
            "description": "The kit's address under its publisher; never changes."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "description": "The kit's display name."
          },
          "summary": {
            "type": "string",
            "minLength": 1,
            "maxLength": 280,
            "description": "One or two sentences on what the kit sets up."
          },
          "visibility": {
            "type": "string",
            "enum": [
              "public",
              "unlisted",
              "organization"
            ],
            "description": "Who may find the kit: `public`, `unlisted` (by link only) or `organization` (the publisher's own workspaces). Every part must be readable wherever the kit is."
          },
          "version": {
            "$ref": "#/components/schemas/PublishLibraryKitVersionRequest"
          }
        }
      },
      "LibraryKitCollaborator": {
        "type": "object",
        "description": "An organization credited on a kit beside its publisher.",
        "required": [
          "organizationId",
          "name",
          "accepted"
        ],
        "properties": {
          "organizationId": {
            "type": "string",
            "description": "The credited organization's id."
          },
          "name": {
            "type": "string",
            "description": "The credited organization's name."
          },
          "accepted": {
            "type": "boolean",
            "description": "Whether an admin of that organization has accepted the credit. Only accepted credits are shown on the kit; the publisher also sees pending ones."
          }
        }
      },
      "LibraryKitExtension": {
        "type": "object",
        "description": "What a kit version's extension source holds and where installing it places its extensions.",
        "required": [
          "sha256",
          "format",
          "sizeBytes",
          "extensions",
          "placements"
        ],
        "properties": {
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "Digest of the archive; installing the kit with its extension echoes it back as the acknowledgement."
          },
          "format": {
            "$ref": "#/components/schemas/HostedSiteArchiveFormat"
          },
          "sizeBytes": {
            "type": "integer",
            "description": "The archive's size in bytes."
          },
          "extensions": {
            "type": "array",
            "description": "The extensions the source's `tessule.site.json` declares, with the scopes each asks for.",
            "items": {
              "$ref": "#/components/schemas/HostedSiteExtension"
            }
          },
          "placements": {
            "type": "array",
            "description": "Where installing the kit places them.",
            "items": {
              "$ref": "#/components/schemas/LibraryKitPlacement"
            }
          }
        }
      },
      "LibraryKitVersionPart": {
        "type": "object",
        "description": "One part of a kit version, as read back, with the part's name for display.",
        "required": [
          "partId",
          "slug",
          "name",
          "version"
        ],
        "properties": {
          "partId": {
            "type": "string",
            "description": "The part's id."
          },
          "slug": {
            "type": "string",
            "description": "The part's slug."
          },
          "name": {
            "type": "string",
            "description": "The part's name."
          },
          "version": {
            "type": "integer",
            "description": "The part version's number."
          },
          "include": {
            "$ref": "#/components/schemas/InstallRequestInclude"
          }
        }
      },
      "LibraryKitVersion": {
        "type": "object",
        "description": "One immutable version of a kit.",
        "required": [
          "number",
          "parts",
          "bindings",
          "extension",
          "samples",
          "readme",
          "changeNote",
          "createdAt"
        ],
        "properties": {
          "number": {
            "type": "integer",
            "description": "The version's number, from 1."
          },
          "parts": {
            "type": "array",
            "description": "The part versions it installs, in order.",
            "items": {
              "$ref": "#/components/schemas/LibraryKitVersionPart"
            }
          },
          "bindings": {
            "type": "array",
            "description": "Slots of later parts bound to tables earlier parts create.",
            "items": {
              "$ref": "#/components/schemas/LibraryKitBinding"
            }
          },
          "extension": {
            "description": "The extension source, or null when the kit carries none.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/LibraryKitExtension"
              },
              {
                "type": "null"
              }
            ]
          },
          "samples": {
            "description": "The sample documents, or null when the kit carries none.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/LibraryKitSamples"
              },
              {
                "type": "null"
              }
            ]
          },
          "readme": {
            "type": "string",
            "description": "The setup guide, markdown."
          },
          "changeNote": {
            "type": "string",
            "description": "What changed since the previous version."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the version was published."
          }
        }
      },
      "LibraryKitSummary": {
        "type": "object",
        "description": "A kit as a listing shows it.",
        "required": [
          "id",
          "publisher",
          "slug",
          "name",
          "summary",
          "visibility",
          "curated",
          "latestVersionNumber",
          "collaborators",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The kit's id."
          },
          "publisher": {
            "$ref": "#/components/schemas/SchemaPartPublisher"
          },
          "slug": {
            "type": "string",
            "description": "The kit's slug under its publisher."
          },
          "name": {
            "type": "string",
            "description": "The kit's name."
          },
          "summary": {
            "type": "string",
            "description": "What the kit sets up."
          },
          "visibility": {
            "type": "string",
            "description": "`public`, `unlisted` or `organization`, as for a part."
          },
          "curated": {
            "type": "boolean",
            "description": "Whether the platform curates the kit (\"Curated by Tessule\")."
          },
          "latestVersionNumber": {
            "type": "integer",
            "description": "The newest version's number."
          },
          "collaborators": {
            "type": "array",
            "description": "The organizations credited beside the publisher. Others see accepted credits only; the publisher's own organization also sees pending ones.",
            "items": {
              "$ref": "#/components/schemas/LibraryKitCollaborator"
            }
          },
          "withdrawn": {
            "type": "boolean",
            "description": "Whether the kit is withdrawn; only its publisher still sees a withdrawn kit."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the kit last changed."
          }
        }
      },
      "LibraryKit": {
        "description": "A kit with its latest version.",
        "allOf": [
          {
            "$ref": "#/components/schemas/LibraryKitSummary"
          },
          {
            "type": "object",
            "required": [
              "latestVersion"
            ],
            "properties": {
              "latestVersion": {
                "$ref": "#/components/schemas/LibraryKitVersion"
              }
            }
          }
        ]
      },
      "LibraryKitCredit": {
        "type": "object",
        "description": "A kit that credits the organization, as that organization sees it, pending or accepted.",
        "required": [
          "kit",
          "accepted"
        ],
        "properties": {
          "kit": {
            "$ref": "#/components/schemas/LibraryKitSummary"
          },
          "accepted": {
            "type": "boolean",
            "description": "Whether the organization has accepted the credit."
          }
        }
      },
      "AddLibraryKitCollaboratorRequest": {
        "type": "object",
        "description": "Credits an organization on a kit; it shows once an admin of that organization accepts.",
        "required": [
          "organizationId"
        ],
        "properties": {
          "organizationId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The organization to credit; not the publisher itself."
          }
        }
      },
      "KitInstallPartRequest": {
        "type": "object",
        "description": "One part's sections of a kit install, in the kit's part order: what `InstallRequest` takes for a part on its own, less the target and the people (bound once for the whole kit) and the roles review (one for the whole kit). Slots the kit binds to an earlier part's table are bound by the kit and may be left out here.",
        "properties": {
          "tableNames": {
            "type": "object",
            "description": "Part table name → the name it takes in this workspace.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "externalTables": {
            "type": "object",
            "description": "External-table slot → an existing table of this workspace, for slots the kit does not bind.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "secrets": {
            "type": "object",
            "description": "Secret slot → the name of a secret this workspace holds.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "currency": {
            "type": "string",
            "enum": [
              "keep",
              "workspaceDefault"
            ],
            "description": "As `InstallRequest.currency`."
          },
          "mode": {
            "type": "string",
            "enum": [
              "create",
              "reconcile"
            ],
            "description": "As `InstallRequest.mode`."
          },
          "roleNames": {
            "type": "object",
            "description": "Part role name → the name it takes in this workspace.",
            "additionalProperties": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          },
          "intakeNames": {
            "type": "object",
            "description": "Part intake name → the name it takes in this workspace.",
            "additionalProperties": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          },
          "include": {
            "$ref": "#/components/schemas/InstallRequestInclude"
          }
        }
      },
      "KitInstallRequest": {
        "type": "object",
        "description": "Installs a kit version into the caller's workspace: each part's sections in order, the people bound once for every part (a slot key means the same person in each part that names it), and the reviews. Request body of `POST /library/kits/{kitId}/versions/{number}/install` and of its preview.",
        "properties": {
          "parts": {
            "type": "array",
            "maxItems": 20,
            "description": "Each part's sections, index-aligned with the kit version's `parts`; a part with none may be `{}` or left off the end.",
            "items": {
              "$ref": "#/components/schemas/KitInstallPartRequest"
            }
          },
          "people": {
            "type": "object",
            "description": "People slot key → the member (`userId`) or group (`groupId`) that fills it, in every part.",
            "additionalProperties": {
              "$ref": "#/components/schemas/InstallPeopleBinding"
            }
          },
          "extension": {
            "type": "object",
            "description": "Whether to deploy the kit's extension source to this workspace's site and place its extensions.",
            "required": [
              "deploy"
            ],
            "properties": {
              "deploy": {
                "type": "boolean",
                "description": "Deploy the source and place its extensions. Needs the permission to manage the hosted site and `acknowledgedExtension`. A site that already has an active deployment is never replaced: unless `layerOnLiveSite` is true, the install succeeds without the extension and with an issue saying so."
              },
              "layerOnLiveSite": {
                "type": "boolean",
                "description": "When the site already serves a deployment, add the kit's files to it: the install deploys a new deployment holding the live one's files plus the source's, with the extension declarations merged, and makes it active (the previous one stays in the site's history to activate again). A source file at a path the live site holds with other content, or an extension id it already declares differently, refuses the layering with an issue, and the extension is not deployed. Ignored when the site serves nothing."
              }
            }
          },
          "acknowledgedRoles": {
            "type": "string",
            "description": "The preview's `rolesReviewToken`, sent back once a person has read the roles every part creates and who holds them. Required when any part creates roles."
          },
          "acknowledgedExtension": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "The extension source's digest (`KitInstallPreview.extension.sha256`), sent back once a person has agreed to deploy this code to their site. Required when `extension.deploy` is true."
          },
          "samples": {
            "type": "boolean",
            "description": "Deliver the kit version's sample documents once every part is installed, each through its intake as the caller. A sample the intake refuses is reported as an issue and the rest are delivered; samples never fail an install. Ignored when the version carries none."
          }
        }
      },
      "KitInstallPreviewPart": {
        "type": "object",
        "description": "One part of a kit install preview, previewed as it would install after the parts before it.",
        "required": [
          "partId",
          "name",
          "version",
          "preview",
          "kitBoundSlots"
        ],
        "properties": {
          "partId": {
            "type": "string",
            "description": "The part's id."
          },
          "name": {
            "type": "string",
            "description": "The part's name."
          },
          "version": {
            "type": "integer",
            "description": "The part version's number."
          },
          "preview": {
            "$ref": "#/components/schemas/InstallPreview"
          },
          "kitBoundSlots": {
            "type": "array",
            "description": "External-table slots the kit binds to a table an earlier part creates, as `slot → table`.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "KitInstallPreviewSamples": {
        "type": "object",
        "description": "What asking for the samples (`KitInstallRequest.samples`) would deliver.",
        "required": [
          "count",
          "intakes"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "description": "How many documents would be delivered."
          },
          "intakes": {
            "type": "array",
            "description": "The intakes they are delivered to, by the names the kit's parts create them under.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "KitInstallPreviewExtension": {
        "type": "object",
        "description": "What deploying the kit's extension source would do to this workspace's site.",
        "required": [
          "sha256",
          "extensions",
          "placements",
          "site"
        ],
        "properties": {
          "sha256": {
            "type": "string",
            "description": "The source's digest; `acknowledgedExtension` echoes it."
          },
          "extensions": {
            "type": "array",
            "description": "The extensions the source declares, with the scopes each asks for.",
            "items": {
              "$ref": "#/components/schemas/HostedSiteExtension"
            }
          },
          "placements": {
            "type": "array",
            "description": "Where the install places them, by the tables' installed names.",
            "items": {
              "$ref": "#/components/schemas/LibraryKitPlacement"
            }
          },
          "site": {
            "type": "string",
            "x-known-values": "KnownKitInstallSiteAction",
            "description": "`create` (the workspace has no site: one is created and the source deployed), `deploy` (the site has no active deployment: the source becomes it), `layer` (the site already serves a deployment and the request asked to add the kit's files to it: `extension.layerOnLiveSite`), `untouched` (the site already serves a deployment, which an install never replaces unless asked to layer: deploy and place by hand, as the readme says) or `unavailable` (hosted sites are not configured here). Open contract: clients must tolerate actions they do not know and show them as needing a look."
          }
        }
      },
      "KnownKitInstallSiteAction": {
        "type": "string",
        "description": "The site actions a kit install preview names.",
        "enum": [
          "create",
          "deploy",
          "layer",
          "untouched",
          "unavailable"
        ]
      },
      "KitInstallPreview": {
        "type": "object",
        "description": "A kit install, run against this workspace without changing anything: every part's preview in order (a later part sees the tables earlier parts would create), one roles review for the whole kit, and the extension review. Only a preview with no error issues anywhere installs.",
        "required": [
          "parts",
          "rolesReviewToken",
          "extension",
          "samples",
          "issues"
        ],
        "properties": {
          "parts": {
            "type": "array",
            "description": "Each part's preview, in install order.",
            "items": {
              "$ref": "#/components/schemas/KitInstallPreviewPart"
            }
          },
          "rolesReviewToken": {
            "type": [
              "string",
              "null"
            ],
            "description": "A digest of every part's roles review, in order; null when no part creates roles. Send it back as `acknowledgedRoles` once a person has read the roles."
          },
          "extension": {
            "description": "The extension review, or null when the kit carries no source or `extension.deploy` is false.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/KitInstallPreviewExtension"
              },
              {
                "type": "null"
              }
            ]
          },
          "samples": {
            "description": "The sample documents the version carries, whether or not the request asks for them; null when it carries none.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/KitInstallPreviewSamples"
              },
              {
                "type": "null"
              }
            ]
          },
          "issues": {
            "type": "array",
            "description": "Issues of the kit as a whole (the caller cannot deploy, a request section names no part).",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          }
        }
      },
      "KitInstallPart": {
        "type": "object",
        "description": "One step of a kit install.",
        "required": [
          "partId",
          "name",
          "version"
        ],
        "properties": {
          "partId": {
            "type": "string",
            "description": "The part's id."
          },
          "name": {
            "type": "string",
            "description": "The part's name."
          },
          "version": {
            "type": "integer",
            "description": "The part version's number."
          },
          "installId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The part install this step queued (`GET /library/installs/{installId}`), once queued."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "That part install's status, once queued."
          }
        }
      },
      "KitInstall": {
        "type": "object",
        "description": "A kit install and how far it has got.",
        "required": [
          "id",
          "kitId",
          "kitName",
          "version",
          "status",
          "parts",
          "placed",
          "samplesDelivered",
          "issues",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The kit install's id."
          },
          "kitId": {
            "type": "string",
            "description": "The kit's id."
          },
          "kitName": {
            "type": "string",
            "description": "The kit's name."
          },
          "version": {
            "type": "integer",
            "description": "The kit version installed."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownSchemaPartInstallStatus",
            "description": "`queued`, `running`, `succeeded` or `failed`, as a part install's (see KnownSchemaPartInstallStatus). Open contract: clients must tolerate statuses they do not know and keep polling."
          },
          "parts": {
            "type": "array",
            "description": "Its steps, in order.",
            "items": {
              "$ref": "#/components/schemas/KitInstallPart"
            }
          },
          "deploymentId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The site deployment the install made, if any."
          },
          "placed": {
            "type": "array",
            "description": "The extension blocks it placed, by installed table name.",
            "items": {
              "$ref": "#/components/schemas/LibraryKitPlacement"
            }
          },
          "samplesDelivered": {
            "type": [
              "integer",
              "null"
            ],
            "description": "How many sample documents the install delivered, once it has tried them; null when the request did not ask for samples or they are not yet delivered. A refused one is an issue."
          },
          "issues": {
            "type": "array",
            "description": "What the install could not do and left to the person (an untouched site, a layout it did not replace, a sample an intake refused), followed by each part install's own issues, their `path` prefixed `parts[i]` and their `message` with the part's name. A succeeded install can carry an `error`: sample rows that stopped partway leave the kit installed and say so here.",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the install failed, when it did."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it was requested."
          },
          "finishedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it ended."
          }
        }
      },
      "PublishSchemaPartRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/library/parts`: a new part's metadata and its first version's document. Slots, stats, capabilities and the platform pin are derived from the document; the publisher's only say over a slot is its `purpose` (and an external table's `suggestedPart`), which ride inside the document.",
        "type": "object",
        "required": [
          "slug",
          "name",
          "summary",
          "tags",
          "category",
          "licence",
          "visibility",
          "readme",
          "credit",
          "document"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[a-z0-9][a-z0-9-]*$",
            "description": "URL-safe name, unique within the publishing organization and fixed for good once published."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "description": "The part's display name."
          },
          "summary": {
            "type": "string",
            "minLength": 1,
            "maxLength": 280,
            "description": "One or two sentences on what the part is for, shown under its name in listings."
          },
          "tags": {
            "type": "array",
            "maxItems": 10,
            "description": "Lower-case tags for filtering the listing; may be empty.",
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9-]{1,32}$"
            }
          },
          "category": {
            "type": "string",
            "enum": [
              "sales",
              "operations",
              "people",
              "finance",
              "projects",
              "personal",
              "other"
            ],
            "description": "The process category to file the part under."
          },
          "licence": {
            "type": "string",
            "enum": [
              "CC0-1.0",
              "CC-BY-4.0",
              "MIT"
            ],
            "description": "The licence installers receive the part under. `CC0-1.0` is the friction-free choice a publish dialog pre-selects."
          },
          "visibility": {
            "type": "string",
            "enum": [
              "public",
              "unlisted",
              "organization"
            ],
            "description": "Who may find the part: `public`, `unlisted` (by link only) or `organization` (the publisher's own workspaces). `organization` requires the organization's plan to allow it (403 `LIBRARY_ORGANIZATION_VISIBILITY_DISABLED`)."
          },
          "readme": {
            "type": "string",
            "maxLength": 20000,
            "description": "Plain-text readme shown on the part page; may be empty."
          },
          "changeNote": {
            "type": "string",
            "maxLength": 1000,
            "description": "Optional note on the first version; later versions require one."
          },
          "credit": {
            "type": "string",
            "enum": [
              "named",
              "organization"
            ],
            "description": "`named` shows the publishing member's display name on the version, on a page every tenant can read; `organization` shows the publisher alone."
          },
          "document": {
            "description": "The part document to publish. Untyped here for the same reason\nSchemaPlanRequest.plan is: the shared TypeScript shape is\n`SchemaPartDocument` in `@taskexchange/api-spec`, so a malformed\ndocument reaches the validator and comes back as teaching issues\n(400) rather than an opaque request-validation error.\n"
          },
          "composedFrom": {
            "type": "array",
            "maxItems": 100,
            "description": "Table names in the publisher's workspace the document was composed from (the `tables` sent to `POST /library/compose`), recorded on the version so a later republish compose reads the same tables again. Leave it out for a document written by hand.",
            "items": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_]{1,63}$"
            }
          }
        }
      },
      "PublishSchemaPartVersionRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/library/parts/{partId}/versions`: the next version's document, readme and change note. The member who posts it becomes the credited user of the new version.",
        "type": "object",
        "required": [
          "changeNote",
          "readme",
          "credit",
          "document"
        ],
        "properties": {
          "changeNote": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000,
            "description": "What changed since the previous version, shown in the version list. Required from version 2."
          },
          "readme": {
            "type": "string",
            "maxLength": 20000,
            "description": "The new version's plain-text readme; send the previous one again to keep it."
          },
          "credit": {
            "type": "string",
            "enum": [
              "named",
              "organization"
            ],
            "description": "`named` shows the publishing member's display name on the version; `organization` shows the publisher alone."
          },
          "document": {
            "description": "The new version's part document. Untyped here for the same reason\nSchemaPlanRequest.plan is: the shared TypeScript shape is\n`SchemaPartDocument` in `@taskexchange/api-spec`, so a malformed\ndocument comes back as teaching issues (400).\n"
          },
          "composedFrom": {
            "type": "array",
            "maxItems": 100,
            "description": "Table names in the publisher's workspace the document was composed from (the `tables` sent to `POST /library/compose`), recorded on the version so a later republish compose reads the same tables again. Leave it out for a document written by hand.",
            "items": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_]{1,63}$"
            }
          }
        }
      },
      "PatchSchemaPartRequest": {
        "description": "Request body of `PATCH /organizations/{organizationId}/library/parts/{partId}`: the metadata a publisher may change after publishing. Only the properties sent change; the slug and the versions never do.",
        "type": "object",
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "description": "New display name."
          },
          "summary": {
            "type": "string",
            "minLength": 1,
            "maxLength": 280,
            "description": "New summary."
          },
          "tags": {
            "type": "array",
            "maxItems": 10,
            "description": "Replacement tag list (the whole list, not a delta).",
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9-]{1,32}$"
            }
          },
          "category": {
            "type": "string",
            "enum": [
              "sales",
              "operations",
              "people",
              "finance",
              "projects",
              "personal",
              "other"
            ],
            "description": "New process category."
          },
          "visibility": {
            "type": "string",
            "enum": [
              "public",
              "unlisted",
              "organization"
            ],
            "description": "New visibility. Narrowing never revokes copies already installed. `organization` requires the organization's plan to allow it (403 `LIBRARY_ORGANIZATION_VISIBILITY_DISABLED`)."
          },
          "deprecated": {
            "type": [
              "object",
              "null"
            ],
            "description": "Deprecate the part (hidden from the default listing, still installable) with a note and optionally a successor, or null to undo a deprecation.",
            "required": [
              "note"
            ],
            "properties": {
              "note": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500,
                "description": "Why the part is no longer recommended, shown beside it."
              },
              "successorPartId": {
                "type": "string",
                "pattern": "^[0-9a-f]{12}$",
                "description": "The part installers should use instead, when there is one."
              }
            }
          }
        }
      },
      "ForkSchemaPartRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/library/parts/{partId}/versions/{number}/fork`: the new part's metadata. Its first version copies the source version's document and readme, and the lineage is recorded.",
        "type": "object",
        "required": [
          "slug",
          "name",
          "summary",
          "tags",
          "category",
          "visibility",
          "licence"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[a-z0-9][a-z0-9-]*$",
            "description": "URL-safe name for the fork, unique within the forking organization."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "description": "The fork's display name."
          },
          "summary": {
            "type": "string",
            "minLength": 1,
            "maxLength": 280,
            "description": "The fork's summary."
          },
          "tags": {
            "type": "array",
            "maxItems": 10,
            "description": "The fork's tags; may be empty.",
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9-]{1,32}$"
            }
          },
          "category": {
            "type": "string",
            "enum": [
              "sales",
              "operations",
              "people",
              "finance",
              "projects",
              "personal",
              "other"
            ],
            "description": "The fork's process category."
          },
          "visibility": {
            "type": "string",
            "enum": [
              "public",
              "unlisted",
              "organization"
            ],
            "description": "Who may find the fork. `organization` requires the organization's plan to allow it (403 `LIBRARY_ORGANIZATION_VISIBILITY_DISABLED`)."
          },
          "licence": {
            "type": "string",
            "enum": [
              "CC0-1.0",
              "CC-BY-4.0",
              "MIT"
            ],
            "description": "The licence installers receive the fork under."
          }
        }
      },
      "ComposeRequest": {
        "description": "Request body of `POST /library/compose`: the workspace tables to compose a part document from.",
        "type": "object",
        "required": [
          "tables"
        ],
        "properties": {
          "tables": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "description": "Names of the workspace's tables to include. Companions that belong to them come along; anything that reaches outside the selection is left out and listed with the reason.",
            "items": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_]{1,63}$"
            }
          }
        }
      },
      "ComposeResult": {
        "description": "Response of `POST /library/compose`: a part document built from workspace tables, ready to edit and publish, and what was left out of it and why so the publisher can widen the selection.",
        "type": "object",
        "required": [
          "document",
          "leftOut"
        ],
        "properties": {
          "document": {
            "description": "The composed part document, holding names only (no workspace ids),\nwith people and secrets turned into slots. Untyped here for the\nsame reason SchemaPlanRequest.plan is: the shared TypeScript shape\nis `SchemaPartDocument` in `@taskexchange/api-spec`. Edit it, then\npost it as a part or version `document`.\n"
          },
          "leftOut": {
            "type": "array",
            "description": "What was not composed into the document, each with the reason: companions, and whatever of the tables' schema the plan export could not carry.",
            "items": {
              "type": "object",
              "required": [
                "kind",
                "name",
                "reason"
              ],
              "properties": {
                "kind": {
                  "type": "string",
                  "description": "What was left out: `schema` (part of the selected tables' schema the plan cannot carry, such as a lookup or rollup column or an automation rule reaching outside the selection), `savedView`, `flow`, `recordLayout`, `approvalRule`, `summary`, `dashboard`, `query` or `chart`. Clients must tolerate kinds they do not know and show the name and reason alone."
                },
                "name": {
                  "type": "string",
                  "description": "The left-out object's name, as the workspace shows it."
                },
                "reason": {
                  "type": "string",
                  "description": "Why it was left out (for example it reads a table outside the selection, or the caller cannot read it)."
                }
              }
            }
          }
        }
      },
      "ComposeFromWorkspaceRequest": {
        "description": "Request body of `POST /organizations/{organizationId}/library/parts/{partId}/compose`: the workspace to compose the part's next version from.",
        "type": "object",
        "required": [
          "workspaceId"
        ],
        "properties": {
          "workspaceId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The workspace holding the tables the part was composed from. The caller must be able to read its tables."
          }
        }
      },
      "ComposeFromWorkspaceResult": {
        "description": "Response of `POST /organizations/{organizationId}/library/parts/{partId}/compose`: the recomposed document and what was left out, plus its diff against the part's latest version — what \"Publish as version N+1\" would publish.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ComposeResult"
          },
          {
            "type": "object",
            "required": [
              "diff"
            ],
            "properties": {
              "diff": {
                "$ref": "#/components/schemas/SchemaPartDiff"
              }
            }
          }
        ]
      },
      "InstallTargetCurrent": {
        "description": "Install into the workspace the request is made in.",
        "type": "object",
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "current"
            ],
            "description": "Always `current`."
          }
        }
      },
      "InstallTargetNewWorkspace": {
        "description": "Install into a new workspace created in the installer's organization, which the installer administers. Requires the organization permission to manage workspaces.",
        "type": "object",
        "required": [
          "kind",
          "name",
          "environment"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "newWorkspace"
            ],
            "description": "Always `newWorkspace`."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "description": "Display name of the new workspace."
          },
          "environment": {
            "$ref": "#/components/schemas/WorkspaceEnvironment"
          }
        }
      },
      "InstallPeopleBinding": {
        "description": "Who fills one people slot of a part: a workspace member for a `user` slot, a group for a `group` slot. Send exactly one of the two ids.",
        "type": "object",
        "properties": {
          "userId": {
            "type": "string",
            "pattern": "^[0-9a-z]{12}$",
            "description": "The workspace member that fills a `user` slot."
          },
          "groupId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The group that fills a `group` slot."
          }
        }
      },
      "InstallSlotBindings": {
        "description": "Bindings for the slots a newer version of an installed part adds, sent with an update or its preview. Each is merged over the install's stored request, and the merged request is the one the update stores, so the next update starts from it. Only a slot the stored request does not bind may be named; naming one it binds is an error issue (`PART_UPDATE_SLOT_ALREADY_BOUND`) in the preview, which the update refuses on, since rebinding would move what the installed tables already reference.",
        "type": "object",
        "properties": {
          "externalTables": {
            "type": "object",
            "description": "External-table slot name → the name of an existing table in this workspace to bind it to, as in an install request.",
            "additionalProperties": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_]{1,63}$"
            }
          },
          "people": {
            "type": "object",
            "description": "People slot key → the member or group that fills it, as in an install request.",
            "additionalProperties": {
              "$ref": "#/components/schemas/InstallPeopleBinding"
            }
          },
          "secrets": {
            "type": "object",
            "description": "Secret slot name → the name of a secret this workspace already holds, as in an install request.",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "InstallUpdatePreviewRequest": {
        "description": "Optional request body of `POST /library/installs/{installId}/update/preview`: bindings for slots the new version adds. Without it the preview runs the install's stored request as is.",
        "type": "object",
        "properties": {
          "bindings": {
            "$ref": "#/components/schemas/InstallSlotBindings"
          }
        }
      },
      "InstallRequest": {
        "description": "Request body of the install preview and the install: where to put the part, how to adapt it to the workspace (renames, slot bindings, currency) and which companions to include. The preview and the install take the same request, so what was previewed is what installs.",
        "type": "object",
        "required": [
          "target"
        ],
        "properties": {
          "target": {
            "description": "Where the part goes — this workspace, or a new one.",
            "oneOf": [
              {
                "$ref": "#/components/schemas/InstallTargetCurrent"
              },
              {
                "$ref": "#/components/schemas/InstallTargetNewWorkspace"
              }
            ]
          },
          "tableNames": {
            "type": "object",
            "description": "Part table name → the name it takes in this workspace, to resolve a collision. Every reference, view, companion and sample row follows the rename.",
            "additionalProperties": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_]{1,63}$"
            }
          },
          "externalTables": {
            "type": "object",
            "description": "External-table slot name → the name of an existing table in this workspace to bind it to.",
            "additionalProperties": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_]{1,63}$"
            }
          },
          "people": {
            "type": "object",
            "description": "People slot key → the member (`userId`) or group (`groupId`) that fills it.",
            "additionalProperties": {
              "$ref": "#/components/schemas/InstallPeopleBinding"
            }
          },
          "secrets": {
            "type": "object",
            "description": "Secret slot name → the name of a secret this workspace already holds. Values never travel in an install.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "roleNames": {
            "type": "object",
            "description": "Part role name → the name it takes in this workspace, to resolve a collision with an existing role. A part never changes a role the workspace already has.",
            "additionalProperties": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          },
          "intakeNames": {
            "type": "object",
            "description": "Part intake name → the name it takes in this workspace, to resolve a collision.",
            "additionalProperties": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          },
          "acknowledgedRoles": {
            "type": "string",
            "description": "The `rolesReviewToken` of a preview made with this same request, sent back to say a person has read the roles the install creates and who they are assigned to. Required when the version carries roles and they are included: without it, or with a token from a preview of other bindings, the install answers 409 `PART_ROLES_NOT_REVIEWED`. An AI client shows the preview's `roles` to the person and installs only on their yes.",
            "maxLength": 128
          },
          "currency": {
            "type": "string",
            "enum": [
              "keep",
              "workspaceDefault"
            ],
            "description": "`workspaceDefault` sets every currency field to the workspace's default currency when it has one; `keep` (the default) leaves the publisher's."
          },
          "mode": {
            "type": "string",
            "enum": [
              "create",
              "reconcile"
            ],
            "description": "`create` (the default) refuses a table that already exists; `reconcile` reuses an identical existing table and reports one that differs."
          },
          "include": {
            "$ref": "#/components/schemas/InstallRequestInclude"
          },
          "enableFlows": {
            "type": "boolean",
            "enum": [
              false
            ],
            "description": "Only `false` is accepted: flows arrive created and published but disabled, to be enabled one by one after reading them."
          }
        }
      },
      "InstallPreview": {
        "description": "Response of the install preview: what installing the version with this request would do, what stands in the way, and what the part reaches for. Only a preview without error issues can be installed.",
        "type": "object",
        "required": [
          "issues",
          "willCreate",
          "willModify",
          "cannotApply",
          "capabilities",
          "compatibility",
          "compatibilityIssues",
          "reconcile",
          "roles",
          "rolesReviewToken"
        ],
        "properties": {
          "issues": {
            "type": "object",
            "description": "The resolved plan's issues, grouped by what the installer does about them.",
            "required": [
              "unboundSlots",
              "collisions",
              "other"
            ],
            "properties": {
              "unboundSlots": {
                "type": "array",
                "description": "Slots with no binding, or bound to something missing — bind them in the request.",
                "items": {
                  "$ref": "#/components/schemas/PlanIssue"
                }
              },
              "collisions": {
                "type": "array",
                "description": "Tables, saved views or flows whose names are already taken — rename them or reconcile.",
                "items": {
                  "$ref": "#/components/schemas/PlanIssue"
                }
              },
              "other": {
                "type": "array",
                "description": "Every other issue the validator found.",
                "items": {
                  "$ref": "#/components/schemas/PlanIssue"
                }
              }
            }
          },
          "willCreate": {
            "type": "object",
            "description": "What the install would create, by kind, with the final names after renames.",
            "required": [
              "tables",
              "views",
              "savedViews",
              "recordLayouts",
              "approvalRules",
              "summaries",
              "flows",
              "queries",
              "charts",
              "dashboards",
              "roles",
              "intakes"
            ],
            "properties": {
              "tables": {
                "type": "array",
                "description": "Tables, by final name.",
                "items": {
                  "type": "string"
                }
              },
              "views": {
                "type": "array",
                "description": "SQL views, by final name.",
                "items": {
                  "type": "string"
                }
              },
              "savedViews": {
                "type": "array",
                "description": "Saved views, by name.",
                "items": {
                  "type": "string"
                }
              },
              "recordLayouts": {
                "type": "array",
                "description": "Record page layouts, by the table they lay out.",
                "items": {
                  "type": "string"
                }
              },
              "approvalRules": {
                "type": "array",
                "description": "Approval rules, by name.",
                "items": {
                  "type": "string"
                }
              },
              "summaries": {
                "type": "array",
                "description": "Summary rows, by name.",
                "items": {
                  "type": "string"
                }
              },
              "flows": {
                "type": "array",
                "description": "Flows, by name; all arrive disabled.",
                "items": {
                  "type": "string"
                }
              },
              "queries": {
                "type": "array",
                "description": "Saved queries, by name.",
                "items": {
                  "type": "string"
                }
              },
              "charts": {
                "type": "array",
                "description": "Charts, by name.",
                "items": {
                  "type": "string"
                }
              },
              "dashboards": {
                "type": "array",
                "description": "Dashboards, by name.",
                "items": {
                  "type": "string"
                }
              },
              "roles": {
                "type": "array",
                "description": "Roles, by final name; each is described in `roles` for review.",
                "items": {
                  "type": "string"
                }
              },
              "intakes": {
                "type": "array",
                "description": "Intakes, by final name; each is published.",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "willModify": {
            "type": "array",
            "description": "The installer's EXISTING tables the install would change, one entry per table, each saying why the part reaches it and what it does there; empty when the install only creates. Show it beside `willCreate` so nobody installs a part without seeing that it touches their own tables.",
            "items": {
              "$ref": "#/components/schemas/InstallPreviewModification"
            }
          },
          "cannotApply": {
            "type": "array",
            "description": "Companion kinds the installer lacks the permission to create, so a wizard un-ticks them and says why rather than failing midway.",
            "items": {
              "type": "object",
              "required": [
                "kind",
                "reason"
              ],
              "properties": {
                "kind": {
                  "type": "string",
                  "description": "The companion kind, named as in `InstallRequest.include` (`flows`, `approvalRules`, …). Clients must tolerate kinds they do not know."
                },
                "reason": {
                  "type": "string",
                  "description": "Why it cannot be applied, naming the missing permission."
                }
              }
            }
          },
          "capabilities": {
            "$ref": "#/components/schemas/SchemaPartCapabilities"
          },
          "compatibility": {
            "type": "string",
            "x-known-values": "KnownSchemaPartCompatibility",
            "description": "The version's standing against the current platform (see KnownSchemaPartCompatibility); `attention` installs, with its warnings in `compatibilityIssues`. Open contract: clients must tolerate values they do not know."
          },
          "compatibilityIssues": {
            "type": "array",
            "description": "The warnings the version's last re-validation found.",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "reconcile": {
            "type": [
              "object",
              "null"
            ],
            "description": "For `mode` `reconcile`, what would be skipped as identical and what conflicts; null otherwise.",
            "required": [
              "skipped",
              "conflicts"
            ],
            "properties": {
              "skipped": {
                "$ref": "#/components/schemas/SchemaPlanSkippedStats"
              },
              "conflicts": {
                "type": "array",
                "description": "Existing objects that differ from the part's, which reconcile reports and never forces.",
                "items": {
                  "$ref": "#/components/schemas/PlanIssue"
                }
              }
            }
          },
          "roles": {
            "type": "array",
            "description": "Every role the install creates, described for a person to read before installing: what it can do, which records its rules reach and who holds it. Show all of it, and install only once the person has read it; empty when the install creates no role.",
            "items": {
              "$ref": "#/components/schemas/PartRoleReview"
            }
          },
          "rolesReviewToken": {
            "type": [
              "string",
              "null"
            ],
            "description": "A digest of exactly the roles described in `roles`, for this version and these bindings. Send it back as `InstallRequest.acknowledgedRoles` once the person has read them; null when the install creates no role."
          }
        }
      },
      "PartRoleReview": {
        "description": "One role a part install creates, in the words a person reviews it in: its actions by their catalogue labels, each row rule and metadata grant as a sentence over the installed tables' display names, and who it is assigned to.",
        "type": "object",
        "required": [
          "key",
          "name",
          "actions",
          "rules",
          "metadataGrants",
          "assignees"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "The role's key in the part document."
          },
          "name": {
            "type": "string",
            "description": "The role's name in this workspace, after any rename."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "The publisher's description of the role."
          },
          "actions": {
            "type": "array",
            "description": "The actions the role grants, each with its catalogue label.",
            "items": {
              "type": "object",
              "required": [
                "action",
                "label"
              ],
              "properties": {
                "action": {
                  "type": "string",
                  "description": "The action, as in the action catalogue (e.g. `records:update`)."
                },
                "label": {
                  "type": "string",
                  "description": "The catalogue's label for it, shown to the person."
                }
              }
            }
          },
          "rules": {
            "type": "array",
            "description": "Each row rule as a sentence, e.g. \"may update Invoices only when Review status is not approved\". A table's first rule on a verb governs it: roles without one there can no longer reach those records.",
            "items": {
              "type": "string"
            }
          },
          "metadataGrants": {
            "type": "array",
            "description": "Each metadata grant as a sentence, e.g. \"may create detections on Invoices\".",
            "items": {
              "type": "string"
            }
          },
          "assignees": {
            "type": "array",
            "description": "Who the role is assigned to at install, by people slot; empty when it is created unassigned (for instance, for an integration an admin attaches it to later).",
            "items": {
              "type": "object",
              "required": [
                "slot"
              ],
              "properties": {
                "slot": {
                  "type": "string",
                  "description": "The people slot's key."
                },
                "userId": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "The member bound to the slot; null when the slot is not bound yet."
                }
              }
            }
          },
          "flows": {
            "type": "array",
            "description": "The part's flows that hold the role. Such a flow runs as itself, not as the person who triggers it, with exactly the roles it holds: it can do what this role allows whoever sets it off. Absent or empty when no flow holds it.",
            "items": {
              "type": "object",
              "required": [
                "key",
                "name"
              ],
              "properties": {
                "key": {
                  "type": "string",
                  "description": "The flow's key in the part document."
                },
                "name": {
                  "type": "string",
                  "description": "The flow's name, as it will appear in the workspace."
                }
              }
            }
          }
        }
      },
      "InstallPreviewModification": {
        "description": "One existing workspace table the install would change: which table, why the part reaches it, and what it applies there. Saved views and summaries the part adds to the table are listed under `willCreate`, not here.",
        "type": "object",
        "required": [
          "table",
          "reason",
          "changes"
        ],
        "properties": {
          "table": {
            "type": "string",
            "description": "The table's name in this workspace (after the request's bindings and renames), so a client can link to the installer's own table."
          },
          "reason": {
            "type": "string",
            "x-known-values": "KnownInstallModifyReason",
            "description": "Why an existing table is involved (see KnownInstallModifyReason): an external table slot bound to it, a reconcile reusing it in place of one the part creates, or the built-in activities table the part enables and this workspace already has. Open contract: clients must tolerate values they do not know and show the table and its changes regardless."
          },
          "changes": {
            "type": "array",
            "description": "What the install applies to the table, in a stable order; never empty. A client lists each as a line such as \"adds fields\" or \"replaces the record layout\". Under `reconcile`, only what the table does not already have identically is listed.",
            "items": {
              "type": "string",
              "x-known-values": "KnownInstallModifyChange",
              "description": "One change the install applies to the table (see KnownInstallModifyChange). Open contract: clients must tolerate values they do not know and show them as a change to the table."
            }
          }
        }
      },
      "SchemaPartRefusal": {
        "description": "Why the library refused a document or a version: `error` says what is wrong and `code` names the refusal (`PART_VERSION_STALE`, `PART_INSTALL_PREVIEW_FAILED`, or none for a document that does not validate), and `issues` lists the `PlanIssue`s behind it, each locating a problem and saying how to fix it. Show the issues beside the document they point into.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ErrorResponse"
          },
          {
            "type": "object",
            "properties": {
              "issues": {
                "type": "array",
                "description": "The issues behind the refusal: the document's validation issues on a publish, the version's re-validation issues for `PART_VERSION_STALE`, the preview's error issues for `PART_INSTALL_PREVIEW_FAILED`. Empty or absent when the refusal is not about a document (a request that did not match this specification).",
                "items": {
                  "$ref": "#/components/schemas/PlanIssue"
                }
              }
            }
          }
        ]
      },
      "SchemaPartInstallCreatedObject": {
        "description": "One object an install created, by id and name, so a client can link to it.",
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The created object's id in the workspace."
          },
          "name": {
            "type": "string",
            "description": "The created object's name."
          }
        }
      },
      "SchemaPartInstall": {
        "description": "An install of a part version into a workspace: the job the install request queued, and once it succeeds the record of what the part became there. Poll `GET /library/installs/{installId}` until `status` is terminal.",
        "type": "object",
        "required": [
          "id",
          "workspaceId",
          "partId",
          "partName",
          "partSlug",
          "version",
          "status",
          "progress",
          "result",
          "created",
          "issues",
          "error",
          "updateAvailable",
          "updatedFrom",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The install's id; what `/library/installs/{installId}` names."
          },
          "workspaceId": {
            "type": "string",
            "description": "The workspace the part is installed into, and the one the install is read from. For a `newWorkspace` target it is the new workspace: the install is created in and polled from there (the caller is its first admin and obtains a token for it the usual way), so `GET /library/installs/{installId}` with the requesting workspace's token answers 404."
          },
          "partId": {
            "type": "string",
            "description": "The installed part."
          },
          "partName": {
            "type": "string",
            "description": "The installed part's name as it stands now, to name the install by. It is given even when the part is no longer visible to this workspace (withdrawn, or narrowed to its publisher's organization), since the workspace installed it; `updateAvailable` is null then."
          },
          "partSlug": {
            "type": "string",
            "description": "The installed part's slug as it stands now: its short, stable handle, unique within its publisher, for a client that shows or matches parts by handle."
          },
          "version": {
            "type": "integer",
            "description": "The installed version's number."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownSchemaPartInstallStatus",
            "description": "Where the job stands (see KnownSchemaPartInstallStatus). Open contract: clients must tolerate values they do not know and keep polling."
          },
          "progress": {
            "type": "object",
            "description": "How far a running install has got, for a progress bar.",
            "required": [
              "phase",
              "done",
              "total"
            ],
            "properties": {
              "phase": {
                "type": "string",
                "description": "`queued`, then the apply's own phases in order (schema, settings, seed, views, flows, layouts, dashboards, …). Clients must tolerate phases they do not know and show them as given."
              },
              "done": {
                "type": "integer",
                "description": "Units finished in the current phase."
              },
              "total": {
                "type": "integer",
                "description": "Units the current phase will do in total."
              }
            }
          },
          "result": {
            "type": [
              "object",
              "null"
            ],
            "description": "The apply's outcome once the job has finished; null before.",
            "required": [
              "applied",
              "companionChanges"
            ],
            "properties": {
              "applied": {
                "type": "boolean",
                "description": "Whether the part was applied."
              },
              "summary": {
                "type": "string",
                "description": "One human-readable sentence on what was created."
              },
              "companionChanges": {
                "description": "On a succeeded update (`updatedFrom` set), what changed in the part's companions (saved views, layouts, flows, dashboards and the rest) between the version the updated install had and this one, for the installer to apply by hand: an update applies the plan only. Its `plan` sections are empty but `lifecycles`, which lists the lifecycle changes on tables that already existed: an update designates lifecycles only on the tables it creates, so the installer's own lifecycle edits are never overwritten. Null on a plain install and on a failed update.",
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/SchemaPartDiff"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          },
          "created": {
            "type": [
              "object",
              "null"
            ],
            "description": "What the part became in the workspace once the install succeeded; null before or on failure. On an update it carries forward what the updated install recorded, plus any table the update added.",
            "required": [
              "tables",
              "savedViews",
              "flows",
              "recordLayouts",
              "dashboards"
            ],
            "properties": {
              "tables": {
                "type": "array",
                "description": "Tables created.",
                "items": {
                  "$ref": "#/components/schemas/SchemaPartInstallCreatedObject"
                }
              },
              "savedViews": {
                "type": "integer",
                "description": "Saved views created."
              },
              "flows": {
                "type": "array",
                "description": "Flows created, published and left disabled; link each so the installer can read and enable it.",
                "items": {
                  "$ref": "#/components/schemas/SchemaPartInstallCreatedObject"
                }
              },
              "recordLayouts": {
                "type": "integer",
                "description": "Record page layouts written."
              },
              "dashboards": {
                "type": "array",
                "description": "Dashboards created.",
                "items": {
                  "$ref": "#/components/schemas/SchemaPartInstallCreatedObject"
                }
              }
            }
          },
          "issues": {
            "type": "array",
            "description": "Issues the apply reported; on a failed install, why it failed.",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why a failed install failed, safe to show (it names a code such as `PART_NOT_FOUND` or `PART_VERSION_STALE` when the part changed after the request); null otherwise."
          },
          "updateAvailable": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The part's latest installable version number when it is newer than this install's version, so `POST /library/installs/{installId}/update` would update it; null when the install did not succeed, is already at that version, has been superseded by a succeeded update, or the part is no longer installable here. Show it as \"Update available\"."
          },
          "updatedFrom": {
            "type": [
              "string",
              "null"
            ],
            "description": "The install this one updates (an install queued by `POST /library/installs/{installId}/update`); null for a plain install."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the install was requested, ISO-8601 UTC."
          }
        }
      },
      "InstallUpdatePreview": {
        "description": "Response of `POST /library/installs/{installId}/update/preview`: what updating the install would do, previewed with the install's own stored request (its table names and its external-table, people and secret bindings) into this workspace in `reconcile` mode with every companion left out, exactly as the update runs. Only a preview with no error issues can be updated; pass `targetVersion` as the update's `expectedVersion` so the update runs the version that was previewed.",
        "type": "object",
        "required": [
          "targetVersion",
          "preview"
        ],
        "properties": {
          "targetVersion": {
            "type": "integer",
            "description": "The version the update would move the install to: the part's latest installable version, the install's `updateAvailable` as it stands now. Show the diff from the install's `version` to it."
          },
          "preview": {
            "$ref": "#/components/schemas/InstallPreview"
          }
        }
      },
      "UpdateInstallRequest": {
        "description": "Optional request body of `POST /library/installs/{installId}/update`. Without it the update moves the install to whatever the latest installable version is when the request arrives.",
        "type": "object",
        "properties": {
          "expectedVersion": {
            "type": "integer",
            "minimum": 1,
            "description": "The version the caller previewed (the update preview's `targetVersion`). When the part's latest installable version is no longer this one — a newer version was published, or this one stopped validating — the update is refused with 409 `INSTALL_UPDATE_VERSION_MOVED`, so nobody updates to a version they did not see."
          },
          "bindings": {
            "$ref": "#/components/schemas/InstallSlotBindings"
          }
        }
      },
      "SchemaPartAnalytics": {
        "description": "Response of `GET /organizations/{organizationId}/library/parts/{partId}/analytics`: how a part is used, per version, for its publisher.",
        "type": "object",
        "required": [
          "partId",
          "counters",
          "installsPerWeek",
          "versions"
        ],
        "properties": {
          "partId": {
            "type": "string",
            "description": "The part the figures are for."
          },
          "counters": {
            "$ref": "#/components/schemas/SchemaPartCounters"
          },
          "installsPerWeek": {
            "type": "array",
            "description": "New installs (not updates) that succeeded in each of the last 12 weeks, oldest first, a week starting on Monday (UTC). Every week is listed, empty ones as 0.",
            "items": {
              "type": "object",
              "required": [
                "weekStart",
                "installs"
              ],
              "properties": {
                "weekStart": {
                  "type": "string",
                  "format": "date",
                  "description": "The Monday the week starts on."
                },
                "installs": {
                  "type": "integer",
                  "description": "Installs that succeeded that week."
                }
              }
            }
          },
          "versions": {
            "type": "array",
            "description": "Per-version figures, newest version first.",
            "items": {
              "type": "object",
              "required": [
                "number",
                "installs",
                "activeInstalls",
                "forks"
              ],
              "properties": {
                "number": {
                  "type": "integer",
                  "description": "The version number."
                },
                "installs": {
                  "type": "integer",
                  "description": "Distinct workspaces this version was installed into."
                },
                "activeInstalls": {
                  "type": "integer",
                  "description": "Of those, workspaces whose install still has its tables."
                },
                "forks": {
                  "type": "integer",
                  "description": "Parts forked from this version."
                }
              }
            }
          }
        }
      },
      "SchemaPlanValidationResult": {
        "description": "Response of `POST /schema-plans/validate`: the dry-run verdict on a schema plan — whether it could be applied, every issue found, what it would create, and a stored draft id the apply call can name.",
        "type": "object",
        "required": [
          "valid",
          "issues",
          "stats"
        ],
        "properties": {
          "valid": {
            "description": "True when the plan has no blocking issues and `POST /schema-plans/apply` would accept it as-is. Warnings do not make it false.",
            "type": "boolean"
          },
          "issues": {
            "description": "Everything the validator found, errors and warnings alike, each located by its path within the plan and carrying a fix suggestion where there is one.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "stats": {
            "$ref": "#/components/schemas/SchemaPlanStats"
          },
          "summary": {
            "type": "string",
            "description": "Human-readable markdown summary of the proposed changes, present\nwhen the plan is valid. Show this to the user for confirmation\nbefore applying.\n"
          },
          "planId": {
            "type": "string",
            "description": "The stored draft of the document just validated, applicable by id for 30 minutes. Absent only when the request itself was refused."
          },
          "planHash": {
            "type": "string",
            "description": "Content hash of that document (key order ignored), so an approval can name it: \"apply plan 7f3a… (hash 9c1e…)\"."
          }
        }
      },
      "SchemaPlanApplyResult": {
        "description": "Response of `POST /schema-plans/apply`: whether the plan was applied and, if so, every table, field, constraint, automation rule and saved view it created with their server-assigned ids. A refused plan comes back with `applied: false`, the blocking `issues`, and nothing changed.",
        "type": "object",
        "required": [
          "applied",
          "issues",
          "stats"
        ],
        "properties": {
          "applied": {
            "description": "True when the whole plan was applied in one transaction. False when validation refused it: nothing was changed and `issues` says why.",
            "type": "boolean"
          },
          "issues": {
            "description": "Validation findings. On a refusal, the errors that blocked it; on success, warnings that did not.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanIssue"
            }
          },
          "stats": {
            "$ref": "#/components/schemas/SchemaPlanStats"
          },
          "planId": {
            "type": "string",
            "description": "The draft that was applied, when the request named one."
          },
          "planHash": {
            "type": "string",
            "description": "Content hash of the document that was applied (or refused), for the record."
          },
          "createdTables": {
            "description": "Tables the plan created, with the ids the server assigned them.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {
                "id": {
                  "description": "Server-assigned id of the new table; stable across renames.",
                  "type": "string"
                },
                "name": {
                  "description": "The table's snake_case name as stored, after sanitisation of what the plan proposed.",
                  "type": "string"
                },
                "displayName": {
                  "description": "The table's human-readable name as stored.",
                  "type": "string"
                }
              }
            }
          },
          "addedFields": {
            "description": "Fields the plan added, one entry per field, each naming the table it landed on.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {
                "tableId": {
                  "description": "Id of the table the field was added to.",
                  "type": "string"
                },
                "tableName": {
                  "description": "That table's name, so a summary can be read without another lookup.",
                  "type": "string"
                }
              }
            }
          },
          "addedConstraints": {
            "description": "Table constraints the plan added, each naming its table.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {
                "tableId": {
                  "description": "Id of the table the constraint applies to.",
                  "type": "string"
                },
                "tableName": {
                  "description": "That table's name.",
                  "type": "string"
                }
              }
            }
          },
          "addedAutomations": {
            "description": "Automation rules (cross-table derivations, not flows) the plan created.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {
                "id": {
                  "description": "Server-assigned id of the new automation rule.",
                  "type": "string"
                },
                "name": {
                  "description": "The rule's name as stored.",
                  "type": "string"
                }
              }
            }
          },
          "createdViews": {
            "description": "Saved views the plan created.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {
                "id": {
                  "description": "Server-assigned id of the new saved view.",
                  "type": "string"
                },
                "name": {
                  "description": "The view's stored name.",
                  "type": "string"
                },
                "displayName": {
                  "description": "The view's label as shown to users.",
                  "type": "string"
                }
              }
            }
          },
          "summary": {
            "description": "Human-readable markdown account of what was applied, suitable to show the user or an assistant as confirmation.",
            "type": "string"
          }
        }
      },
      "QueryResultRow": {
        "type": "object",
        "additionalProperties": true,
        "description": "A single result row with keys matching selected fields or aliases"
      },
      "QueryErrorResponse": {
        "type": "object",
        "description": "Why a query was refused. `code` is stable (INVALID_QUERY_TYPE, CROSS_SCHEMA_ACCESS, TABLE_NOT_FOUND, COLUMN_NOT_FOUND, SYNTAX_ERROR, UNSUPPORTED_SYNTAX, READ_ONLY, SQL_INVALID, QUERY_TIMEOUT, …). QUERY_TIMEOUT is a query that ran past the time allowed for one statement and was stopped; narrow it or make it do less work per row rather than retrying it unchanged. SQL_INVALID is any other error PostgreSQL raises against the caller's SQL (an ambiguous column, an unknown function, a bad cast), carrying PostgreSQL's own message. INVALID_QUERY_TYPE is a statement that is not one plain read (a write, DDL, several statements, a forbidden function); SYNTAX_ERROR is text that does not parse; UNSUPPORTED_SYNTAX is valid PostgreSQL the pre-flight parser cannot read yet, naming the construct and carrying the rewrite in `suggestion`. A COLUMN_NOT_FOUND that names a lookup, rollup or computed column says so — those are computed when records are read and are not columns of the SQL table — and carries the equivalent expression in `suggestion`.",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "description": "Human-readable explanation of the refusal, suitable to show the query's author; for `SQL_INVALID` it is PostgreSQL's own message.",
            "type": "string"
          },
          "code": {
            "description": "Stable machine-readable reason (the vocabulary is in the schema description). Switch on this, not on `error`, whose wording may change.",
            "type": "string"
          },
          "suggestion": {
            "type": "string",
            "description": "What to write instead, when the engine knows: for a read-time column, the scalar expression the app evaluates, written against the table aliased as `t`."
          }
        }
      },
      "QueryResponse": {
        "description": "Result of running a query: the rows, and metadata describing their columns, how many came back, whether more exist and how long the run took. Response of `POST /query` and `POST /queries/{queryId}/run`.",
        "type": "object",
        "required": [
          "rows",
          "metadata"
        ],
        "properties": {
          "rows": {
            "description": "The result rows, keyed by selected field name or alias, at most the query's limit; `metadata.hasMore` says whether the limit cut them off.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QueryResultRow"
            }
          },
          "metadata": {
            "description": "Facts about the result as a whole: how many rows came back, whether more exist, how long the query took and what each column holds.",
            "type": "object",
            "required": [
              "totalRows",
              "executionTimeMs",
              "resolvedSql",
              "readAt",
              "tables"
            ],
            "properties": {
              "totalRows": {
                "type": "integer",
                "description": "Number of rows returned"
              },
              "executionTimeMs": {
                "type": "number",
                "description": "Query execution time in milliseconds"
              },
              "hasMore": {
                "type": "boolean",
                "description": "Whether more rows exist beyond limit"
              },
              "resolvedSql": {
                "type": "string",
                "description": "The SQL that ran, after every `{{variable}}` and `[[optional]]` block was substituted and with the default `LIMIT` the server adds when the text names none — the statement a person can paste back into the query editor to reproduce these rows. A comment in the statement appears here as blank space of the same length: comments are removed before the statement runs. The server additionally wraps every query in its hard row ceiling, which never changes the rows below that ceiling."
              },
              "readAt": {
                "type": "string",
                "format": "date-time",
                "description": "The server time at which the rows were read."
              },
              "tables": {
                "type": "array",
                "description": "The distinct tables and SQL views of the workspace schema the result's columns were read from, by name, in column order — resolved from the database's own column provenance, so a joined query lists every table it touched. A column computed from no table (a constant, an aggregate over a join) names nothing; a result with no such provenance has an empty list.",
                "items": {
                  "type": "string",
                  "description": "A table or SQL view name in the workspace schema."
                }
              },
              "columns": {
                "description": "One entry per result column, in SELECT order, so a client can lay out and format rows without inspecting values.",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "description": "The column's key in each row: the selected field name or its alias.",
                      "type": "string"
                    },
                    "type": {
                      "description": "Value type of the column, decided once for all its rows: `number`, `boolean`, `object` (JSON) or `string` (text, dates and anything that could not be represented exactly as a number).",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "ReferenceOptionHit": {
        "description": "One record offered as a value for a reference field, as the picker shows it: the id to store and the label to display. Item of `ReferenceOptionsResponse`.",
        "type": "object",
        "required": [
          "id",
          "label"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The referenced record's id — the value a reference field stores."
          },
          "tableId": {
            "type": [
              "string",
              "null"
            ],
            "description": "For a `polymorphicReference` field, the target table this option's record is in — the `tableId` half of the value to store; absent for a single-target reference."
          },
          "label": {
            "type": "string",
            "description": "Display label, resolved from the reference field's configured display field (`referencedFieldId`), else the referenced table's display label (`DataTable.displayLabel` — a stored field or a read-time computed column), falling back to a caller-readable field named name/displayName/title, then the record id. Masking-aware — never sourced from a field the caller cannot read; a computed label whose inputs the caller may not read renders as the id."
          },
          "deleted": {
            "type": "boolean",
            "description": "True when the referenced record is in the recycle bin (#84). Only ever set on an `ids` resolve — a SEARCH never offers a binned row, because a write may not reference one. Its purpose is the tombstone: a stored value whose target has been binned still renders as a labelled chip marked deleted, instead of dangling as a raw id that resolves to nothing."
          }
        }
      },
      "RecordInboundReference": {
        "type": "object",
        "description": "One referencing field's contribution. Deliberately describes the CONSEQUENCE rather than addressing the schema: names are the display names a warning is written from, and the only identifier is `tableId`, which groups entries when several of a table's fields point here. Physical field/table names would be additive to add if a machine consumer ever needs them.",
        "required": [
          "tableId",
          "tableDisplayName",
          "fieldDisplayName",
          "count",
          "cascade"
        ],
        "properties": {
          "tableId": {
            "type": "string",
            "description": "The referencing table (the one holding the reference field)."
          },
          "tableDisplayName": {
            "description": "Display name of the referencing table, for writing the warning (\"3 Deals point at this Account\").",
            "type": "string"
          },
          "fieldDisplayName": {
            "type": "string",
            "description": "The reference field pointing at this record."
          },
          "count": {
            "type": "integer",
            "description": "How many live records hold this record through that field, counted under the caller's own row scope — so it never reveals rows the caller cannot read, and may under-count for a scoped caller."
          },
          "cascade": {
            "type": "boolean",
            "description": "True when the field's `cascadeBehavior` is `cascade`, meaning these records go to the bin WITH this one under the same batch (and come back together on restore). False means they stay live and keep pointing at a binned record — the tombstone case."
          }
        }
      },
      "RecordReferencesResponse": {
        "description": "The inbound references to one record — which fields on which tables point at it and how many of those rows a delete would take along. Response of `GET /tables/{tableId}/items/{itemId}/references`, read before confirming a delete.",
        "type": "object",
        "required": [
          "references",
          "totalCount",
          "cascadeCount"
        ],
        "properties": {
          "references": {
            "type": "array",
            "description": "One entry per referencing field that holds at least one record.",
            "items": {
              "$ref": "#/components/schemas/RecordInboundReference"
            }
          },
          "totalCount": {
            "type": "integer",
            "description": "Total records referencing this one, across every field."
          },
          "cascadeCount": {
            "type": "integer",
            "description": "The subset of `totalCount` that would be binned alongside this record. `totalCount - cascadeCount` is the number left holding a reference to a binned row."
          }
        }
      },
      "ReferenceOptionsResponse": {
        "description": "Response of `GET /tables/{tableId}/fields/{fieldId}/reference-options`: the picker options of a reference field — record ids with the display label the picker shows — either matching a search term or resolving a list of ids.",
        "type": "object",
        "required": [
          "options",
          "truncated"
        ],
        "properties": {
          "options": {
            "description": "Matching records of the referenced table (or users/groups), each with its id and the display label the picker shows, ranked by match; at most `limit` of them.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ReferenceOptionHit"
            }
          },
          "truncated": {
            "type": "boolean",
            "description": "True when more rows matched than `limit` allowed. For a search this means \"type more to narrow\"; for an `ids` resolve it means the ids list exceeded what one request returns."
          }
        }
      },
      "CaptureImage": {
        "type": "object",
        "description": "One photograph or one PDF document, inline. Clients downscale a photo before sending (the longest edge at or under ~1600px is plenty for print) — the server refuses anything over 2.5MB decoded, and the vision model would downscale a larger image anyway, so sending more only costs upload time. A PDF larger than that is read from an attachment already on a record instead (`CaptureExtractRequest.attachment`).\n",
        "required": [
          "mediaType",
          "dataBase64"
        ],
        "properties": {
          "mediaType": {
            "description": "MIME type of the encoded bytes: JPEG, PNG, WebP or GIF for a photograph, or `application/pdf` for a document whose selected pages are read (`pages`).",
            "type": "string",
            "enum": [
              "image/jpeg",
              "image/png",
              "image/webp",
              "image/gif",
              "application/pdf"
            ]
          },
          "dataBase64": {
            "type": "string",
            "minLength": 1,
            "description": "The image or PDF bytes, base64-encoded (2.5MB decoded maximum)."
          }
        }
      },
      "CaptureAttachmentSource": {
        "type": "object",
        "description": "A file already attached to a record of the target table, read in place of an inline image: the attachment the named field holds on the named record. The record must be visible to the caller under their own read scope, and the file must be a type capture accepts (a photograph or a PDF, up to 20MB for a PDF). Nothing is re-uploaded, and the proposal is laid over that record.",
        "required": [
          "itemId",
          "fieldId"
        ],
        "properties": {
          "itemId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The record in the target table that holds the attachment."
          },
          "fieldId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The attachment field of that record whose current file is read."
          }
        }
      },
      "CaptureDocumentInfo": {
        "type": "object",
        "description": "What the capture read when the source was a PDF: how many pages the document has and which of them were sent to the model, so the review can say \"pages 1–2 of 48\".",
        "required": [
          "pageCount",
          "pages"
        ],
        "properties": {
          "pageCount": {
            "type": "integer",
            "description": "Number of pages in the document."
          },
          "pages": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "The 1-based pages that were read, in the order they were sent."
          }
        }
      },
      "CaptureExtractRequest": {
        "description": "Request body of `POST /captures/extract`: one photographed business card, leaflet or sign, the table whose fields it should be read into, and optional context (a user note and any QR text decoded in the browser). Nothing is written; the response is a proposal the user confirms through the ordinary record create.",
        "type": "object",
        "required": [
          "tableId"
        ],
        "properties": {
          "tableId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "The table the proposed record is for; its fields are what the image is read into."
          },
          "image": {
            "$ref": "#/components/schemas/CaptureImage"
          },
          "attachment": {
            "$ref": "#/components/schemas/CaptureAttachmentSource"
          },
          "pages": {
            "type": "array",
            "minItems": 1,
            "maxItems": 5,
            "items": {
              "type": "integer",
              "minimum": 1
            },
            "description": "For a PDF source: the 1-based pages to read, at most 5 per capture (an information memorandum is read a few pages at a time, never whole). Omitted, the first page is read. A page beyond the document is refused with 400 `CAPTURE_INVALID_DOCUMENT`, naming the page count. Ignored for a photograph. The selected pages are extracted server-side and sent to the vision model as one document, so a multi-page selection yields one proposal."
          },
          "hint": {
            "type": "string",
            "maxLength": 500,
            "description": "Optional note from the user about the image (\"the roofer we met at the show\"). Given to the model as context, never as instructions.\n"
          },
          "qrText": {
            "type": "string",
            "maxLength": 4000,
            "description": "Text decoded client-side from a QR code on the image (typically a vCard or a URL), when the browser could read one. Given to the model alongside the photo as printed text — it is usually the most reliable copy of the contact details on the card.\n"
          }
        }
      },
      "CaptureKind": {
        "type": "string",
        "description": "What the image appears to be.",
        "enum": [
          "business_card",
          "leaflet",
          "flyer",
          "sign",
          "badge",
          "letterhead",
          "document",
          "other"
        ]
      },
      "CaptureFieldProposal": {
        "type": "object",
        "description": "One proposed field value. Already coerced into the field's wire shape (string, number, boolean, string array for multipicklist, address object) and validated against the field's own rules — a value that fails them is returned under `unplaced` instead, never here. The user still confirms every value before anything is written.\n",
        "required": [
          "fieldId",
          "fieldName",
          "value",
          "confidence",
          "sourceText"
        ],
        "properties": {
          "fieldId": {
            "description": "Stable identifier of the target field; the value survives a field rename and is what a client writes with.",
            "type": "string"
          },
          "fieldName": {
            "description": "The target field's `fieldName`, the key under which the value would sit in `TableItem.data`.",
            "type": "string"
          },
          "value": {
            "description": "The proposed value, in the field's wire shape (the same shape TableItem.data carries)."
          },
          "confidence": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "The model's confidence that this text belongs in this field, 0–1."
          },
          "sourceText": {
            "type": "string",
            "description": "The text on the image the value was read from, so the user can check it."
          },
          "label": {
            "type": "string",
            "description": "Human-readable rendering of the value when the value itself is an identifier — the referenced record's title for a reference field. Absent when the value is already readable.\n"
          }
        }
      },
      "CaptureUnplacedText": {
        "type": "object",
        "description": "Text the model could read but did not place — no matching field, or a value the field's rules refused.",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "description": "The text as it was read from the image.",
            "type": "string"
          },
          "note": {
            "type": "string",
            "description": "Why it was not placed, when known."
          }
        }
      },
      "CaptureDuplicateCandidate": {
        "type": "object",
        "description": "An existing record in the target table that matches one of the extracted values — offered so the user can update it instead of creating a twin. Found through global search under the caller's own read scope, so only records the caller may see are ever suggested.\n",
        "required": [
          "itemId",
          "title",
          "snippet",
          "matchedFields",
          "matchedOn"
        ],
        "properties": {
          "itemId": {
            "description": "The matching record's id, to open it or update it in place of creating a new one.",
            "type": "string"
          },
          "title": {
            "description": "The record's display title, as the app would show it in search results.",
            "type": "string"
          },
          "snippet": {
            "description": "Short excerpt of the record's readable text with the matching terms highlighted, as returned by global search; empty when the hit came only through the record's title.",
            "type": "string"
          },
          "matchedFields": {
            "description": "Names of the record's fields (ones the caller may read) in which the extracted value was found.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "matchedOn": {
            "type": "string",
            "description": "The extracted value that found this record (an email, phone number or name)."
          }
        }
      },
      "CaptureUsage": {
        "type": "object",
        "description": "Model tokens this extraction consumed — the same figures metered against the organization's AI budget.",
        "required": [
          "inputTokens",
          "outputTokens"
        ],
        "properties": {
          "inputTokens": {
            "description": "Tokens the model read (the images plus the prompt and schema).",
            "type": "integer"
          },
          "outputTokens": {
            "description": "Tokens the model produced for the proposal.",
            "type": "integer"
          }
        }
      },
      "CaptureProposal": {
        "description": "What the vision model read out of one photographed business card, leaflet or sign, shaped for the target table: candidate values per field, text it could not place, and existing records that may already be the same entity. Nothing has been written; the client shows it in the create form and the user confirms with an ordinary record create. Response of `POST /captures/extract`.",
        "type": "object",
        "required": [
          "tableId",
          "kind",
          "summary",
          "fields",
          "unplaced",
          "duplicates",
          "attachmentFieldId",
          "model",
          "usage"
        ],
        "properties": {
          "tableId": {
            "description": "The table the proposal was shaped for; the same table the client should create the record in.",
            "type": "string"
          },
          "kind": {
            "$ref": "#/components/schemas/CaptureKind"
          },
          "summary": {
            "type": "string",
            "description": "One line naming the entity the image is about (\"Jane Doe, Sales Director at Acme Ltd\")."
          },
          "fields": {
            "description": "One proposed value per field the model could fill, each with its confidence and the source text it came from. Fields with no readable value are omitted.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CaptureFieldProposal"
            }
          },
          "unplaced": {
            "description": "Text the model read but could not assign to a field, or that a field's rules refused; shown so the user can place it by hand or discard it.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CaptureUnplacedText"
            }
          },
          "duplicates": {
            "description": "Existing records in the table that match an extracted email, phone number or name, so the user can update one instead of creating a twin. Only records the caller may see; empty when nothing matched or the search was unavailable.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CaptureDuplicateCandidate"
            }
          },
          "attachmentFieldId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The table's attachment field the photo or document can be saved to (the first one that accepts its type), or null when the table has none — in which case the file is not kept once the record is created — and null when the source was an attachment already on a record, which has nothing to keep.\n"
          },
          "document": {
            "$ref": "#/components/schemas/CaptureDocumentInfo"
          },
          "model": {
            "type": "string",
            "description": "The model that read the image."
          },
          "usage": {
            "$ref": "#/components/schemas/CaptureUsage"
          }
        }
      },
      "SearchHit": {
        "description": "One record matched by global search, within its table's group (`SearchGroup`). Title, snippet and matched fields are computed over the caller-visible fields only.",
        "type": "object",
        "required": [
          "itemId",
          "title",
          "snippet",
          "rank",
          "matchedFields"
        ],
        "properties": {
          "itemId": {
            "type": "string",
            "description": "Record id, for navigating to the record."
          },
          "title": {
            "type": "string",
            "description": "Display title, resolved from the table's record layout title field, else the table's display label (`DataTable.displayLabel`, stored or computed), falling back to the first readable text field, then the record id. Masking-aware — never sourced from a field the caller cannot read.\n"
          },
          "snippet": {
            "type": "string",
            "description": "Match context with `**` around matched terms — explicit non-HTML markers, so clients render highlights without trusting markup. Computed over the caller-visible fields only, on accent-folded text (a hit on \"Müller\" is quoted as \"Muller\"). Empty on fuzzy hits (`SearchResponse.fuzzy`): there is no exact match to quote, and fabricating one would imply otherwise.\n"
          },
          "rank": {
            "type": "number",
            "description": "Relevance within this table's group only. Ranks are NOT comparable across tables — which is why results are grouped.\n"
          },
          "matchedFields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Field names the record matched on — why it is in the results. Caller-visible fields only, by construction. When the table's display label is a computed column, a match on one of the label's source columns — including a referenced table's label reached through a lookup — is reported under the label's name.\n"
          }
        }
      },
      "SearchGroup": {
        "description": "The search hits from one table, as grouped in `SearchResponse.groups`. Groups exist because relevance scores are not comparable across tables; hits are ranked within the group.",
        "type": "object",
        "required": [
          "tableId",
          "tableName",
          "total",
          "hits"
        ],
        "properties": {
          "tableId": {
            "description": "The table these hits belong to; navigate to it with the hit's record id.",
            "type": "string"
          },
          "tableName": {
            "type": "string",
            "description": "The table's display name — a user-facing grouping label."
          },
          "total": {
            "type": "integer",
            "description": "Matches for this caller in this table, before the per-table hit limit.\n"
          },
          "hits": {
            "description": "The best matches in this table, ranked, capped by the per-table hit limit; `total` says how many matched in all.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SearchHit"
            }
          }
        }
      },
      "SearchTruncation": {
        "description": "How much of the workspace a search covered when the table budget cut it short. Present on `SearchResponse` so the UI can tell the user the results are partial.",
        "type": "object",
        "required": [
          "tablesSearched",
          "tablesSkipped"
        ],
        "properties": {
          "tablesSearched": {
            "type": "integer",
            "description": "How many tables this search actually ran against."
          },
          "tablesSkipped": {
            "type": "integer",
            "description": "How many searchable tables the table budget cut before they were searched. Zero means the search covered everything it could see; a non-zero value must be surfaced to the user — a search that quietly covers 40 of a workspace's 200 tables is worse than one that admits it.\n"
          }
        }
      },
      "SearchAssetHit": {
        "description": "One non-record result of workspace search: a table, dashboard, chart or saved query whose title matched. Item of `SearchResponse`.",
        "type": "object",
        "required": [
          "kind",
          "itemId",
          "title"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "description": "What the matched title names — `table`, `dashboard`, `chart`, or `query` (a saved query). Open by contract: new asset kinds may be added over time, so clients MUST tolerate unknown values (skip them or render generically) rather than switching exhaustively.",
            "x-known-values": "KnownSearchAssetKind"
          },
          "itemId": {
            "type": "string",
            "description": "The asset's id — a table, dashboard, chart, or saved-query id, per `kind` — for navigating to the asset."
          },
          "title": {
            "type": "string",
            "description": "The asset's user-facing title (a table's display name; the stored name for the rest)."
          }
        }
      },
      "KnownSearchAssetKind": {
        "type": "string",
        "description": "Asset kinds the title search currently covers.",
        "enum": [
          "table",
          "dashboard",
          "chart",
          "query"
        ]
      },
      "SearchResponse": {
        "description": "Response of `GET /search`: workspace-wide record search results grouped by table, plus matching workspace assets (tables, dashboards, charts, saved queries), with flags saying whether results were truncated, degraded, or came from the fuzzy fallback.",
        "type": "object",
        "required": [
          "groups",
          "assets",
          "truncated",
          "degradedTableIds",
          "fuzzy"
        ],
        "properties": {
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SearchGroup"
            },
            "description": "Grouped by table; groups ordered by their best hit, hits ranked within their group.\n"
          },
          "assets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SearchAssetHit"
            },
            "description": "Workspace assets — tables, dashboards, charts, saved queries — whose TITLES match every search term as an accent-folded substring. Independent of the record groups: each kind appears only when the caller holds its read action (tables:read, dashboards:read, charts:read, savedQueries:read). Ordered by kind, then title.\n"
          },
          "truncated": {
            "$ref": "#/components/schemas/SearchTruncation"
          },
          "degradedTableIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Tables that were searched correctly but without a usable index (missing, stale, or invalid) — degraded and visible, not absent and silent. Tables a workspace opted out of search are simply absent, not listed here: the opt-out is an answer, not a failure.\n"
          },
          "fuzzy": {
            "type": "boolean",
            "description": "True when the strict full-text pass found nothing and `groups` came from the trigram (typo-tolerance and substring) fallback instead — close matches, not exact ones. Clients MUST surface the distinction; hits in fuzzy responses carry an empty `snippet`. Asset hits are unaffected (asset title matching is substring-based already).\n"
          }
        }
      },
      "WorkspaceStoreItem": {
        "description": "A free-form JSON document stored per workspace under a client-chosen `type` and `name` — the generic storage behind features that have no dedicated table. Returned by the `/store/workspace` endpoints.",
        "type": "object",
        "required": [
          "id",
          "type",
          "name",
          "contents",
          "locked",
          "createdBy",
          "updatedBy",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Stable identifier of the stored item, used in the `/store/workspace/{itemId}` endpoints.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "type": {
            "type": "string",
            "maxLength": 64,
            "description": "Item type (e.g., saved_query, dashboard, report)"
          },
          "name": {
            "type": "string",
            "maxLength": 255,
            "description": "Display name for the stored item"
          },
          "contents": {
            "type": "object",
            "additionalProperties": true,
            "description": "Flexible JSON payload"
          },
          "locked": {
            "type": "boolean",
            "description": "Prevent accidental modification"
          },
          "createdBy": {
            "description": "User id of whoever created the item.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$"
          },
          "updatedBy": {
            "description": "User id of whoever last saved the item; equals `createdBy` until it is edited.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$"
          },
          "createdAt": {
            "description": "When the item was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the item was last saved, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateWorkspaceStoreItem": {
        "description": "Request body of `POST /store/workspace`: a new free-form JSON document in the workspace store, filed under a client-chosen `type` so it can be listed back by kind. The server assigns the id, author and timestamps.",
        "type": "object",
        "required": [
          "type",
          "name",
          "contents"
        ],
        "properties": {
          "type": {
            "description": "Client-chosen kind of the document (e.g. `saved_query`, `dashboard`, `report`) used to list items back by `?type=`. Fixed once created.",
            "type": "string",
            "maxLength": 64
          },
          "name": {
            "description": "Display name of the stored item, as a list of items of this type should show it. Need not be unique.",
            "type": "string",
            "maxLength": 255
          },
          "contents": {
            "description": "The document itself: any JSON object, stored as given and returned verbatim. The server does not interpret it.",
            "type": "object",
            "additionalProperties": true
          },
          "locked": {
            "description": "Create the item already locked, so updates and deletion are refused with 403 until it is unlocked. Default false.",
            "type": "boolean",
            "default": false
          }
        }
      },
      "UpdateWorkspaceStoreItem": {
        "description": "Request body of `PUT /store/workspace/{itemId}`: the fields of a workspace store item to change. Only the fields present are written; an item that is currently locked refuses the update with 403.",
        "type": "object",
        "properties": {
          "name": {
            "description": "New display name for the item. Omit to keep the current one.",
            "type": "string",
            "maxLength": 255
          },
          "contents": {
            "description": "Replacement JSON payload; the whole document is replaced, not merged. Omit to keep the current contents.",
            "type": "object",
            "additionalProperties": true
          },
          "locked": {
            "description": "Set true to protect the item from further updates (a locked item answers 403 to this endpoint, including attempts to unlock it). Omit to leave the lock as it is.",
            "type": "boolean"
          }
        }
      },
      "UserStoreItem": {
        "description": "A free-form JSON document kept per user per workspace (recent queries, preferences, favourites), filed under a client-chosen `type`. Returned by the `/store/user` endpoints; visible only to the user who owns it.",
        "type": "object",
        "required": [
          "id",
          "workspaceId",
          "userId",
          "type",
          "name",
          "contents",
          "locked",
          "createdBy",
          "updatedBy",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "description": "Identifier of the item, used in the `/store/user/{itemId}` endpoints.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "workspaceId": {
            "description": "The workspace this item belongs to. Personal items are kept per workspace, so the same user has a separate store in each.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          },
          "userId": {
            "description": "User id of the owner — the only person who can read or change the item.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$"
          },
          "type": {
            "type": "string",
            "maxLength": 64,
            "description": "Item type (e.g., recent_query, preference, favorite)"
          },
          "name": {
            "type": "string",
            "maxLength": 255,
            "description": "Display name for the stored item"
          },
          "contents": {
            "type": "object",
            "additionalProperties": true,
            "description": "Flexible JSON payload"
          },
          "locked": {
            "type": "boolean",
            "description": "Prevent accidental modification"
          },
          "createdBy": {
            "description": "User id of the creator; always the owner, since items are created through the owner's own session.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$"
          },
          "updatedBy": {
            "description": "User id of the last person to change the item; the owner, since only they can.",
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[a-z0-9]{12}$"
          },
          "createdAt": {
            "description": "When the item was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the item's name, contents or lock last changed, ISO-8601 UTC; equals `createdAt` until the first update.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateUserStoreItem": {
        "description": "Request body of `POST /store/user`: add one item to the caller's personal key-value store for this workspace (recent queries, preferences, assistant history and the like). Items are private to the user who created them.",
        "type": "object",
        "required": [
          "type",
          "name",
          "contents"
        ],
        "properties": {
          "type": {
            "description": "Client-chosen category of the item, e.g. `recent_query`, `preference`, `favorite`; up to 64 characters. The list endpoint filters on it.",
            "type": "string",
            "maxLength": 64
          },
          "name": {
            "description": "Label identifying the item within its type, up to 255 characters; shown wherever the client lists its stored items.",
            "type": "string",
            "maxLength": 255
          },
          "contents": {
            "description": "The stored payload, any JSON object. The server keeps it opaque and returns it exactly as sent.",
            "type": "object",
            "additionalProperties": true
          },
          "locked": {
            "description": "When true, later updates and deletes of the item are refused with 403 (`Item is locked`), guarding it against accidental modification. Defaults to false.",
            "type": "boolean",
            "default": false
          }
        }
      },
      "UpdateUserStoreItem": {
        "description": "Request body of `PUT /store/user/{itemId}`: changes a personal store item's name, contents or lock. Only the supplied fields change; `type` is fixed at creation, and a locked item refuses the update with 403 until it is unlocked.",
        "type": "object",
        "properties": {
          "name": {
            "description": "New display name for the item. Omit to keep the current one.",
            "type": "string",
            "maxLength": 255
          },
          "contents": {
            "description": "Replacement document: the whole JSON object is stored as given, not merged with the existing contents. Omit to keep the current contents.",
            "type": "object",
            "additionalProperties": true
          },
          "locked": {
            "description": "True locks the item, after which further updates and deletion are refused with 403; false unlocks it. Note an already-locked item refuses this update too, so a lock cannot be lifted through this endpoint.",
            "type": "boolean"
          }
        }
      },
      "OAuthTokenRequest": {
        "description": "Request body of `POST /oauth/token` (form-encoded or JSON). Four grants are supported. `authorization_code` exchanges the code issued by the authorize flow for an access token; the PKCE verifier is checked when the authorize request carried a challenge. `refresh_token` trades a refresh token for a new access token. The RFC 8693 token-exchange grant (`urn:ietf:params:oauth:grant-type:token-exchange`) trades an id_token from the organization's own identity provider for a short-lived access token scoped to one workspace, for a connected app acting as the signed-in member; it issues no refresh token. `client_credentials` lets a partner whose integration a workspace installed mint a 15-minute access token that acts as that integration in that workspace; it authenticates with the partner's client secret, names the workspace in `resource`, and issues no refresh token. Refusals use `OAuthErrorResponse`.",
        "type": "object",
        "required": [
          "grant_type"
        ],
        "properties": {
          "grant_type": {
            "description": "The OAuth 2.0 grant being exercised: `authorization_code`, `refresh_token`, `urn:ietf:params:oauth:grant-type:token-exchange` (RFC 8693), or `client_credentials`.",
            "type": "string",
            "enum": [
              "authorization_code",
              "refresh_token",
              "urn:ietf:params:oauth:grant-type:token-exchange",
              "client_credentials"
            ]
          },
          "code": {
            "type": "string",
            "description": "Authorization code from the authorize flow. Read by the `authorization_code` grant, which requires it."
          },
          "redirect_uri": {
            "type": "string",
            "description": "Must match the redirect_uri used in authorize. Read by the `authorization_code` grant."
          },
          "code_verifier": {
            "type": "string",
            "description": "PKCE code verifier (optional but recommended). Read by the `authorization_code` grant."
          },
          "refresh_token": {
            "type": "string",
            "description": "The refresh token issued with an earlier access token. Read by the `refresh_token` grant, which requires it."
          },
          "client_id": {
            "type": "string",
            "description": "The OAuth client's id. Read by the token-exchange grant, which requires it and accepts only a connected app's client id; the other grants may carry it as client authentication, and the `client_credentials` grant requires it (here or in HTTP Basic)."
          },
          "client_secret": {
            "type": "string",
            "description": "The confidential client's secret, when it is not sent in HTTP Basic. Required by the `client_credentials` grant."
          },
          "resource": {
            "type": "string",
            "description": "RFC 8707 resource indicator. For the token-exchange and `client_credentials` grants, which require it, the workspace the token is for, as `https://<api host>/workspaces/{workspaceId}`; neither issues a workspace-less token."
          },
          "scope": {
            "type": "string",
            "description": "Space-separated scopes to narrow the token to. For the token-exchange grant it can only remove from the connected app's ceiling, and for the `client_credentials` grant from the install's; omitted, the token carries the whole ceiling."
          },
          "subject_token": {
            "type": "string",
            "description": "The id_token the organization's identity provider issued for the signed-in person. Read by the token-exchange grant, which requires it."
          },
          "subject_token_type": {
            "type": "string",
            "description": "What kind of token `subject_token` is. Read by the token-exchange grant, which requires it; an id_token is the only kind accepted.",
            "enum": [
              "urn:ietf:params:oauth:token-type:id_token"
            ]
          }
        }
      },
      "OAuthTokenResponse": {
        "description": "Tokens issued by `POST /oauth/token` (RFC 6749 token response) after an authorization-code, refresh-token, token-exchange or client-credentials grant. The access token is presented as a bearer token to the API and the MCP endpoint.",
        "type": "object",
        "required": [
          "access_token",
          "token_type",
          "expires_in"
        ],
        "properties": {
          "access_token": {
            "description": "Bearer token to send as `Authorization: Bearer …` on API and MCP requests. Valid for `expires_in` seconds.",
            "type": "string"
          },
          "issued_token_type": {
            "type": "string",
            "description": "RFC 8693 type of the issued token, `urn:ietf:params:oauth:token-type:access_token`. Present on the token-exchange grant only."
          },
          "token_type": {
            "description": "Always `Bearer` (RFC 6750).",
            "type": "string",
            "enum": [
              "Bearer"
            ]
          },
          "expires_in": {
            "type": "integer",
            "description": "Token lifetime in seconds. On the token-exchange grant it never exceeds the remaining life of the subject token."
          },
          "refresh_token": {
            "type": "string",
            "description": "Token for refreshing access. Absent on the token-exchange grant: the identity provider's session is the session of record, so exchange again with a fresh id_token."
          },
          "scope": {
            "type": "string",
            "description": "Space-separated scopes the access token carries."
          }
        }
      },
      "OAuthClientRegistrationRequest": {
        "description": "Dynamic client registration (RFC 7591) for a local OAuth client such as an MCP host. Request body of the unauthenticated `POST /oauth/register`; because anyone can call it, only loopback redirect URIs are accepted.",
        "type": "object",
        "required": [
          "redirect_uris"
        ],
        "properties": {
          "client_name": {
            "type": "string",
            "description": "Human-readable name of the client"
          },
          "redirect_uris": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Allowed redirect URIs. Registration is unauthenticated, so every URI must be an http loopback URI (127.0.0.1, [::1] or localhost) — an authorization code can then only ever be delivered to the user's own machine. A client with a hosted https callback must be registered by an operator instead."
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "OAuth grant types the client will use"
          },
          "response_types": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "OAuth response types the client will use"
          },
          "token_endpoint_auth_method": {
            "type": "string",
            "description": "Authentication method for token endpoint"
          },
          "software_id": {
            "type": "string",
            "description": "Unique identifier for the client software"
          },
          "software_version": {
            "type": "string",
            "description": "Version of the client software"
          }
        }
      },
      "OAuthClientRegistrationResponse": {
        "description": "Response (201) of `POST /oauth/register`: the client metadata as registered, per RFC 7591. The server echoes what it stored, with defaults filled in for metadata the request left out; for an existing `software_id` it is the stored client, not the request.",
        "type": "object",
        "required": [
          "client_id",
          "redirect_uris"
        ],
        "properties": {
          "client_id": {
            "type": "string",
            "description": "Issued client identifier"
          },
          "client_name": {
            "description": "Human-readable name of the client as stored, shown to the user when they authorize it. Absent when the request gave none.",
            "type": "string"
          },
          "redirect_uris": {
            "description": "The redirect URIs the client may use at `/oauth/authorize`, as stored. For a re-registration of an existing `software_id` this includes the previously stored URIs plus any loopback URIs the request added.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "grant_types": {
            "description": "OAuth 2.0 grant types the client may use at the token endpoint; defaults to `authorization_code` and `refresh_token`. For an existing `software_id` the stored grants are returned regardless of what the request asked for.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "response_types": {
            "description": "OAuth 2.0 response types the client may request at `/oauth/authorize`; defaults to `code`.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "token_endpoint_auth_method": {
            "description": "How the client authenticates at the token endpoint. Defaults to `none`, the only method this server supports: clients are public and prove themselves with PKCE.",
            "type": "string"
          },
          "client_id_issued_at": {
            "type": "integer",
            "description": "Unix timestamp when client_id was issued"
          }
        }
      },
      "ApiTokenBaseRole": {
        "type": "string",
        "enum": [
          "member",
          "none"
        ],
        "description": "What a token may do before any role is attached to it. `member` (the default) starts from the member baseline, or the reader baseline if its owner is a reader. `none` starts from nothing: the token holds only the actions and record access of the roles attached to it, which makes a narrow credential (for example, one that can only deploy the workspace's hosted site). Either way a token never exceeds what its owner may do at the moment it is used."
      },
      "ApiToken": {
        "description": "Metadata of one workspace API token, as listed by `GET /api-tokens`. Never carries the token value itself; that is shown once at creation (`ApiTokenCreated`).",
        "type": "object",
        "required": [
          "id",
          "name",
          "baseRole",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "12-char hex token ID, used to identify and revoke the token"
          },
          "name": {
            "description": "Label the creator gave the token so it can be recognised in the list, e.g. \"CI deploy\". Free text, not unique.",
            "type": "string"
          },
          "baseRole": {
            "$ref": "#/components/schemas/ApiTokenBaseRole"
          },
          "lastUsedAt": {
            "description": "When the token last authenticated a request, ISO-8601 UTC; updated asynchronously on use, so it can lag by moments. Null for a token that has never been used.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "expiresAt": {
            "description": "When the token stops authenticating, ISO-8601 UTC, as set at creation. Null for a token that never expires.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "description": "When the token was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AgentSummary": {
        "type": "object",
        "description": "An agent named beside something it did or may do: its id and the name its owner gave it. The `Agent` schema is the full resource.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The agent's id, which `GET /agents/{agentId}` reads back."
          },
          "name": {
            "type": "string",
            "description": "The name the owner gave the agent, as the audit trail shows it."
          }
        }
      },
      "Agent": {
        "type": "object",
        "description": "An agent (configurable authorization, spec section 5.8): a principal of its own that a member creates and connects an AI client to through OAuth, choosing it on the consent screen. It holds no baseline role — its permissions are exactly the roles attached to it, then the scopes the owner consented to — and the owner may attach only roles they hold themselves (`permissions:manage` may attach any). What the agent writes is still the owner's (`createdBy`, `ownedBy`); the audit trail and record history name the agent beside them. A disabled agent authenticates nothing until it is enabled again.",
        "required": [
          "id",
          "name",
          "description",
          "ownerUserId",
          "ownerName",
          "disabled",
          "roles",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The agent's id; the consent screen sends it as `agent_id`."
          },
          "name": {
            "type": "string",
            "description": "The name the owner gave the agent, shown wherever the agent's writes are listed."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the agent is for, in the owner's words; null when none was given."
          },
          "ownerUserId": {
            "type": "string",
            "description": "The member who owns the agent and whose grants cap what may be attached to it."
          },
          "ownerName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The owner's display name, resolved at read time; null when the account no longer resolves."
          },
          "disabled": {
            "type": "boolean",
            "description": "True when the agent authenticates nothing: switched off by its owner, or its owner left the workspace. Enabling it again is the owner's call."
          },
          "roles": {
            "type": "array",
            "description": "The roles attached to the agent, which are the whole of its permissions.",
            "items": {
              "type": "object",
              "required": [
                "id",
                "name"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "description": "The role's id."
                },
                "name": {
                  "type": "string",
                  "description": "The role's name."
                }
              }
            }
          },
          "createdAt": {
            "description": "When the agent was created, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "description": "When the agent or its attachments last changed, ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateAgentRequest": {
        "type": "object",
        "description": "Body of `POST /agents`; the caller becomes the owner.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "The agent's name, free text and not unique."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000,
            "description": "What the agent is for, for the owner's own list."
          }
        }
      },
      "UpdateAgentRequest": {
        "type": "object",
        "description": "Body of `PATCH /agents/{agentId}`; every field is optional and only the fields sent change.",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "A new name."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000,
            "description": "A new description; null clears it."
          },
          "disabled": {
            "type": "boolean",
            "description": "True switches the agent off (every token it holds stops authenticating at once); false switches it on again."
          }
        }
      },
      "AttachAgentRoleRequest": {
        "type": "object",
        "description": "Body of `POST /agents/{agentId}/roles`. The owner may attach a role they hold themselves; a caller with `permissions:manage` may attach any role whose grants are within their own (the anti-escalation rule every role assignment follows).",
        "required": [
          "roleId"
        ],
        "properties": {
          "roleId": {
            "type": "string",
            "description": "The role to attach."
          }
        }
      },
      "IntegrationAccount": {
        "type": "object",
        "description": "An integration: a principal a workspace admin creates for a machine (a scanner, a feed, a device). It belongs to the workspace, not to a person: it holds exactly the roles attached to it over no baseline, it cannot sign in, it reaches the API only through tokens issued to it, and everything it writes names it, in record history and the audit log. It is never counted as a seat. A disabled integration authenticates nothing until it is enabled again.",
        "required": [
          "id",
          "name",
          "description",
          "userId",
          "disabled",
          "roles",
          "tokenCount",
          "partnerClient",
          "scopes",
          "createdBy",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The integration's id, used in the paths below."
          },
          "name": {
            "type": "string",
            "description": "The integration's name, shown wherever its writes are listed."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the integration is for; null when none was given."
          },
          "userId": {
            "type": "string",
            "description": "The account the integration acts as: the id its records' `createdBy`, record history and the audit log name."
          },
          "disabled": {
            "type": "boolean",
            "description": "True when the integration authenticates nothing; its tokens stop working at once."
          },
          "roles": {
            "type": "array",
            "description": "The roles attached to the integration, which are the whole of its permissions.",
            "items": {
              "$ref": "#/components/schemas/IntegrationAccountRole"
            }
          },
          "tokenCount": {
            "type": "integer",
            "description": "How many tokens the integration holds. Always 0 for a partner's install, whose credential is the partner's own client."
          },
          "partnerClient": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/IntegrationPartnerClient"
              },
              {
                "type": "null"
              }
            ],
            "description": "The partner this integration is an install of: its tokens are minted by the partner with the `client_credentials` grant. Null for an integration whose tokens the workspace issues."
          },
          "scopes": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "The ceiling on what the partner's tokens may do in this workspace, intersected with the integration's roles. Null for an integration that is not a partner's install."
          },
          "createdBy": {
            "type": [
              "string",
              "null"
            ],
            "description": "The member who created the integration; null when that account no longer resolves."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the integration was created, ISO-8601 UTC."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the integration, its roles or its tokens last changed, ISO-8601 UTC."
          }
        }
      },
      "IntegrationPartnerClient": {
        "type": "object",
        "description": "The partner client an integration is an install of.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The partner's OAuth `client_id`."
          },
          "name": {
            "type": "string",
            "description": "The partner's name."
          }
        }
      },
      "IntegrationAccountRole": {
        "type": "object",
        "description": "A role attached to an integration.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The role's id."
          },
          "name": {
            "type": "string",
            "description": "The role's name."
          }
        }
      },
      "CreateIntegrationAccountRequest": {
        "type": "object",
        "description": "Body of `POST /integration-accounts`. The integration starts with no roles and no tokens.",
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "The integration's name, as it should appear on what it writes (\"Invoice scanner\")."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000,
            "description": "What the integration is for."
          },
          "partnerClientId": {
            "type": "string",
            "description": "Install a partner: the partner's OAuth `client_id`, which it publishes. The integration is then the partner's install in this workspace, and the partner mints its tokens with the `client_credentials` grant; the workspace issues none. The client must be one the platform offers for install (404 otherwise), and a workspace holds one install per partner (409 for a second)."
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "For a partner's install only: the most its tokens may do here, narrowed from the partner's own ceiling (400 for a scope outside it). Omitted, the install takes the partner's whole ceiling. Either way its roles still decide what it can do."
          }
        }
      },
      "UpdateIntegrationAccountRequest": {
        "type": "object",
        "description": "Body of `PATCH /integration-accounts/{integrationId}`; only the fields sent change.",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "A new name. What the integration already wrote shows the new name too."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000,
            "description": "A new description; null clears it."
          },
          "disabled": {
            "type": "boolean",
            "description": "True switches the integration off (its tokens stop working at once); false switches it on."
          }
        }
      },
      "AttachIntegrationRoleRequest": {
        "type": "object",
        "description": "Body of `POST /integration-accounts/{integrationId}/roles`. A caller may attach a role they hold themselves; a caller with `permissions:manage` may attach any role whose grants are within their own.",
        "required": [
          "roleId"
        ],
        "additionalProperties": false,
        "properties": {
          "roleId": {
            "type": "string",
            "description": "The role to attach."
          }
        }
      },
      "CreateIntegrationTokenRequest": {
        "type": "object",
        "description": "Body of `POST /integration-accounts/{integrationId}/tokens`. An integration's token always holds exactly the integration's roles; there is no base role to choose.",
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "A label for the token, such as where it is installed."
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the token stops working; null or absent for a token that does not expire."
          }
        }
      },
      "ApiTokenCreated": {
        "description": "Response of `POST /api-tokens`: the new token's metadata together with its full secret value, which is returned only in this response and never again.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ApiToken"
          },
          {
            "type": "object",
            "required": [
              "token"
            ],
            "properties": {
              "token": {
                "type": "string",
                "description": "Full token value — shown once only, store securely"
              }
            }
          }
        ]
      },
      "CreateApiTokenRequest": {
        "description": "Request body of `POST /api-tokens`: the label, optional expiry and base role of a new workspace API token.",
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "description": "Label shown in the token list so its owner can tell tokens apart; whitespace is trimmed and a blank name is refused.",
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "expiresAt": {
            "description": "When the token stops being accepted, ISO-8601 UTC. Omit or send null for a token that never expires.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "baseRole": {
            "$ref": "#/components/schemas/ApiTokenBaseRole"
          }
        }
      },
      "HostedSite": {
        "type": "object",
        "description": "The workspace's hosted site: a frontend its admins build and deploy themselves, served at its own origin to signed-in members of the workspace only (docs/HOSTED_SITES.md). At most one per workspace.",
        "required": [
          "id",
          "url",
          "activeDeploymentId",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "12-char hex site id, unrelated to the workspace id. The site always answers on it as the first label of its hostname, and on every address its workspace holds or held (see `url`). The `-prv` suffix of a hostname label is reserved: a label ending in `-prv` or containing `-prv-` never names a site."
          },
          "url": {
            "type": "string",
            "description": "The site's origin, the one to open and link to: `https://<address>.<hosted-sites domain>` when the workspace has an address (set with `PUT /workspace/address`), otherwise `https://<id>.<hosted-sites domain>`, or `https://<hostname>` while a custom domain is active (`GET /hosted-site/domains`). Every other label the site answers on (its id, an address the workspace held before) redirects here, so a client never needs to store more than this."
          },
          "activeDeploymentId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The deployment the site serves; null until one is activated."
          },
          "createdAt": {
            "description": "When the site was created, ISO-8601 UTC; set by the server. Deployments have their own timestamps.",
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "HostedSiteDomain": {
        "type": "object",
        "description": "A hostname of the workspace's own (`crm.acme.com`) its hosted site answers on, or is being set up to (docs/CUSTOM_DOMAINS.md). The workspace creates one CNAME record, given in `cname`; Tessule then obtains and renews the certificate and, once it is issued, serves the site there and redirects the site's other addresses to it. A hostname stays reserved to the workspace after it is removed, so no other organization can take it over.",
        "required": [
          "id",
          "hostname",
          "status",
          "cname",
          "detail",
          "createdAt",
          "activatedAt",
          "lastCheckedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable identifier of this hostname, used in `DELETE /hosted-site/domains/{domainId}`."
          },
          "hostname": {
            "type": "string",
            "description": "The hostname as stored, lowercase ASCII (unicode labels punycoded); the site's origin is `https://` + this."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownHostedSiteDomainStatus",
            "description": "Where the hostname is in its lifecycle: `pending` until the CNAME resolves and the certificate issues (minutes after the record is created, up to a few hours), `active` while the site is served there, `failed` when the certificate could not be issued or renewed or the CNAME went away for three daily checks (`detail` says which; create the record again and remove and re-add the hostname). Open vocabulary: clients tolerate values not listed in `KnownHostedSiteDomainStatus`."
          },
          "cname": {
            "type": "object",
            "description": "The one DNS record the workspace creates at its DNS provider, verbatim.",
            "required": [
              "name",
              "target"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "The record's name, which is the hostname itself (`crm.acme.com`)."
              },
              "target": {
                "type": "string",
                "description": "The record's value, a Tessule hostname that every custom domain points at (`sites-edge.tessule.dev`)."
              }
            }
          },
          "detail": {
            "type": [
              "string",
              "null"
            ],
            "description": "The last word from the certificate authority or the DNS check, for display beside the status (`validation-timed-out`, `pending-validation`); null when there is nothing to say."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the hostname was added, ISO-8601 UTC."
          },
          "activatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the site first answered on the hostname, ISO-8601 UTC; null until then."
          },
          "lastCheckedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the hostname's certificate and DNS were last inspected, ISO-8601 UTC; null before the first check."
          }
        }
      },
      "HostedSiteDomainRequest": {
        "type": "object",
        "description": "A hostname to attach to the workspace's hosted site.",
        "required": [
          "hostname"
        ],
        "properties": {
          "hostname": {
            "type": "string",
            "description": "The hostname to serve the site on, such as `crm.acme.com`. Case and a trailing dot are ignored; unicode is accepted and stored punycoded. It must be a subdomain the workspace can create a CNAME for (a bare domain such as `acme.com` is refused, as is any name on a Tessule domain), and it must not be in use by another workspace.",
            "maxLength": 253
          }
        }
      },
      "HostedSiteDeployment": {
        "type": "object",
        "description": "One immutable upload of the site's files. Activating a deployment makes the edge serve it within seconds; activating an older one is a rollback. The newest few deployments are kept for that purpose and older ones are removed.",
        "required": [
          "id",
          "status",
          "fileCount",
          "totalBytes",
          "createdAt",
          "activatedAt",
          "uploadedBy",
          "extensions",
          "placementHints",
          "hasSource"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "12-char hex deployment id."
          },
          "hasSource": {
            "type": "boolean",
            "description": "Whether the deployment was sent with the source it was built from, which `GET /hosted-site/deployments/{deploymentId}/files` hands back. False for a deployment whose only copy of its source is the built files."
          },
          "extensions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HostedSiteExtension"
            },
            "description": "The app extensions this deployment declares in `/tessule.site.json`, validated at deploy time; empty when it declares none."
          },
          "placementHints": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HostedSiteExtensionPlacementHint"
            },
            "description": "How to place each declared extension in a record layout, for the deployer to read; empty when there is nothing to suggest."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownHostedSiteDeploymentStatus",
            "description": "Open vocabulary: uploading (files may still be arriving), ready (verified complete, not live), active (the one the site serves). Clients must tolerate a status this build does not know."
          },
          "fileCount": {
            "description": "Number of files in the deployment's manifest.",
            "type": "integer"
          },
          "totalBytes": {
            "description": "Combined size of the deployment's files in bytes, as declared in its manifest.",
            "type": "integer",
            "format": "int64"
          },
          "createdAt": {
            "description": "When the deployment was started (its manifest accepted and uploads begun), ISO-8601 UTC.",
            "type": "string",
            "format": "date-time"
          },
          "activatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When this deployment was last made active; null if never."
          },
          "uploadedBy": {
            "type": [
              "object",
              "null"
            ],
            "description": "Who started the deployment (and so chose its files). Null once that user's account no longer exists.",
            "required": [
              "id",
              "name"
            ],
            "properties": {
              "id": {
                "description": "User id of the person who started the deployment.",
                "type": "string"
              },
              "name": {
                "description": "Display name of the person who started the deployment, for the deployments list.",
                "type": "string"
              }
            }
          }
        }
      },
      "HostedSiteExtensionTarget": {
        "type": "string",
        "description": "Where in the app an extension is shown. `record.block` is a panel on a record page, placed by a record layout block of kind `extension`. `home.tile` is a tile on the home page, placed by a home-page tile of kind `extension`. `dashboard.tile` is a tile on a dashboard, placed by a dashboard tile of kind `extension`. `app.page` is a full page of the app at `/x/<siteId>/<extensionId>/...`, reached by a navigation or quick-link target of kind `extensionPage`. A client skips a target it does not know.",
        "enum": [
          "record.block",
          "home.tile",
          "dashboard.tile",
          "app.page"
        ]
      },
      "ExtensionPlacement": {
        "type": "object",
        "description": "Names the app extension a placement shows: a record layout block, a home-page or dashboard tile, or an `extensionPage` link. The app never trusts `siteId` from a client; the server resolves it against the workspace's own sites and refuses any other.",
        "required": [
          "siteId",
          "extensionId"
        ],
        "properties": {
          "siteId": {
            "type": "string",
            "pattern": "^[0-9a-f]{12}$",
            "description": "Id of the hosted site that declares the extension, as `siteId` of the extension catalog."
          },
          "extensionId": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{0,39}$",
            "description": "Id of the extension within that site, as listed by `GET /hosted-site/extensions`."
          }
        }
      },
      "ExtensionModalSize": {
        "type": "string",
        "enum": [
          "small",
          "medium",
          "large"
        ],
        "description": "How large the modal an `openModal` message asks for is; the app picks the dialog width from it, medium when absent."
      },
      "HostedSiteExtensionHeight": {
        "type": "object",
        "description": "How tall the extension's frame is, in CSS pixels, for `record.block` and the two tile targets (`app.page` fills the page and ignores it). The app opens the frame at `initial`; a `record.block` then follows the extension's `resize` messages within `min` and `max`, while a tile keeps the size its grid gives it and uses `initial` to seed the tile's height.",
        "required": [
          "initial"
        ],
        "properties": {
          "initial": {
            "type": "integer",
            "minimum": 120,
            "maximum": 2000,
            "description": "Height the frame opens at, before the extension has reported its own."
          },
          "min": {
            "type": "integer",
            "minimum": 120,
            "maximum": 2000,
            "description": "Smallest height the frame may take; the platform floor applies when absent."
          },
          "max": {
            "type": "integer",
            "minimum": 120,
            "maximum": 2000,
            "description": "Tallest height the frame may take; the platform ceiling applies when absent."
          }
        }
      },
      "HostedSiteExtension": {
        "type": "object",
        "description": "One route of a hosted site that the app shows inside its own page in an iframe, as declared in the site's `tessule.site.json`. The deployment's active catalog is `GET /hosted-site/extensions`; a record layout places one by site id and `id`.",
        "required": [
          "id",
          "name",
          "target",
          "path",
          "scopes"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{0,39}$",
            "description": "Stable key of the extension within its site. A layout block names the extension by this value, so renaming it unplaces the block."
          },
          "name": {
            "type": "string",
            "maxLength": 60,
            "description": "Title the app shows for the extension, in the layout editor and on the block."
          },
          "description": {
            "type": "string",
            "maxLength": 300,
            "description": "What the extension does, shown to the admin who places it and to the viewer asked for consent."
          },
          "target": {
            "$ref": "#/components/schemas/HostedSiteExtensionTarget"
          },
          "path": {
            "type": "string",
            "pattern": "^/ext/[a-z0-9][a-z0-9-]{0,39}/$",
            "description": "Site path the frame loads, always `/ext/<id>/`. The app never builds the frame address from this; it uses the `frameUrl` of a frame session."
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Permission scopes the extension asks to act with, a subset of what the site may use. The viewer consents to exactly this set before a frame session is issued."
          },
          "height": {
            "$ref": "#/components/schemas/HostedSiteExtensionHeight"
          },
          "tables": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Table ids or names the extension is meant for, `record.block` only. The layout editor offers it only on those tables' record layouts; absent means any table. Ignored on every other target."
          }
        }
      },
      "HostedSiteDeclaration": {
        "type": "object",
        "description": "The shape of `/tessule.site.json`, the file a site's build ships to declare its extensions. Deploying reads it, validates every entry and stores the result with the deployment.",
        "required": [
          "extensions"
        ],
        "properties": {
          "extensions": {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/HostedSiteExtension"
            },
            "description": "The extensions the site offers; empty when it declares none."
          }
        }
      },
      "HostedSiteExtensionCatalog": {
        "type": "object",
        "description": "The extensions the workspace's hosted site offers now, which a layout editor lists and a record page resolves its extension blocks against.",
        "required": [
          "deploymentId",
          "siteId",
          "siteOrigin",
          "extensions"
        ],
        "properties": {
          "siteId": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9a-f]{12}$",
            "description": "Id of the workspace's hosted site, the value to store as `siteId` in a placement of one of these extensions; null when the workspace has no site."
          },
          "deploymentId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Id of the active deployment the catalog was read from; null when the site has none or no site exists."
          },
          "siteOrigin": {
            "type": [
              "string",
              "null"
            ],
            "description": "Origin of the workspace's site as it is advertised (`https://<label>.<hosted-sites domain>`, the origin of `HostedSite.url`); null when the workspace has no site or hosted sites are not configured on this deployment. It is the only origin the app will frame an extension from: a frame session whose `frameUrl` is on any other origin is never mounted."
          },
          "extensions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HostedSiteExtension"
            },
            "description": "The active deployment's extensions; empty when it declares none."
          }
        }
      },
      "HostedSiteExtensionPlacementHint": {
        "type": "object",
        "description": "A line telling the person who deployed how to place an extension where its target goes: a record page layout, the home page, a dashboard or the navigation. A client shows `text` after a deploy, and the app lists it beside the deployment; it changes nothing by itself.",
        "required": [
          "extensionId",
          "text"
        ],
        "properties": {
          "extensionId": {
            "type": "string",
            "description": "The extension the hint is about."
          },
          "text": {
            "type": "string",
            "description": "The hint, as a sentence to show as is."
          },
          "recordUrl": {
            "type": "string",
            "description": "App link to a record page where the extension could be placed, when one exists; offer it as a link."
          }
        }
      },
      "HostedSiteExtensionFrameSession": {
        "type": "object",
        "description": "What the app needs to open one extension frame for the signed-in viewer: load `frameUrl` in an iframe, then hand `frameToken` to the frame in the `init` message. Issued per frame and short lived; request a new one on `reauth` or before `expiresAt`.",
        "required": [
          "frameUrl",
          "frameToken",
          "expiresAt",
          "hostOrigin",
          "extension"
        ],
        "properties": {
          "frameUrl": {
            "type": "string",
            "description": "Address of the extension on the site's origin, carrying a path token; the iframe `src`."
          },
          "frameToken": {
            "type": "string",
            "description": "Credential the frame sends as `Authorization: Tessule-Frame <token>` when it calls the site's API proxy."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the frame session stops working, ISO-8601 UTC; renew before then."
          },
          "hostOrigin": {
            "type": "string",
            "description": "Origin of the app page; the frame posts to it and the app accepts messages only from the frame's origin."
          },
          "extension": {
            "$ref": "#/components/schemas/HostedSiteExtension"
          }
        }
      },
      "HostedSiteExtensionFrameSessionRequest": {
        "type": "object",
        "description": "Optional body of a frame-session request: where inside the extension's own folder the frame opens. The app sends it for a modal frame (`openModal`), so the address is built by the server and never by the browser.",
        "properties": {
          "path": {
            "type": "string",
            "maxLength": 256,
            "pattern": "^[a-z0-9][a-z0-9._/-]*$",
            "description": "File inside the extension's `/ext/<id>/` directory to open, relative to it and without a leading slash (`detail.html`, `edit/42.html`): lowercase letters, digits and `. _ / -`, starting with a letter or digit, at most 256 characters, the same rule an `openModal` path follows. A path outside the pattern or the length is refused by request validation (400); one with a `..` segment, which the pattern allows, is refused with 400 `EXTENSION_PATH_INVALID`. `index.html` when absent. The returned `frameUrl` ends with it."
          }
        }
      },
      "HostedSiteExtensionConsentRequired": {
        "description": "Body of the 403 `EXTENSION_CONSENT_REQUIRED` refusal of a frame-session request: the viewer has not agreed to everything the extension now asks for. Show `newScopes` for consent, post `scopes` to `POST /hosted-site/extensions/{extensionId}/consents`, then retry.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ErrorResponse"
          },
          {
            "type": "object",
            "required": [
              "code",
              "scopes",
              "newScopes"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "EXTENSION_CONSENT_REQUIRED"
                ],
                "description": "Always `EXTENSION_CONSENT_REQUIRED`; a client tells this refusal from any other 403 by it, then shows the consent card for `newScopes`."
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The full scope set the extension declares now; the set to consent to."
              },
              "newScopes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The scopes in `scopes` the viewer has not yet agreed to, for the consent prompt."
              }
            }
          }
        ]
      },
      "HostedSiteExtensionConsentRequest": {
        "type": "object",
        "description": "The scopes a viewer agrees to let an extension act with. Consent is the exact set, so it stops covering the extension when its declared scopes change.",
        "required": [
          "scopes"
        ],
        "properties": {
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The extension's declared scopes as shown to the viewer; a set that differs from them is refused."
          }
        }
      },
      "ExtensionContext": {
        "type": "object",
        "description": "What the app tells a frame about where it is shown and who is looking, sent in `init` and again in a `context` message whenever it changes. The extension reads it; it carries no credential.",
        "required": [
          "target",
          "workspace",
          "viewer"
        ],
        "properties": {
          "target": {
            "$ref": "#/components/schemas/HostedSiteExtensionTarget"
          },
          "workspace": {
            "type": "object",
            "description": "The workspace the page belongs to.",
            "required": [
              "id",
              "name"
            ],
            "properties": {
              "id": {
                "type": "string",
                "description": "Workspace id."
              },
              "name": {
                "type": "string",
                "description": "Workspace display name."
              }
            }
          },
          "viewer": {
            "type": "object",
            "description": "The signed-in person looking at the page.",
            "required": [
              "userId",
              "displayName",
              "locale",
              "timeZone",
              "permissions"
            ],
            "properties": {
              "userId": {
                "type": "string",
                "description": "Id of the viewer."
              },
              "displayName": {
                "type": "string",
                "description": "Name to greet or attribute the viewer by."
              },
              "locale": {
                "type": "string",
                "description": "BCP 47 locale the app renders in; format dates and numbers by it."
              },
              "timeZone": {
                "type": "string",
                "description": "IANA time zone of the viewer."
              },
              "permissions": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Permission scopes the viewer holds, so the extension can hide controls they could not use."
              }
            }
          },
          "record": {
            "type": "object",
            "description": "The record page the extension sits on; absent for a target that is not a record.",
            "required": [
              "tableId",
              "tableName",
              "recordId",
              "updatedAt",
              "fields"
            ],
            "properties": {
              "tableId": {
                "type": "string",
                "description": "Id of the record's table."
              },
              "tableName": {
                "type": "string",
                "description": "Name of the record's table."
              },
              "recordId": {
                "type": "string",
                "description": "Id of the record."
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time",
                "description": "When the record last changed, ISO-8601 UTC; a changed value means the fields were refreshed."
              },
              "fields": {
                "type": "object",
                "additionalProperties": true,
                "description": "The record's data keyed by field name, as the viewer may see it; fields they cannot read are absent. Untyped for the same reason as `Record.data`: its keys are the table's own field names."
              }
            }
          },
          "form": {
            "type": "object",
            "description": "State of the record form around the frame, when the page is editing.",
            "required": [
              "dirty"
            ],
            "properties": {
              "dirty": {
                "type": "boolean",
                "description": "Whether the form holds unsaved changes; avoid replacing field values while true."
              }
            }
          },
          "dashboard": {
            "type": "object",
            "description": "The dashboard a `dashboard.tile` sits on; present when `target` is `dashboard.tile` and absent otherwise.",
            "required": [
              "id",
              "variables"
            ],
            "properties": {
              "id": {
                "type": "string",
                "description": "Id of the dashboard."
              },
              "variables": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                },
                "description": "The dashboard's current variable values keyed by variable name, as text; a variable left on \"All\" is absent. A `context` message follows when the viewer changes one."
              }
            }
          },
          "route": {
            "type": "object",
            "description": "Where the viewer is inside an `app.page` extension; present when `target` is `app.page` and absent otherwise.",
            "required": [
              "path",
              "query"
            ],
            "properties": {
              "path": {
                "type": "string",
                "description": "Path after `/x/<siteId>/<extensionId>`, starting with `/`; `/` for the extension's root."
              },
              "query": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                },
                "description": "The page's query string parameters by name; a repeated name carries its last value."
              }
            }
          }
        }
      },
      "ExtensionTheme": {
        "type": "object",
        "description": "The app's current look, sent in `init` and again in a `theme` message when it changes, so an extension can match it.",
        "required": [
          "mode",
          "tokens"
        ],
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "light",
              "dark"
            ],
            "description": "Whether the app is showing its light or dark theme."
          },
          "tokens": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Design tokens as CSS custom property name to value; apply them as variables on the document root."
          }
        }
      },
      "ExtensionHostInitMessage": {
        "type": "object",
        "description": "App to frame, sent once when the frame announces `ready`; carries everything the extension needs to start.",
        "required": [
          "tessule",
          "type",
          "frameToken",
          "context",
          "theme",
          "hostOrigin"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id, echoed by the reply when one is expected."
          },
          "type": {
            "type": "string",
            "enum": [
              "init"
            ],
            "description": "Message discriminator; always `init`."
          },
          "frameToken": {
            "type": "string",
            "description": "The frame session's token for calls to the site's API proxy."
          },
          "context": {
            "$ref": "#/components/schemas/ExtensionContext"
          },
          "theme": {
            "$ref": "#/components/schemas/ExtensionTheme"
          },
          "hostOrigin": {
            "type": "string",
            "description": "Origin of the app; the frame accepts host messages only from it."
          }
        }
      },
      "ExtensionHostContextMessage": {
        "type": "object",
        "description": "App to frame, sent when the context changes after `init` (the record was saved or refreshed, the form became dirty).",
        "required": [
          "tessule",
          "type",
          "context"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id, echoed by the reply when one is expected."
          },
          "type": {
            "type": "string",
            "enum": [
              "context"
            ],
            "description": "Message discriminator; always `context`."
          },
          "context": {
            "$ref": "#/components/schemas/ExtensionContext"
          }
        }
      },
      "ExtensionHostThemeMessage": {
        "type": "object",
        "description": "App to frame, sent when the app's theme changes after `init`.",
        "required": [
          "tessule",
          "type",
          "theme"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id, echoed by the reply when one is expected."
          },
          "type": {
            "type": "string",
            "enum": [
              "theme"
            ],
            "description": "Message discriminator; always `theme`."
          },
          "theme": {
            "$ref": "#/components/schemas/ExtensionTheme"
          }
        }
      },
      "ExtensionHostResultMessage": {
        "type": "object",
        "description": "App to frame, the answer to a frame message that carried an `id` (such as `setFieldValue`).",
        "required": [
          "tessule",
          "type",
          "id",
          "ok"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "The `id` of the frame message this answers."
          },
          "type": {
            "type": "string",
            "enum": [
              "result"
            ],
            "description": "Message discriminator; always `result`."
          },
          "ok": {
            "type": "boolean",
            "description": "Whether the request was carried out; read `error` when false."
          },
          "value": {
            "description": "What the request produced, when it produces something; shape depends on the request."
          },
          "error": {
            "type": "string",
            "description": "Why the request was refused, for the extension to show or log; present when `ok` is false."
          }
        }
      },
      "ExtensionHostCloseMessage": {
        "type": "object",
        "description": "App to frame, sent just before the app removes the frame, so the extension can stop work and save.",
        "required": [
          "tessule",
          "type",
          "reason"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id, echoed by the reply when one is expected."
          },
          "type": {
            "type": "string",
            "enum": [
              "close"
            ],
            "description": "Message discriminator; always `close`."
          },
          "reason": {
            "type": "string",
            "description": "Why the frame is closing, such as `navigated` or `session-expired`; informational."
          }
        }
      },
      "ExtensionHostMessage": {
        "description": "Any message the app posts to an extension frame. Branch on `type`; ignore a type or a `tessule` version you do not know.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/ExtensionHostInitMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionHostContextMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionHostThemeMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionHostResultMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionHostCloseMessage"
          }
        ],
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "init": "#/components/schemas/ExtensionHostInitMessage",
            "context": "#/components/schemas/ExtensionHostContextMessage",
            "theme": "#/components/schemas/ExtensionHostThemeMessage",
            "result": "#/components/schemas/ExtensionHostResultMessage",
            "close": "#/components/schemas/ExtensionHostCloseMessage"
          }
        }
      },
      "ExtensionFrameReadyMessage": {
        "type": "object",
        "description": "Frame to app, sent once the extension's script is listening; the app answers with `init`.",
        "required": [
          "tessule",
          "type"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id; the app echoes it in a `result` when the message expects one."
          },
          "type": {
            "type": "string",
            "enum": [
              "ready"
            ],
            "description": "Message discriminator; always `ready`."
          }
        }
      },
      "ExtensionFrameResizeMessage": {
        "type": "object",
        "description": "Frame to app, asking the app to set the frame's height to fit its content.",
        "required": [
          "tessule",
          "type",
          "height"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id; the app echoes it in a `result` when the message expects one."
          },
          "type": {
            "type": "string",
            "enum": [
              "resize"
            ],
            "description": "Message discriminator; always `resize`."
          },
          "height": {
            "type": "integer",
            "description": "Wanted height in CSS pixels; the app clamps it to the extension's `min` and `max`."
          }
        }
      },
      "ExtensionFrameToastMessage": {
        "type": "object",
        "description": "Frame to app, asking the app to show a brief notice in its own toast area.",
        "required": [
          "tessule",
          "type",
          "message",
          "severity"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id; the app echoes it in a `result` when the message expects one."
          },
          "type": {
            "type": "string",
            "enum": [
              "toast"
            ],
            "description": "Message discriminator; always `toast`."
          },
          "message": {
            "type": "string",
            "description": "Plain text to show; the app cuts one longer than 300 characters."
          },
          "severity": {
            "type": "string",
            "enum": [
              "info",
              "success",
              "warning",
              "error"
            ],
            "description": "How the notice is styled."
          }
        }
      },
      "ExtensionFrameNavigateMessage": {
        "type": "object",
        "description": "Frame to app, asking the app to go to one of its own destinations. Only in-app targets exist, so a frame cannot send the viewer off-product.",
        "required": [
          "tessule",
          "type",
          "target"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id; the app echoes it in a `result` when the message expects one."
          },
          "type": {
            "type": "string",
            "enum": [
              "navigate"
            ],
            "description": "Message discriminator; always `navigate`."
          },
          "target": {
            "allOf": [
              {
                "$ref": "#/components/schemas/HomepageQuickLinkTarget"
              }
            ],
            "description": "Where to go, as a quick-link target; any `url` is dropped, since the app resolves destinations itself. On this message alone, an `extensionPage` target may omit `extension`: it then names the frame's own extension, and the app fills in its own placement, so a frame moves within its own page (`{ \"kind\": \"extensionPage\", \"path\": \"/detail\" }`) without ever naming its site. Only an `app.page` frame has a page of its own; from any other target such a request is refused. With `extension` the target must be an `app.page` extension of the workspace's own site, as for a stored link. Every other kind carries what it names, as stored."
          }
        }
      },
      "ExtensionFrameRefreshRecordMessage": {
        "type": "object",
        "description": "Frame to app, telling the app the record changed behind its back (the extension wrote through the API); the app reloads it and sends a fresh `context`.",
        "required": [
          "tessule",
          "type"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id; the app echoes it in a `result` when the message expects one."
          },
          "type": {
            "type": "string",
            "enum": [
              "refreshRecord"
            ],
            "description": "Message discriminator; always `refreshRecord`."
          }
        }
      },
      "ExtensionFrameSetFieldValueMessage": {
        "type": "object",
        "description": "Frame to app, asking the app to set one field in the open record form. It changes the form only; the viewer saves it. The app answers with a `result`.",
        "required": [
          "tessule",
          "type",
          "field",
          "value"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id the `result` echoes; send one to learn whether the field was set."
          },
          "type": {
            "type": "string",
            "enum": [
              "setFieldValue"
            ],
            "description": "Message discriminator; always `setFieldValue`."
          },
          "field": {
            "type": "string",
            "description": "Name of the field to set."
          },
          "value": {
            "description": "The new value, in the field type's value contract; the app validates it as the form would."
          }
        }
      },
      "ExtensionFrameOpenModalMessage": {
        "type": "object",
        "description": "Frame to app, asking the app to open a modal frame of the same extension at `path`, with the same context. One modal is open at a time; a second request while one is open is answered with a failed `result`. The app answers this message with a `result` once the modal closes: `value` is what the modal's `closeModal` carried, or absent when the viewer dismissed it.",
        "required": [
          "tessule",
          "type",
          "id",
          "path"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id the closing `result` echoes; required, since the answer arrives when the modal closes."
          },
          "type": {
            "type": "string",
            "enum": [
              "openModal"
            ],
            "description": "Message discriminator; always `openModal`."
          },
          "path": {
            "type": "string",
            "maxLength": 256,
            "pattern": "^[a-z0-9][a-z0-9._/-]*$",
            "description": "Route inside the extension's own `/ext/<id>/` folder to load, without a leading slash (`detail.html`). Lowercase letters, digits and `. _ / -`, with no `..` segment; the app resolves it inside the extension's folder and refuses any other. A route without a file extension serves the extension's `index.html`, whose relative URLs then resolve from the route's folder: below a route of more than one segment that is the wrong folder and its assets do not load, so name an `.html` file or a single segment."
          },
          "title": {
            "type": "string",
            "maxLength": 100,
            "description": "Heading the app shows on the modal's frame; the extension's name when absent."
          },
          "size": {
            "$ref": "#/components/schemas/ExtensionModalSize"
          }
        }
      },
      "ExtensionFrameScanMessage": {
        "type": "object",
        "description": "Frame to app, asking the app to read a barcode or QR code for the extension. The app opens its own scanner (the camera, or a code typed or read by a handheld scanner) and answers with a `result` once the viewer is done: `value` is an `ExtensionScanResult`, or absent when the viewer cancelled. The camera stays the app's: the frame never sees video and needs no camera permission of its own (its frame does not allow one). One scan at a time; a second request while the scanner is open is answered with a failed `result`.",
        "required": [
          "tessule",
          "type",
          "id"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id the `result` echoes; required, since the answer arrives when the viewer is done."
          },
          "type": {
            "type": "string",
            "enum": [
              "scan"
            ],
            "description": "Message discriminator; always `scan`."
          },
          "title": {
            "type": "string",
            "maxLength": 100,
            "description": "What is being scanned, shown as the scanner's heading after \"Scan\" (\"asset tag\" reads \"Scan asset tag\"); \"a code\" when absent."
          }
        }
      },
      "ExtensionScanResult": {
        "type": "object",
        "description": "What the app's scanner read for an extension: the `value` of the `result` answering a `scan`. Text only; look it up with the API as any typed code (`findRecordsByCode` in `@tessule/client/scan`).",
        "required": [
          "code",
          "format"
        ],
        "properties": {
          "code": {
            "type": "string",
            "maxLength": 4000,
            "description": "The code read or typed, as text, trimmed, with control characters removed."
          },
          "format": {
            "type": [
              "string",
              "null"
            ],
            "description": "The symbology the camera read (`qr_code`, `code_128`, `ean_13`, …), or null when the code was typed or came from a handheld scanner."
          }
        }
      },
      "ExtensionFrameCloseModalMessage": {
        "type": "object",
        "description": "Frame to app, sent by the frame running inside a modal to close it. The app closes the modal and answers the opener's `openModal` with a `result` carrying `value`.",
        "required": [
          "tessule",
          "type"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id; the app echoes it in a `result` when the message expects one."
          },
          "type": {
            "type": "string",
            "enum": [
              "closeModal"
            ],
            "description": "Message discriminator; always `closeModal`."
          },
          "value": {
            "description": "Any JSON value to hand back to the opener as the `value` of its `result`; absent for none."
          }
        }
      },
      "ExtensionFrameReauthMessage": {
        "type": "object",
        "description": "Frame to app, sent when the frame token is about to expire or was refused; the app issues a new frame session and sends a fresh `init`.",
        "required": [
          "tessule",
          "type"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id; the app echoes it in a `result` when the message expects one."
          },
          "type": {
            "type": "string",
            "enum": [
              "reauth"
            ],
            "description": "Message discriminator; always `reauth`."
          }
        }
      },
      "ExtensionFrameErrorMessage": {
        "type": "object",
        "description": "Frame to app, reporting that the extension cannot work; the app replaces the frame with a notice carrying `message`.",
        "required": [
          "tessule",
          "type",
          "message"
        ],
        "properties": {
          "tessule": {
            "type": "integer",
            "enum": [
              1
            ],
            "description": "Protocol version; a message with another value is ignored."
          },
          "id": {
            "type": "string",
            "description": "Correlation id; the app echoes it in a `result` when the message expects one."
          },
          "type": {
            "type": "string",
            "enum": [
              "error"
            ],
            "description": "Message discriminator; always `error`."
          },
          "message": {
            "type": "string",
            "description": "What went wrong, in words a viewer can read; shown as plain text, cut to 300 characters."
          }
        }
      },
      "ExtensionFrameMessage": {
        "description": "Any message an extension frame posts to the app. The app accepts one only from the frame's own origin and parses it against this union; anything else is dropped. Branch on `type`.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/ExtensionFrameReadyMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionFrameResizeMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionFrameToastMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionFrameNavigateMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionFrameRefreshRecordMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionFrameSetFieldValueMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionFrameOpenModalMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionFrameCloseModalMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionFrameReauthMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionFrameErrorMessage"
          },
          {
            "$ref": "#/components/schemas/ExtensionFrameScanMessage"
          }
        ],
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "ready": "#/components/schemas/ExtensionFrameReadyMessage",
            "resize": "#/components/schemas/ExtensionFrameResizeMessage",
            "toast": "#/components/schemas/ExtensionFrameToastMessage",
            "navigate": "#/components/schemas/ExtensionFrameNavigateMessage",
            "refreshRecord": "#/components/schemas/ExtensionFrameRefreshRecordMessage",
            "setFieldValue": "#/components/schemas/ExtensionFrameSetFieldValueMessage",
            "openModal": "#/components/schemas/ExtensionFrameOpenModalMessage",
            "closeModal": "#/components/schemas/ExtensionFrameCloseModalMessage",
            "reauth": "#/components/schemas/ExtensionFrameReauthMessage",
            "error": "#/components/schemas/ExtensionFrameErrorMessage",
            "scan": "#/components/schemas/ExtensionFrameScanMessage"
          }
        }
      },
      "HostedSiteFile": {
        "type": "object",
        "description": "One file of a deployment manifest.",
        "required": [
          "path",
          "contentType",
          "size"
        ],
        "properties": {
          "path": {
            "type": "string",
            "maxLength": 512,
            "description": "The URL path the file is served at, starting with \"/\", e.g. \"/index.html\" or \"/assets/app.3f9a.js\". Segments may use letters, digits and . _ ~ @ + - only, and may not be \".\" or \"..\". Any request path whose last segment has no \".\" is served \"/index.html\", which every manifest must include."
          },
          "contentType": {
            "type": "string",
            "maxLength": 255,
            "description": "The Content-Type the file is served with, e.g. \"text/html; charset=utf-8\"."
          },
          "size": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "Exact size in bytes; the upload URL only accepts this length."
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "SHA-256 of the file's bytes, lowercase hex. Declaring it makes the file content-addressed: a file the site already holds under that hash (from an earlier deployment) is linked server-side and needs no upload, and the upload URL of a new one accepts only bytes with that hash. Without it the file is uploaded every time and stored for this deployment only."
          }
        }
      },
      "HostedSiteCachePolicy": {
        "type": "string",
        "enum": [
          "no-cache",
          "immutable"
        ],
        "x-enum-varnames": [
          "NoCache",
          "Immutable"
        ],
        "description": "How browsers may cache a served file. `no-cache`: the browser revalidates on every use (`Cache-Control: public, max-age=0, must-revalidate, s-maxage=31536000`), right for a file whose path keeps its name across deployments, `/index.html` above all. `immutable`: the browser keeps the file for a year without asking (`Cache-Control: public, max-age=31536000, immutable`), right for a file whose name carries a content hash and so changes whenever its bytes do. The edge caches every file for a year under its deployment either way, so a deployment never needs cache-busting."
      },
      "HostedSiteCacheRule": {
        "type": "object",
        "description": "One cache rule of a deployment manifest: the policy for every file whose path matches a glob. Rules are tried in order and the first match wins; a file no rule matches gets the defaults (`/assets/**` and content-hashed filenames `immutable`, everything else `no-cache`).",
        "required": [
          "pattern",
          "policy"
        ],
        "properties": {
          "pattern": {
            "type": "string",
            "maxLength": 256,
            "description": "A glob over the served path, starting with \"/\": `*` matches within one segment, `**` across segments, `?` one character; everything else is literal. `/assets/**` is every file under /assets; `/*.json` the JSON files at the top level."
          },
          "policy": {
            "$ref": "#/components/schemas/HostedSiteCachePolicy"
          }
        }
      },
      "CreateHostedSiteDeploymentRequest": {
        "description": "Manifest of a new hosted-site deployment: every file it will serve, declared up front so the server can hand back a presigned upload for each file it does not already hold. Request body of `POST /hosted-site/deployments`; nothing is served until the deployment is activated.",
        "type": "object",
        "required": [
          "files"
        ],
        "properties": {
          "files": {
            "description": "Every file the deployment serves, at least one; `/index.html` must be among them. The response returns one upload per entry the site does not already hold (by `sha256`), in manifest order.",
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/HostedSiteFile"
            }
          },
          "cache": {
            "description": "Cache rules, tried in order; a file no rule matches gets the defaults (`/assets/**` and content-hashed filenames `immutable`, everything else `no-cache`). Omit it to use the defaults alone.",
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/HostedSiteCacheRule"
            }
          },
          "extensions": {
            "description": "The app extensions the deployment declares, the same list as `/tessule.site.json`. Omit it when the build declares none.",
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/HostedSiteExtension"
            }
          }
        }
      },
      "HostedSiteUpload": {
        "type": "object",
        "description": "Where and how to upload one file of a new deployment.",
        "required": [
          "path",
          "url",
          "headers"
        ],
        "properties": {
          "path": {
            "description": "The URL path of the file this upload is for, exactly as given in the deployment manifest, so the client can match uploads to files.",
            "type": "string"
          },
          "url": {
            "type": "string",
            "description": "A presigned URL; PUT the file's bytes to it."
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Headers the PUT must carry exactly (they are part of the signature): the content type and cache policy the file is served with, `If-None-Match: *` (write-once), and for a content-addressed file `x-amz-checksum-sha256`, which makes storage refuse bytes whose hash is not the declared one."
          }
        }
      },
      "HostedSiteDeploymentCreated": {
        "description": "Response of `POST /hosted-site/deployments`: the new deployment plus one presigned upload per declared file the site does not already hold. Upload every listed file before the URLs expire, then activate the deployment; nothing is served until activation.",
        "allOf": [
          {
            "$ref": "#/components/schemas/HostedSiteDeployment"
          },
          {
            "type": "object",
            "required": [
              "uploads",
              "uploadsExpireAt",
              "reusedFileCount"
            ],
            "properties": {
              "uploads": {
                "description": "One presigned upload per file that still has to be sent, in manifest order: every file declared without a `sha256`, and one per distinct `sha256` the site does not hold yet, keyed by the first path that declares it (two paths with the same content share one upload; the blob is one write-once key, and storage answers a second PUT to it with 412, which means it is already there). PUT each file's bytes to its `url` with exactly its `headers` before `uploadsExpireAt`. A file declared with a `sha256` the site already holds is absent here; activation links it.",
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/HostedSiteUpload"
                }
              },
              "reusedFileCount": {
                "type": "integer",
                "description": "How many declared files the site already held by `sha256`, and so need no upload; `fileCount` minus the length of `uploads`."
              },
              "uploadsExpireAt": {
                "type": "string",
                "format": "date-time",
                "description": "The upload URLs stop working at this time; start a new deployment after it."
              }
            }
          }
        ]
      },
      "HostedSiteArchiveFormat": {
        "type": "string",
        "enum": [
          "zip",
          "tar.gz"
        ],
        "x-enum-varnames": [
          "Zip",
          "TarGz"
        ],
        "description": "The container of an archived build: `zip` (deflate or stored entries) or `tar.gz` (a gzip-compressed ustar/pax tar, as `tar -czf` writes)."
      },
      "DeployHostedSiteArchiveRequest": {
        "type": "object",
        "description": "A whole build in one request: an archive of the built directory, unpacked and validated server-side. Request body of `POST /hosted-site/deployments/archive`. Each file's content type comes from its extension and its cache policy from `cache` and the defaults, as for a declared manifest.",
        "required": [
          "format",
          "archive"
        ],
        "properties": {
          "format": {
            "$ref": "#/components/schemas/HostedSiteArchiveFormat"
          },
          "archive": {
            "type": "string",
            "format": "byte",
            "description": "The archive's bytes, base64-encoded (2.5 MB decoded at most; larger builds deploy through the manifest and upload URLs of `POST /hosted-site/deployments`). The entries are the build's files with their paths under the built directory; one top-level directory wrapping every entry (`dist/`) is stripped. Directory entries, `__MACOSX/` and `.DS_Store` are ignored; a symbolic or hard link, an absolute path, a `..` segment or a path the site could not serve is refused."
          },
          "activate": {
            "type": "boolean",
            "description": "Whether to make the deployment live once its files are stored; omitted means yes. `false` leaves it `ready`, to activate later."
          },
          "cache": {
            "description": "Cache rules, tried in order; a file no rule matches gets the defaults (`/assets/**` and content-hashed filenames `immutable`, everything else `no-cache`).",
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/HostedSiteCacheRule"
            }
          },
          "source": {
            "$ref": "#/components/schemas/HostedSiteSourceArchive"
          }
        }
      },
      "HostedSiteSourceArchive": {
        "type": "object",
        "description": "The source a build was made from (the project before its build step: `src/`, `package.json`, configuration), kept with the deployment and never served. Send it whenever the site has no repository of its own: it is what `GET /hosted-site/deployments/{deploymentId}/files` hands back so the site can be changed and deployed again. The build and its source together are 2.5 MB decoded at most.",
        "required": [
          "format",
          "archive"
        ],
        "properties": {
          "format": {
            "$ref": "#/components/schemas/HostedSiteArchiveFormat"
          },
          "archive": {
            "type": "string",
            "format": "byte",
            "description": "The source archive's bytes, base64-encoded. Its entries are checked as a build's are (no link, absolute path or `..` segment, the same size limits) but may be any relative path, dotfiles included; one top-level directory is kept as it is."
          }
        }
      },
      "HostedSiteDeploymentFile": {
        "type": "object",
        "description": "One file a deployment serves, as read back from it.",
        "required": [
          "path",
          "contentType",
          "size",
          "url"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "The served path, starting with `/` (`/index.html`)."
          },
          "contentType": {
            "type": "string",
            "description": "The `Content-Type` the file is served with."
          },
          "size": {
            "type": "integer",
            "format": "int64",
            "description": "The file's size in bytes."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "A download URL for the file's bytes, valid until `urlsExpireAt`; it needs no credentials, so do not share it."
          }
        }
      },
      "HostedSiteDeploymentFiles": {
        "type": "object",
        "description": "A deployment read back: its files, its build as a zip when that fits in one answer, and the source it was deployed with when its deployer sent one. Response of `GET /hosted-site/deployments/{deploymentId}/files`.",
        "required": [
          "deploymentId",
          "status",
          "files",
          "urlsExpireAt",
          "archive",
          "source"
        ],
        "properties": {
          "deploymentId": {
            "type": "string",
            "description": "The deployment read."
          },
          "status": {
            "type": "string",
            "x-known-values": "KnownHostedSiteDeploymentStatus",
            "description": "The deployment's status (`ready` or `active`; open vocabulary, as on `HostedSiteDeployment`)."
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HostedSiteDeploymentFile"
            },
            "description": "Every file the deployment serves, in its manifest's order."
          },
          "urlsExpireAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the files' download URLs stop working; read the deployment again for fresh ones."
          },
          "archive": {
            "type": [
              "string",
              "null"
            ],
            "format": "byte",
            "description": "The whole build as one zip, base64-encoded, with each file at its served path (`index.html`, `assets/…`): an archive `POST /hosted-site/deployments/archive` deploys as it is. Null when the build and its source together are over 2.5 MB; fetch the files from their URLs instead."
          },
          "source": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/HostedSiteSourceArchive"
              },
              {
                "type": "null"
              }
            ],
            "description": "The source archive the deployment was made with, exactly as it was sent; null when its deployer sent none."
          }
        }
      },
      "PublishedPageAudience": {
        "type": "string",
        "enum": [
          "workspace",
          "user"
        ],
        "description": "Who can open a published page. `workspace`: every member of the workspace who holds `pages:read`. `user`: only the member who published it (a draft), who alone sees it in the catalog."
      },
      "PublishedPagePerson": {
        "type": "object",
        "description": "A member named on a page or a version.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "description": "User id of the member, matching `WorkspaceMember.userId`.",
            "type": "string"
          },
          "name": {
            "description": "The member's display name at the time of the read, for showing beside the page or version.",
            "type": "string"
          }
        }
      },
      "PublishedPageCurrentVersion": {
        "type": "object",
        "description": "The version a page's link serves.",
        "required": [
          "id",
          "number",
          "byteSize"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "12-char hex version id."
          },
          "number": {
            "type": "integer",
            "description": "1 for the first version of the page, then 2, 3, …"
          },
          "byteSize": {
            "description": "Size of the version's HTML in bytes, so a client can show it without downloading the page.",
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "PublishedPage": {
        "type": "object",
        "description": "A single static HTML page a member published to the workspace, usually from an AI session (docs/PUBLISHED_PAGES.md). Its content never holds a credential: it is served from a separate domain, only through a short-lived signed URL, into a sandboxed frame.",
        "required": [
          "id",
          "title",
          "description",
          "audience",
          "url",
          "publishedBy",
          "createdAt",
          "updatedAt",
          "currentVersion",
          "versionCount",
          "canManage"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "12-char hex page id."
          },
          "title": {
            "description": "The page's display title, as shown in the catalog and the page chrome; searchable through the list endpoint's text filter.",
            "type": "string"
          },
          "description": {
            "type": "string",
            "description": "What the page shows and where its data came from."
          },
          "audience": {
            "$ref": "#/components/schemas/PublishedPageAudience"
          },
          "url": {
            "type": "string",
            "description": "The page's shareable link, in the app. Opening it needs a sign-in as a member in the page's audience; it is not a capability."
          },
          "publishedBy": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PublishedPagePerson"
              },
              {
                "type": "null"
              }
            ],
            "description": "Who published the page. Null once that account no longer exists."
          },
          "createdAt": {
            "description": "When the page was first published, ISO-8601 UTC; set by the server. Later versions move `updatedAt`, not this.",
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the page's content or details last changed."
          },
          "currentVersion": {
            "$ref": "#/components/schemas/PublishedPageCurrentVersion"
          },
          "versionCount": {
            "description": "How many versions the page has, including the current one. Each new publish to `/published-pages/{pageId}/versions` adds one; any of them can be made current again.",
            "type": "integer"
          },
          "canManage": {
            "type": "boolean",
            "description": "Whether the caller may change, roll back or delete this page: they published it, or they hold `pages:manage`."
          }
        }
      },
      "PublishedPageView": {
        "description": "Response of `GET /published-pages/{pageId}`: the page's details plus a short-lived signed URL for the current version's HTML, for a caller in the page's audience.",
        "allOf": [
          {
            "$ref": "#/components/schemas/PublishedPage"
          },
          {
            "type": "object",
            "required": [
              "contentUrl",
              "contentUrlExpiresAt"
            ],
            "properties": {
              "contentUrl": {
                "type": "string",
                "description": "A signed URL for the current version's HTML, on the pages content host. Load it only into a sandboxed iframe without allow-same-origin. It stops working at contentUrlExpiresAt; ask for the page again for a fresh one."
              },
              "contentUrlExpiresAt": {
                "description": "When `contentUrl` stops working, ISO-8601 UTC. Request the page again for a fresh URL rather than caching one past this instant.",
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "PublishedPageCatalog": {
        "type": "object",
        "description": "The pages the caller can open, most recently updated first.",
        "required": [
          "enabled",
          "pages"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Whether the organization has published pages switched on. When false, nothing can be published or opened, and `pages` is empty."
          },
          "pages": {
            "description": "Every page the caller may open, most recently updated first; empty when `enabled` is false.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublishedPage"
            }
          }
        }
      },
      "PublishedPageVersion": {
        "type": "object",
        "description": "One immutable version of a page's HTML.",
        "required": [
          "id",
          "number",
          "byteSize",
          "createdAt",
          "publishedBy",
          "current"
        ],
        "properties": {
          "id": {
            "description": "Server-assigned identifier of this version, distinct from the page's id; what the version endpoints take.",
            "type": "string"
          },
          "number": {
            "description": "Ordinal of the version within its page, starting at 1 and increasing by one with each publish; never reused.",
            "type": "integer"
          },
          "byteSize": {
            "description": "Size of this version's HTML in bytes, as stored.",
            "type": "integer",
            "format": "int64"
          },
          "createdAt": {
            "description": "When this version was published, ISO-8601 UTC. Versions are immutable, so this never changes.",
            "type": "string",
            "format": "date-time"
          },
          "publishedBy": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PublishedPagePerson"
              },
              {
                "type": "null"
              }
            ],
            "description": "Who published this version. Null once that account no longer exists."
          },
          "current": {
            "type": "boolean",
            "description": "Whether this is the version the page's link serves."
          }
        }
      },
      "CreatePublishedPageRequest": {
        "description": "Request body of `POST /published-pages`: a self-contained HTML page to publish under the workspace, with the title, description and audience the catalog shows for it.",
        "type": "object",
        "required": [
          "title",
          "description",
          "html"
        ],
        "properties": {
          "title": {
            "description": "Short title shown in the published-pages catalog and as the page's heading.",
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "description": "One or two sentences on what the page shows and where its data came from."
          },
          "audience": {
            "$ref": "#/components/schemas/PublishedPageAudience"
          },
          "html": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000000,
            "description": "The whole page as one self-contained HTML document. The workspace's limits cap its size; see docs/PUBLISHED_PAGES.md for what a page may load and do."
          }
        }
      },
      "UpdatePublishedPageRequest": {
        "type": "object",
        "description": "The details to change; one or more.",
        "minProperties": 1,
        "properties": {
          "title": {
            "description": "New title of the published page (1–120 characters).",
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "description": "New description shown with the page (1–500 characters).",
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "audience": {
            "$ref": "#/components/schemas/PublishedPageAudience"
          }
        }
      },
      "CreatePublishedPageVersionRequest": {
        "description": "Request body of `POST /published-pages/{pageId}/versions`: a new HTML version of a published page, which becomes the page's current version on success.",
        "type": "object",
        "required": [
          "html"
        ],
        "properties": {
          "html": {
            "description": "The whole page as one self-contained HTML document; it becomes the current version and is served as published. Its size counts against the workspace's published-page limits (see docs/PUBLISHED_PAGES.md for what a page may load and do).",
            "type": "string",
            "minLength": 1,
            "maxLength": 4000000
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "Replaces the page's title, if given."
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "description": "Replaces the page's description, if given."
          }
        }
      },
      "OAuthCallbackRedirect": {
        "type": "object",
        "required": [
          "redirect_to"
        ],
        "description": "Where the browser must go next to hand the authorization code to the OAuth client. Returned instead of a 302 when the consent screen calls the callback with `response_mode=json`, because a cross-origin Location header is not readable from JavaScript.",
        "properties": {
          "redirect_to": {
            "type": "string",
            "description": "The client's registered redirect_uri, carrying code and state."
          }
        }
      },
      "PermissionCategory": {
        "description": "The kind of work a workspace action enables, which is how actions are presented to people: `data` (records, their attachments and discussion), `analytics` (queries, charts, dashboards, views, published pages), `processes` (flows, approvals), `schema` (tables and fields) and `administration` (members, groups, roles, tokens, secrets, integrations, quotas, hosted sites, branding). A consent screen groups the requested scopes under these headings; what is granted is always the individual actions.",
        "type": "string",
        "enum": [
          "data",
          "analytics",
          "processes",
          "schema",
          "administration"
        ]
      },
      "OAuthAuthorizeInfo": {
        "description": "Response of `GET /oauth/authorize/info`: everything the consent screen needs to render a pending OAuth authorization — the requesting application, the scopes and their meanings, token lifetimes and the workspaces the user may grant access to.",
        "type": "object",
        "required": [
          "client",
          "scopes",
          "tokenLifetime",
          "workspaces"
        ],
        "properties": {
          "client": {
            "description": "The application asking for access, as the consent screen should name it.",
            "type": "object",
            "required": [
              "name",
              "id",
              "redirectHost"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "Display name of the requesting application. A dynamically registered client chooses its own name, so the consent screen shows it beside `redirectHost`, which the application cannot choose."
              },
              "id": {
                "type": "string",
                "description": "OAuth client_id"
              },
              "redirectHost": {
                "type": "string",
                "description": "Host the authorization code is sent to on approval (the request's redirect_uri, checked against the client's registered callbacks), e.g. `claude.ai` or `localhost`. The consent screen names it so the user can see where access goes."
              },
              "identityHost": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Host that publishes the client's metadata document when its client_id is a metadata document URL (OAuth Client ID Metadata Documents), e.g. `claude.ai`. Only that host can say which callbacks the client uses, so the consent screen names it as the party vouching for the client. Null for a registered client."
              }
            }
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "OAuth scopes the application requested, narrowed to what this server issues. The consent screen offers each as an option, all selected by default; the user's selection goes back as the `scope` parameter of `GET /oauth/callback`."
          },
          "scopeDetails": {
            "type": "array",
            "description": "Human-readable meaning of each requested scope, sourced from the server's scope catalog so the consent screen never invents capabilities. Same order as `scopes`.",
            "items": {
              "type": "object",
              "required": [
                "scope",
                "category",
                "label",
                "description"
              ],
              "properties": {
                "scope": {
                  "description": "The scope string, matching an entry of `scopes`. A scope is a workspace action under its own name (`records:read`, `flows:update`), the same string a role grants.",
                  "type": "string"
                },
                "category": {
                  "$ref": "#/components/schemas/PermissionCategory"
                },
                "label": {
                  "description": "Short human-readable name of the scope for the consent checklist; the consent screen shows it under its category's heading.",
                  "type": "string"
                },
                "description": {
                  "description": "One-sentence explanation of what the scope lets the application do, from the server's action catalog.",
                  "type": "string"
                }
              }
            }
          },
          "tokenLifetime": {
            "description": "How long the tokens issued on consent stay valid, in seconds, so the consent screen can say so.",
            "type": "object",
            "required": [
              "accessTokenSeconds",
              "refreshTokenSeconds"
            ],
            "properties": {
              "accessTokenSeconds": {
                "type": "integer",
                "description": "Access token lifetime in seconds"
              },
              "refreshTokenSeconds": {
                "type": "integer",
                "description": "Refresh token lifetime in seconds"
              }
            }
          },
          "hintedWorkspaceId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Workspace ID hinted by the client in the authorize request"
          },
          "workspaceLocked": {
            "type": "boolean",
            "description": "True when the client's RFC 8707 resource indicator named a workspace-scoped MCP URL (/mcp/{workspaceId}). The consent screen must show hintedWorkspaceId read-only; the server refuses to issue the grant for any other workspace."
          },
          "hostedSite": {
            "type": "object",
            "description": "Present only when the requesting client is a hosted site's own sign-in (docs/HOSTED_SITES.md). The consent screen then names the site and the workspace whose admins built it, instead of treating it as an external application. The workspace is always hintedWorkspaceId, and is locked.",
            "required": [
              "url",
              "workspaceName",
              "rememberedScopes"
            ],
            "properties": {
              "url": {
                "type": "string",
                "description": "The site's origin, e.g. https://<siteId>.tessule.dev."
              },
              "workspaceName": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Name of the workspace the site belongs to. Null when the signed-in user is not an active member of it, in which case the grant will be refused and the name is not disclosed."
              },
              "rememberedScopes": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "string"
                },
                "description": "The scopes this member approved for this site at a recent sign-in, narrowed to the ones requested now. When present the consent screen approves exactly these again without asking (signing in again after a session ends is then one redirect). Null when the member has not approved this site recently, has signed out of it since, or is not a member of its workspace."
              }
            }
          },
          "workspaces": {
            "type": "array",
            "description": "Workspaces the authenticated user is a member of",
            "items": {
              "type": "object",
              "required": [
                "id",
                "name",
                "role"
              ],
              "properties": {
                "id": {
                  "description": "Id of a workspace the user may grant the application access to; the chosen one goes back as the workspace of the grant.",
                  "type": "string"
                },
                "name": {
                  "description": "Display name of the workspace for the picker.",
                  "type": "string"
                },
                "role": {
                  "description": "The user's own role in that workspace; the application can never get more than the user has.",
                  "type": "string"
                },
                "agents": {
                  "type": "array",
                  "description": "The user's live agents in that workspace, which the consent screen offers as who the application acts as: the user themselves, or one agent, whose id goes back as the `agent_id` parameter of `GET /oauth/callback`. An agent's token holds the agent's roles, not the user's, still narrowed by the consented scopes.",
                  "items": {
                    "$ref": "#/components/schemas/AgentSummary"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/health/ready": {
      "get": {
        "operationId": "healthReadyGet",
        "summary": "Readiness probe",
        "description": "Runs `SELECT 1` against the control-plane database and every workspace database shard this instance is configured for, each with a short timeout, and answers 200 when all succeed or 503 when any fails. The result is cached in-process for about ten seconds, so a status page polling from several regions cannot amplify into database load. Unauthenticated and tenant-free. Unlike `/health` (which only proves the process is running), this fails during a database outage — it is what the status page's API component probes.",
        "tags": [
          "Health"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Every database check passed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthReadiness"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "At least one database check failed or timed out.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthReadiness"
                }
              }
            }
          }
        }
      }
    },
    "/openapi/v1/openapi.json": {
      "get": {
        "operationId": "openapiV1JsonGet",
        "summary": "Get the platform OpenAPI specification (JSON)",
        "description": "The OpenAPI 3.1 document of the platform API, as JSON: every operation the API serves, identical for every workspace, with `servers` naming the base URL of the host that answered. Public and cacheable (no credential, `Cache-Control: public`), so a build, a linter or a client generator can fetch it by URL. It describes no workspace's tables: a document that does is `GET /workspace/openapi`, read with the workspace's own credential. The same document as YAML is `GET /openapi/v1/openapi.yaml`.",
        "tags": [
          "Specification"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "The platform OpenAPI document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "An OpenAPI 3.1 document (`openapi`, `info`, `servers`, `paths`, `components`).",
                  "additionalProperties": true
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/openapi/v1/openapi.yaml": {
      "get": {
        "operationId": "openapiV1YamlGet",
        "summary": "Get the platform OpenAPI specification (YAML)",
        "description": "The same document as `GET /openapi/v1/openapi.json`, serialised as YAML (`application/yaml`), for tools that read the specification in that form. Public and cacheable.",
        "tags": [
          "Specification"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "The platform OpenAPI document as YAML text.",
            "content": {
              "application/yaml": {
                "schema": {
                  "type": "string",
                  "description": "The OpenAPI 3.1 document, as a YAML text."
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/register": {
      "post": {
        "operationId": "authRegisterPost",
        "summary": "Register a new user",
        "description": "Creates the identity and application user profile only — no organization or workspace is provisioned. The response is a workspace-less session; creating an organization and its first workspace is the deliberate onboarding step (POST /organizations, then POST /organizations/{organizationId}/workspaces), unless the user was domain-auto-joined or accepts an invitation instead.\nWhile sign-ups are restricted to the early-access allowlist, an address that is not on it still gets its account — credentials included — but held pending: the response is 403 EARLY_ACCESS_PENDING with no session, and the person is emailed to sign in once an operator admits the account.",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "User registered successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid registration data; or refused before any work with code CAPTCHA_REQUIRED (no valid verification token) or DISPOSABLE_EMAIL (throwaway-mailbox provider)\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignupRefusalResponse"
                }
              }
            }
          },
          "403": {
            "description": "The account was created but is awaiting early access (code EARLY_ACCESS_PENDING): sign-ups are restricted to the allowlist and this address is not on it, so no session is issued until an operator admits the account. The same status also carries code SSO_REQUIRED when the address's domain mandates single sign-on (nothing is created then).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EarlyAccessPendingResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Challenge verification is temporarily unavailable (Cloudflare unreachable, or the server's Turnstile secret is misconfigured). The request was not processed; the client should ask the user to try again shortly.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationUnavailableResponse"
                }
              }
            }
          }
        }
      }
    },
    "/auth/login": {
      "post": {
        "operationId": "authLoginPost",
        "summary": "Login user",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "User logged in successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Invalid credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Credentials are valid but a session cannot be issued yet: the account is flagged must-change-password (code PASSWORD_CHANGE_REQUIRED, with a passwordChangeToken for /auth/set-password); a second factor is required (code MFA_CHALLENGE, with a challengeToken for /auth/mfa/verify); an organization the user belongs to requires MFA enrollment (code MFA_REQUIRED, with the session refreshToken so the client can enroll); the account is awaiting early access (code EARLY_ACCESS_PENDING, no token of any kind); or the user has no active workspace membership.\n",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/PasswordChangeRequiredResponse"
                    },
                    {
                      "$ref": "#/components/schemas/MfaChallengeResponse"
                    },
                    {
                      "$ref": "#/components/schemas/MfaRequiredResponse"
                    },
                    {
                      "$ref": "#/components/schemas/EarlyAccessPendingResponse"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/set-password": {
      "post": {
        "operationId": "authSetPasswordPost",
        "summary": "Set a new password after a one-time-password login",
        "description": "Completes an admin-initiated password reset. Exchanges the short-lived passwordChangeToken returned by login (when the account held a one-time password) plus the user's chosen new password for a normal authenticated session, clearing the must-change-password flag.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetPasswordRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Password updated; user logged in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Invalid or expired password change token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/me": {
      "get": {
        "operationId": "authMeGet",
        "summary": "Get current user profile",
        "tags": [
          "Authentication"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current user profile with workspaces",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/refresh": {
      "post": {
        "operationId": "authRefreshPost",
        "summary": "Refresh access token",
        "description": "Exchange a refresh token for a new access token scoped to the requested\nworkspace. The refresh token is identity-only — pass any workspace the\nuser is a member of. Passing a different workspaceId than the current\naccess token effectively switches workspace context, so no separate\nswitch-workspace endpoint is needed.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefreshTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token refreshed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Invalid or expired refresh token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Membership revoked or workspace access denied; the workspace's organization requires MFA (code MFA_REQUIRED) and this session does not satisfy it — enroll via /auth/mfa/enroll, or sign in with a passkey; or the account is awaiting early access (code EARLY_ACCESS_PENDING) and the session is ended.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/logout": {
      "post": {
        "operationId": "authLogoutPost",
        "summary": "Log out (revoke the session)",
        "description": "Revokes the session identified by the supplied refresh token. Public and idempotent — logout must succeed even with an expired access token, and the refresh (session) token is itself the credential.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LogoutRequest"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Session revoked (or already invalid)"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/password": {
      "put": {
        "operationId": "authPasswordPut",
        "summary": "Change the current user's password",
        "description": "Changes the authenticated user's password. Requires the current password. Every session is revoked, this one included, and a new one is started with the new password. Without two-factor authentication the response is that new session (200), so this device stays signed in. With it, the password is still changed but the new session owes its second factor: the response is 403 MFA_CHALLENGE with a challengeToken for /auth/mfa/verify.\n",
        "tags": [
          "Authentication"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangePasswordRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Password changed; fresh session issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "400": {
            "description": "Current password incorrect or new password invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Either the password WAS changed but the new session is not yet complete — a second factor is owed (code MFA_CHALLENGE, with a challengeToken for /auth/mfa/verify), or an organization the user belongs to requires MFA enrollment (code MFA_REQUIRED, with the session refreshToken so the client can enroll) — or the change was refused, e.g. from an impersonated session (ErrorResponse).\n",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/MfaChallengeResponse"
                    },
                    {
                      "$ref": "#/components/schemas/MfaRequiredResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/password-reset/request": {
      "post": {
        "operationId": "authPasswordResetRequestPost",
        "summary": "Request a password-reset email",
        "description": "Sends a password-reset link to the given email if an account exists. Always responds 202 with an identical body regardless of whether the account exists, so it cannot be used to enumerate registered emails.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PasswordResetRequestRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Request accepted (a reset email is sent only if the account exists)"
          },
          "400": {
            "description": "Refused before any lookup with code CAPTCHA_REQUIRED (no valid verification token). Independent of whether an account exists.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignupRefusalResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Challenge verification is temporarily unavailable (Cloudflare unreachable, or the server's Turnstile secret is misconfigured). The request was not processed; the client should ask the user to try again shortly.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationUnavailableResponse"
                }
              }
            }
          }
        }
      }
    },
    "/auth/password-reset/confirm": {
      "post": {
        "operationId": "authPasswordResetConfirmPost",
        "summary": "Complete a password reset",
        "description": "Consumes the single-use token from the reset email, validates the new password against the policy, sets it, and revokes the user's other sessions. The user then logs in fresh — no session is returned here.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PasswordResetConfirmRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Password reset; the user may now sign in with the new password",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OkResponse"
                }
              }
            }
          },
          "400": {
            "description": "Token invalid/expired, or the new password fails the policy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/email-verification/request": {
      "post": {
        "operationId": "authEmailVerificationRequestPost",
        "summary": "Send an email-verification link to the current user",
        "description": "Sends a verification link to the authenticated user's own email address. Always responds 202.\n",
        "tags": [
          "Authentication"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Verification email requested"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/email-verification/confirm": {
      "post": {
        "operationId": "authEmailVerificationConfirmPost",
        "summary": "Confirm an email address",
        "description": "Consumes the single-use token from the verification email and marks the address verified. Public because the link may be opened while logged out.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailVerificationConfirmRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Email verified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OkResponse"
                }
              }
            }
          },
          "400": {
            "description": "Token invalid or expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/social/providers": {
      "get": {
        "operationId": "authSocialProvidersGet",
        "summary": "List configured social sign-in providers",
        "description": "Returns the social providers the server is configured for, so the SPA renders only buttons it can complete. Public.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Configured social providers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SocialProvidersResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/social/{provider}/start": {
      "get": {
        "operationId": "authSocialProviderStartGet",
        "summary": "Begin a social sign-in (redirect to the provider)",
        "description": "Initiates the OAuth flow for the given provider server-side and 302s the browser to the identity provider, setting the OAuth state/PKCE cookie. Public — this is a top-level browser navigation. On error it redirects to the SPA callback with an error fragment.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "google",
                "github",
                "microsoft",
                "apple"
              ]
            }
          },
          {
            "name": "workspace",
            "in": "query",
            "required": false,
            "description": "The workspace origin the sign-in started on — a workspace id or address (the label of `https://<label>.app.tessule.com`). The flow returns there instead of to the app origin. Must be shaped like a workspace label; anything else returns to the app origin.",
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the identity provider (or to the SPA callback on error)"
          }
        }
      }
    },
    "/auth/social/complete": {
      "get": {
        "operationId": "authSocialCompleteGet",
        "summary": "Social sign-in completion (internal callback target)",
        "description": "The target better-auth redirects to after the provider callback (same API origin, so the session cookie is present). Mints a one-time code and 302s to the SPA callback with a code (or error) fragment. Public.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "parameters": [
          {
            "name": "error",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workspace",
            "in": "query",
            "required": false,
            "description": "The workspace origin the sign-in started on — a workspace id or address (the label of `https://<label>.app.tessule.com`). The flow returns there instead of to the app origin. Must be shaped like a workspace label; anything else returns to the app origin.",
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the SPA callback with a code or error fragment"
          }
        }
      }
    },
    "/auth/token": {
      "post": {
        "operationId": "authTokenPost",
        "summary": "Exchange a one-time social-login code for a session",
        "description": "Consumes the single-use code delivered to the SPA callback fragment after a social sign-in and returns the normal AuthResponse. Public — the code is the credential and is valid at most once.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SocialTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Session issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Blocked by organization security policy (MFA required); the account is flagged must-change-password by an admin recovery reset (code PASSWORD_CHANGE_REQUIRED); or the account is awaiting early access (code EARLY_ACCESS_PENDING — a first-time social sign-up whose address is not on the allowlist is created and held, like a password one). In the latter two cases the exchanged session is dropped; for a password change NO passwordChangeToken is issued — a linked social/SSO account proves nothing about the admin's new one-time password, and the caller signs in again at /auth/login.\n",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/PasswordChangeRequiredRefusal"
                    },
                    {
                      "$ref": "#/components/schemas/EarlyAccessPendingResponse"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/impersonation/token": {
      "post": {
        "operationId": "authImpersonationTokenPost",
        "summary": "Exchange a one-time impersonation code for an assumed session",
        "description": "Consumes the single-use code an administrator was handed when they assumed this user's identity, and returns an AuthResponse whose access token carries the target user's own permissions — never elevated ones. No refresh token is issued: the session is short-lived and cannot be renewed. Public, like /auth/token — the code is the credential and is valid at most once. Returns 404 when platform impersonation is disabled, so a deployment with the feature off does not advertise it.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImpersonationTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Assumed session issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Platform impersonation is disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/identities": {
      "get": {
        "operationId": "authIdentitiesGet",
        "summary": "List the caller's linked social accounts",
        "tags": [
          "Authentication"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Linked social accounts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkedAccountsResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/identities/{provider}": {
      "delete": {
        "operationId": "authIdentitiesProviderDelete",
        "summary": "Unlink a social account from the caller",
        "description": "Removes the link between the caller and the given provider. Refused with 400 if it would leave the account with no way to sign in (no password and no other linked provider).\n",
        "tags": [
          "Authentication"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "google",
                "github",
                "microsoft",
                "apple"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account unlinked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OkResponse"
                }
              }
            }
          },
          "400": {
            "description": "Unknown provider, or (code LAST_LOGIN_METHOD) unlinking would remove the only sign-in method — the account has no password, no other linked provider and no passkey",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No linked account for that provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/methods": {
      "post": {
        "operationId": "authMethodsPost",
        "summary": "Discover the sign-in methods available for an email address",
        "description": "Returns which login methods apply to the given email, computed ONLY from its domain's verified policy and server configuration — never from user existence, so the response cannot be used for account enumeration. Drives the email-first login flow. Public.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Available login methods",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoginMethods"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/sso/{connectionId}/start": {
      "get": {
        "operationId": "authSsoConnectionIdStartGet",
        "summary": "Begin an org SSO sign-in (redirect to the identity provider)",
        "description": "Initiates the OIDC flow for the given SSO connection server-side and 302s the browser to the organization's identity provider, setting the OAuth state cookie. Public — a top-level browser navigation. On any problem (unknown/disabled connection, SSO not configured) it redirects to the SPA callback with an error fragment. Completion reuses the same one-time-code handoff as social sign-in (/auth/social/complete → /auth/token).\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workspace",
            "in": "query",
            "required": false,
            "description": "The workspace origin the sign-in started on — a workspace id or address (the label of `https://<label>.app.tessule.com`). The flow returns there instead of to the app origin. Must be shaped like a workspace label; anything else returns to the app origin.",
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the identity provider (or to the SPA callback on error)"
          }
        }
      }
    },
    "/auth/mfa/verify": {
      "post": {
        "operationId": "authMfaVerifyPost",
        "summary": "Complete a two-factor sign-in challenge",
        "description": "Exchanges a pending sign-in challenge (from a login that answered MFA_CHALLENGE) plus a valid code for a full session. Accepts an authenticator (TOTP) code, an emailed one-time code, or a backup recovery code.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MfaVerifyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Challenge completed; user logged in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Invalid code or invalid/expired challenge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "403": {
            "description": "The second factor was correct, but the account is flagged must-change-password by an admin recovery reset (code PASSWORD_CHANGE_REQUIRED). The challenge's session is dropped and NO passwordChangeToken is issued: this challenge proves the pre-reset password, not the admin's new one-time password. The caller signs in again at /auth/login, which mints that token only after verifying the current credential.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PasswordChangeRequiredRefusal"
                }
              }
            }
          },
          "429": {
            "description": "Too many failed attempts; account temporarily locked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/mfa/challenge/send-otp": {
      "post": {
        "operationId": "authMfaChallengeSendOtpPost",
        "summary": "Email a one-time code for a pending sign-in challenge",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MfaChallengeSendOtpRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Code sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OkResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Invalid or expired challenge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "429": {
            "description": "Too many attempts, or verification is locked out for a while.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/mfa/status": {
      "post": {
        "operationId": "authMfaStatusPost",
        "summary": "Get the caller's MFA enrollment status",
        "description": "Returns whether a second factor is enrolled plus the caller's registered passkeys. Authenticated by the identity session token in the body (POST rather than GET so the credential never appears in a URL).\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SessionTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Current MFA enrollment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaStatusResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Invalid or expired session token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/mfa/enroll": {
      "post": {
        "operationId": "authMfaEnrollPost",
        "summary": "Begin two-factor enrollment",
        "description": "Generates (or regenerates) the TOTP secret and backup codes for the session's user. Requires the account password, or for an account without one a sign-in within the last ten minutes (else 401 REAUTH_REQUIRED). Enrollment is pending until a code is verified via /auth/mfa/enroll/confirm — either a TOTP code from an authenticator app, or an emailed code requested via /auth/mfa/enroll/send-otp.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MfaEnrollBeginRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Enrollment started; show the QR and backup codes once",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaEnrollBeginResponse"
                }
              }
            }
          },
          "400": {
            "description": "Incorrect password",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired session token, or (code REAUTH_REQUIRED) an account without a password whose sign-in is more than ten minutes old — sign in again and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "429": {
            "description": "Too many attempts, or verification is locked out for a while.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/mfa/enroll/send-otp": {
      "post": {
        "operationId": "authMfaEnrollSendOtpPost",
        "summary": "Email a one-time code to confirm enrollment",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SessionTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Code sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OkResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Invalid or expired session token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "429": {
            "description": "Too many attempts, or verification is locked out for a while.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/mfa/enroll/confirm": {
      "post": {
        "operationId": "authMfaEnrollConfirmPost",
        "summary": "Confirm two-factor enrollment with a code",
        "description": "Proves possession of a factor and enables MFA for the account. The confirming session is rotated and every other session is revoked, so the client MUST replace its stored refresh token with the returned one.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MfaEnrollConfirmRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MFA enabled; adopt the returned session token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaSessionResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Invalid code or invalid/expired session token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "429": {
            "description": "Too many attempts, or verification is locked out for a while.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/mfa/disable": {
      "post": {
        "operationId": "authMfaDisablePost",
        "summary": "Disable two-factor authentication",
        "description": "Turns the second factor off for the account (password required). The session may be rotated; the client MUST adopt the returned refresh token.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MfaDisableRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MFA disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaSessionResponse"
                }
              }
            }
          },
          "400": {
            "description": "Incorrect password",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired session token, or (code REAUTH_REQUIRED) an account without a password whose sign-in is more than ten minutes old — sign in again and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "429": {
            "description": "Too many attempts, or verification is locked out for a while.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/mfa/backup-codes": {
      "post": {
        "operationId": "authMfaBackupCodesPost",
        "summary": "Regenerate backup codes",
        "description": "Generates a fresh set of recovery codes (password required), invalidating the previous set. Shown once.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MfaBackupCodesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "New backup codes (shown once)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaBackupCodesResponse"
                }
              }
            }
          },
          "400": {
            "description": "Incorrect password",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired session token, or (code REAUTH_REQUIRED) an account without a password whose sign-in is more than ten minutes old — sign in again and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "429": {
            "description": "Too many attempts, or verification is locked out for a while.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/passkeys/register/options": {
      "post": {
        "operationId": "authPasskeysRegisterOptionsPost",
        "summary": "Begin passkey registration (WebAuthn create ceremony)",
        "description": "Starts the WebAuthn create ceremony. Requires the account password in addition to the session token — matching MFA enrollment — so a stolen session alone cannot register a durable login credential.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PasskeyRegisterOptionsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "WebAuthn creation options plus challenge state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebAuthnOptionsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Incorrect password",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired session token, or (code REAUTH_REQUIRED) an account without a password whose sign-in is more than ten minutes old — sign in again and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/passkeys/register/verify": {
      "post": {
        "operationId": "authPasskeysRegisterVerifyPost",
        "summary": "Complete passkey registration",
        "description": "Stores the attested credential. Re-checks the account password so the options→verify window cannot be completed with only a stolen session.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PasskeyRegisterVerifyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Passkey registered",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PasskeySummary"
                }
              }
            }
          },
          "400": {
            "description": "Incorrect password, or attestation could not be verified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired session token or challenge, or (code REAUTH_REQUIRED) an account without a password whose sign-in is more than ten minutes old — sign in again and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/passkeys/delete": {
      "post": {
        "operationId": "authPasskeysDeletePost",
        "summary": "Delete a registered passkey",
        "description": "Removes one of the caller's passkeys. POST (not DELETE) because the session token credential travels in the body, like /auth/logout. Requires the account password (same step-up as registration). The account's last way to sign in is never removed: a passkey on an account with no password and no linked provider can be deleted only once another passkey remains.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PasskeyDeleteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Passkey deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OkResponse"
                }
              }
            }
          },
          "400": {
            "description": "Incorrect password, or (code LAST_LOGIN_METHOD) this passkey is the account's only way to sign in — set a password or link a provider first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired session token, or (code REAUTH_REQUIRED) an account without a password whose sign-in is more than ten minutes old — sign in again and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such passkey for this user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/account/delete": {
      "post": {
        "operationId": "authAccountDeletePost",
        "summary": "Delete your own account",
        "description": "Permanently deletes the caller's account. The sign-in account and every way into it go at once: password, social and SSO links, sessions, passkeys, the second factor, API tokens and OAuth grants, push subscriptions and per-user preferences, pending invitations to the account's address, and every organization and workspace membership. Records, comments and history the person wrote inside workspaces stay with those workspaces, which belong to their organizations; they are attributed to the email address the person had when they left.\n\nPOST (not DELETE) because the session token credential travels in the body, like `/auth/logout`. Requires the same step-up as changing a sign-in factor — the password, or for an account without one a sign-in within the last ten minutes — and the account's email address typed again as confirmation.\n\nRefused with 409 `SOLE_OWNER` while the caller is the only owner of an organization that has other members or a current subscription: transfer ownership or have that organization deleted first. An organization the caller owns alone, with no other members and no current subscription, is scheduled for erasure 35 days later instead; the response lists those.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountDeleteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountDeletionResponse"
                }
              }
            }
          },
          "400": {
            "description": "Incorrect password (code `INVALID_PASSWORD`), or the confirmation does not match the account's email address (code `CONFIRMATION_MISMATCH`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired session token, or (code REAUTH_REQUIRED) an account without a password whose sign-in is more than ten minutes old — sign in again and retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaError"
                }
              }
            }
          },
          "409": {
            "description": "The caller is the only owner of an organization that has other members or a current subscription (code `SOLE_OWNER`); the body names each one and why",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountDeletionBlockedResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "An organization the deletion would schedule for erasure has a workspace in the middle of maintenance (code `BUSY`); nothing was deleted — retry shortly",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/auth/passkeys/signin/options": {
      "post": {
        "operationId": "authPasskeysSigninOptionsPost",
        "summary": "Begin a passkey sign-in (WebAuthn get ceremony)",
        "description": "Returns WebAuthn request options for discoverable-credential sign-in plus opaque challenge state to replay on verify. Public; reveals nothing about any account.\n",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "WebAuthn request options plus challenge state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebAuthnOptionsResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/auth/passkeys/signin/verify": {
      "post": {
        "operationId": "authPasskeysSigninVerifyPost",
        "summary": "Complete a passkey sign-in",
        "tags": [
          "Authentication"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PasskeySignInVerifyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signed in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Assertion could not be verified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Blocked by organization security policy (MFA required), or the account is flagged must-change-password by an admin recovery reset (code PASSWORD_CHANGE_REQUIRED). In the latter case the session is dropped and NO passwordChangeToken is issued — possession of a registered authenticator proves nothing about the admin's new one-time password. The caller signs in again at /auth/login.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PasswordChangeRequiredRefusal"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspaces/{workspaceId}/members": {
      "get": {
        "operationId": "workspacesWorkspaceIdMembersGet",
        "x-policy": "workspaceMembers.read",
        "summary": "List workspace members",
        "description": "Returns all members of the workspace (optionally including inactive ones). Readable by a member of this workspace holding workspace:members:read, or by an owner/admin of the organization that owns it (org:workspaces:manage) — the org control plane administers its workspaces without holding membership in them.\n",
        "tags": [
          "Workspaces"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeInactive",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Include deactivated members in the list"
          }
        ],
        "responses": {
          "200": {
            "description": "List of workspace members",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkspaceMember"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "workspacesWorkspaceIdMembersPost",
        "x-policy": "workspaceMembers.add",
        "summary": "Grant an organization member access to the workspace",
        "description": "Grant an existing active organization member access to this workspace with a workspace role. Authorized by workspace:members:manage OR org:workspaces:manage for the workspace's organization (named policy workspaceMembers.add). The target must already be an active member of the workspace's organization.",
        "tags": [
          "Workspaces"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddWorkspaceMemberRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Member granted access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceMember"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Workspace not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "User is not an active org member, or already a workspace member",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspaces/{workspaceId}/members/{userId}": {
      "patch": {
        "operationId": "workspacesWorkspaceIdMembersUserIdPatch",
        "x-policy": "workspaceMembers.modify",
        "summary": "Update member role",
        "description": "Change a member's workspace role. Requires workspace:members:manage in this workspace, or org:workspaces:manage on the organization that owns it. A workspace admin cannot change another admin's role, and cannot demote the workspace's last active admin; an org owner/admin may do both, since the org axis is the recovery path.\n",
        "tags": [
          "Workspaces"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMemberRoleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Role updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceMember"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions or cannot change owner role",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Member not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "workspacesWorkspaceIdMembersUserIdDelete",
        "x-policy": "workspaceMembers.modify",
        "summary": "Deactivate member (soft delete)",
        "description": "Soft-removes a member from the workspace and revokes their API tokens for it. Requires workspace:members:manage in this workspace, or org:workspaces:manage on the organization that owns it. A workspace admin cannot remove another admin, nor the last active admin; an org owner/admin may do both.\n",
        "tags": [
          "Workspaces"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Member deactivated"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions or cannot remove owner",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Member not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspaces/{workspaceId}/members/{userId}/reactivate": {
      "post": {
        "operationId": "workspacesWorkspaceIdMembersUserIdReactivatePost",
        "x-policy": "workspaceMembers.modify",
        "summary": "Reactivate a deactivated member",
        "description": "Re-enables a previously deactivated member. Requires workspace:members:manage in this workspace, or org:workspaces:manage on the organization that owns it. The user must still be an active member of the workspace's organization.\n",
        "tags": [
          "Workspaces"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Member reactivated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceMember"
                }
              }
            }
          },
          "400": {
            "description": "Member is already active",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Member not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations": {
      "get": {
        "operationId": "organizationsGet",
        "summary": "List organizations visible to the current user",
        "description": "Organizations where the user is an active member (with role) plus organizations owning a workspace the user belongs to (role null).",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of organizations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrganizationSummary"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "organizationsPost",
        "summary": "Create an organization",
        "description": "The creator becomes the organization owner.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOrganizationRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Organization created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}": {
      "get": {
        "operationId": "organizationsOrganizationIdGet",
        "x-org-permission": "org:read",
        "summary": "Get an organization",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Organization details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "organizationsOrganizationIdPatch",
        "x-org-permission": "org:settings:manage",
        "summary": "Update an organization",
        "description": "Rename the organization. Requires org owner or admin.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateOrganizationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Organization updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "organizationsOrganizationIdDelete",
        "x-org-permission": "org:delete",
        "summary": "Delete an organization",
        "description": "Requires org owner. Fails with 409 while the organization still owns workspaces, and with 409 and code `ORGANIZATION_HAS_PUBLISHED_PARTS` when it has published a schema part to the library: published parts are never deleted, so such an organization is erased (and kept as a tombstone) rather than deleted.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Organization deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Organization still owns workspaces, or has published schema parts (code `ORGANIZATION_HAS_PUBLISHED_PARTS`) and must be erased instead",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/features": {
      "get": {
        "operationId": "organizationsOrganizationIdFeaturesGet",
        "x-org-permission": "org:read",
        "summary": "Get organization feature toggles",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The organization's feature toggles",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationFeatures"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "organizationsOrganizationIdFeaturesPut",
        "x-org-permission": "org:settings:manage",
        "summary": "Update organization feature toggles",
        "description": "Self-serve feature opt-in for the organization. Requires org owner or admin. Only the feature toggles in the request schema can be changed — operator-managed limits are not reachable from this endpoint.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateOrganizationFeaturesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Feature toggles updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationFeatures"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/security": {
      "get": {
        "operationId": "organizationsOrganizationIdSecurityGet",
        "x-org-permission": "org:read",
        "summary": "Get organization security policy",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The organization's security policy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationSecurity"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "organizationsOrganizationIdSecurityPut",
        "x-org-permission": "org:settings:manage",
        "summary": "Update organization security policy",
        "description": "Requires org owner or admin. Enabling require-MFA additionally requires the caller AND every active organization owner to be MFA-capable already (a verified second factor or a registered passkey) — the policy must never lock the organization's controllers out.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateOrganizationSecurityRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Security policy updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationSecurity"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Precondition failed — the caller or one or more active owners are not MFA-capable yet.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationSecurityBlockedResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/limit-policies": {
      "get": {
        "operationId": "organizationsOrganizationIdLimitPoliciesGet",
        "x-org-permission": "org:read",
        "summary": "Get the organization's quota maxima",
        "description": "The maxima this organization sets for its own workspaces (T2 of the limit ladder), alongside the entitlement ceiling above them. These are limits on limits: they bound what a workspace admin may configure and never count traffic themselves. Organization usage is the sum of its workspaces' counters — there is no counter above the workspace.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The organization's quota maxima per measure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationLimitPolicies"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "organizationsOrganizationIdLimitPoliciesPut",
        "x-org-permission": "org:limits:manage",
        "summary": "Set the organization's quota maxima",
        "description": "Sets the most any one workspace may hold as a total, and the most any single resource may be configured to, for one measure. Values are themselves clamped by the organization's entitlement and the global hard cap, so this endpoint can only ever tighten. Sending null for a field clears that maximum, falling back to the entitlement above it.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateOrganizationLimitPolicyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Maxima updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationLimitPolicies"
                }
              }
            }
          },
          "400": {
            "description": "Invalid measure or value",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/notifications": {
      "get": {
        "operationId": "notificationsGet",
        "x-permission": "notifications:read",
        "summary": "List the notifications visible to the calling user",
        "description": "Conditions first, then events, newest first. Conditions are states that are true until they aren't, so they are the useful thing to read at the top; events are history.\n\nScoped to the caller's current workspace plus their organization's org-scoped notifications. An organization admin who is not a member of an affected workspace is still in the audience for email, but the in-product list stays inside the tenancy boundary the token establishes.\n",
        "tags": [
          "Notifications"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "all"
              ],
              "default": "open"
            },
            "description": "`open` returns unresolved notifications (open and acknowledged) — the centre's default. `all` includes resolved ones, for \"what happened recently\".\n"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The caller's visible notifications",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/notifications/summary": {
      "get": {
        "operationId": "notificationsSummaryGet",
        "x-permission": "notifications:read",
        "summary": "Badge count and banner state",
        "description": "The one request the app shell makes: the badge count plus any open critical conditions that should render as a banner. Cheap enough to poll and to refresh on a NotificationRaised frame.\n",
        "tags": [
          "Notifications"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Badge and banner state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationSummary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/notifications/read": {
      "post": {
        "operationId": "notificationsReadPost",
        "x-permission": "notifications:read",
        "summary": "Mark every visible notification as read",
        "description": "Per-user read state only. Never changes a condition's status: marking read does not assert the underlying fact has gone away, and a still-open condition keeps its banner.\n",
        "tags": [
          "Notifications"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "Read state updated"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/notifications/{notificationId}/read": {
      "post": {
        "operationId": "notificationsNotificationIdReadPost",
        "x-permission": "notifications:read",
        "summary": "Mark one notification as read",
        "tags": [
          "Notifications"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "notificationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Read state updated"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found, or the caller is not in its audience",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/notifications/{notificationId}/acknowledge": {
      "post": {
        "operationId": "notificationsNotificationIdAcknowledgePost",
        "x-permission": "notifications:read",
        "summary": "Acknowledge a condition (shared — drops the banner for everyone)",
        "description": "Acknowledgement is deliberately SHARED rather than per-user: one admin acknowledging drops the banner to the badge for the whole audience, instead of five admins each dismissing the same true fact.\n\nAcknowledging does NOT resolve the condition and does NOT change what anyone can do — the underlying restriction is enforced by the subsystem that owns it, and this only stops the app shouting about it. Events have nothing to acknowledge; read state is their whole lifecycle.\n",
        "tags": [
          "Notifications"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "notificationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The acknowledged notification",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Notification"
                }
              }
            }
          },
          "400": {
            "description": "Not a condition, or already resolved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found, or the caller is not in its audience",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/notifications/{notificationId}/dismiss": {
      "post": {
        "operationId": "notificationsNotificationIdDismissPost",
        "x-permission": "notifications:read",
        "summary": "Dismiss one notification for the calling user",
        "description": "Per-user: the notification leaves the caller's list and badge and nobody else's. Dismissing also marks it read. Idempotent — dismissing an already-dismissed notification answers 204 again.\n\nOnly a notification that can no longer change can be dismissed: an event, or a resolved condition (the `dismissible` flag on the notification says which). An open or acknowledged condition is still true, so it is refused with 400; it leaves the list by itself once the server resolves it. A condition that becomes true again is a new notification, so a dismissal never hides a fresh fact.\n",
        "tags": [
          "Notifications"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "notificationId",
            "in": "path",
            "required": true,
            "description": "Id of the notification to dismiss.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Dismissed for the calling user"
          },
          "400": {
            "description": "A condition that is still open or acknowledged, which cannot be dismissed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found, or the caller is not in its audience",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/notifications/dismiss-read": {
      "post": {
        "operationId": "notificationsDismissReadPost",
        "x-permission": "notifications:read",
        "summary": "Dismiss every read notification the caller can dismiss",
        "description": "The centre's \"Clear read\": dismisses, for the calling user only, every visible notification they have already read and that is dismissible (an event, or a resolved condition). Unread notifications and conditions that are still true are left alone. Other users are unaffected.\n",
        "tags": [
          "Notifications"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "Read, dismissible notifications dismissed for the calling user"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/limits/usage": {
      "get": {
        "operationId": "workspaceLimitsUsageGet",
        "x-permission": "limits:manage",
        "x-rate-limit-exempt": true,
        "summary": "Current quota usage for this workspace",
        "description": "Per row: the measure, the scope, current count against the effective ceiling, WHICH TIER set that ceiling, and when the window resets.\n\nShowing the tier is the point of the page: it turns \"why did my webhook stop?\" from a support ticket into a self-serve answer, and it is information no generic notification centre can carry.\n",
        "tags": [
          "Limits"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Usage and effective ceilings for every counted resource",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceLimitUsage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/intakes": {
      "get": {
        "operationId": "intakesGet",
        "x-permission": "tables:read",
        "summary": "List intakes",
        "description": "The workspace's intakes, each with its draft and the number of its published version. An intake turns an external document into records.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The intakes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "intakesPost",
        "x-permission": "intakes:manage",
        "summary": "Create an intake",
        "description": "Creates an intake and its first draft. The draft is checked for structure only; it is checked against the workspace's tables when published.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateIntakeRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created, with its draft.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Intake"
                }
              }
            }
          },
          "400": {
            "description": "The definition is not well formed; `issues` names each problem.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeIssuesError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "An intake with this name exists (`INTAKE_NAME_TAKEN`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/intakes/{intakeName}": {
      "get": {
        "operationId": "intakesIntakeNameGet",
        "x-permission": "tables:read",
        "summary": "Read an intake",
        "description": "One intake, with its draft and the number of its published version.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "intakeName",
            "in": "path",
            "required": true,
            "description": "The intake's API name.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The intake.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Intake"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No intake with this name in the workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "intakesIntakeNameDelete",
        "x-permission": "intakes:manage",
        "summary": "Delete an intake",
        "description": "Deletes the intake and every version of it. Records it made are not touched.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "intakeName",
            "in": "path",
            "required": true,
            "description": "The intake's API name.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No intake with this name in the workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/intakes/{intakeName}/draft": {
      "put": {
        "operationId": "intakesIntakeNameDraftPut",
        "x-permission": "intakes:manage",
        "summary": "Save the draft",
        "description": "Replaces the draft's definition, under the draft's `updatedAt`. Deliveries keep running the published version until the draft is published.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "intakeName",
            "in": "path",
            "required": true,
            "description": "The intake's API name.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveIntakeDraftRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Intake"
                }
              }
            }
          },
          "400": {
            "description": "The definition is not well formed; `issues` names each problem.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeIssuesError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No intake with this name in the workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The draft changed since it was read (`STALE_RECORD`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/intakes/{intakeName}/publish": {
      "post": {
        "operationId": "intakesIntakeNamePublishPost",
        "x-permission": "intakes:manage",
        "summary": "Publish the draft",
        "description": "Checks the draft against the workspace's tables, fields and metadata tables, then freezes it as the next published version and starts a new draft from it. A refused draft publishes nothing, and `issues` names each problem.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "intakeName",
            "in": "path",
            "required": true,
            "description": "The intake's API name.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published; the intake carries its new published version and draft.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Intake"
                }
              }
            }
          },
          "400": {
            "description": "The draft cannot be published; `issues` names each problem.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeIssuesError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No intake with this name in the workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The draft kept changing while it was being checked (`INTAKE_DRAFT_BUSY`). Nothing was published; publish again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/intakes/{intakeName}/suggestions": {
      "get": {
        "operationId": "intakesIntakeNameSuggestionsGet",
        "x-permission": "intakes:manage",
        "summary": "List the intake's suggested correction rules",
        "description": "The rules the platform suggests from reviewers' corrections to the records this intake made, open ones first, each with the corrections that are its evidence. Evidence on a record the caller cannot read is counted in `recordCount` but not listed.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "intakeName",
            "in": "path",
            "required": true,
            "description": "The intake's API name.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The suggestions.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeRuleSuggestionList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No intake (or suggestion) with this name in the workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/intakes/{intakeName}/suggestions/refresh": {
      "post": {
        "operationId": "intakesIntakeNameSuggestionsRefreshPost",
        "x-permission": "intakes:manage",
        "summary": "Look for new suggested rules now",
        "description": "Runs the suggestion job for this intake now, over the window its published version's `learning` sets, instead of waiting for the daily run. An intake whose published version has no `learning` block is not studied, and the answer says so.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "intakeName",
            "in": "path",
            "required": true,
            "description": "The intake's API name.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What the run found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeRuleSuggestionRefresh"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No intake (or suggestion) with this name in the workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/intakes/{intakeName}/suggestions/{suggestionId}/accept": {
      "post": {
        "operationId": "intakesIntakeNameSuggestionsSuggestionIdAcceptPost",
        "x-permission": "intakes:manage",
        "summary": "Add a suggested rule to the draft",
        "description": "Appends the suggestion's rule to the intake's draft and marks the suggestion accepted. Nothing changes on deliveries until the draft is published.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "intakeName",
            "in": "path",
            "required": true,
            "description": "The intake's API name.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          },
          {
            "name": "suggestionId",
            "in": "path",
            "required": true,
            "description": "The suggestion's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The rule is in the draft.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeRuleSuggestionAccepted"
                }
              }
            }
          },
          "400": {
            "description": "The draft with the rule added would not be a valid definition; `issues` names each problem.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeIssuesError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No intake (or suggestion) with this name in the workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The suggestion is no longer open (`SUGGESTION_DECIDED`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/intakes/{intakeName}/suggestions/{suggestionId}/dismiss": {
      "post": {
        "operationId": "intakesIntakeNameSuggestionsSuggestionIdDismissPost",
        "x-permission": "intakes:manage",
        "summary": "Dismiss a suggested rule",
        "description": "Marks the suggestion dismissed. The same suggestion is not made again until its evidence grows by `minCorrections` more records.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "intakeName",
            "in": "path",
            "required": true,
            "description": "The intake's API name.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          },
          {
            "name": "suggestionId",
            "in": "path",
            "required": true,
            "description": "The suggestion's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Dismissed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeRuleSuggestion"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No intake (or suggestion) with this name in the workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The suggestion is no longer open (`SUGGESTION_DECIDED`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/intakes/{intakeName}/versions": {
      "get": {
        "operationId": "intakesIntakeNameVersionsGet",
        "x-permission": "tables:read",
        "summary": "List an intake's versions",
        "description": "Every version of the intake, newest first: the draft, the published version and the archived ones.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "intakeName",
            "in": "path",
            "required": true,
            "description": "The intake's API name.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The versions.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeVersionList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No intake with this name in the workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/intakes/{intakeName}/versions/{version}": {
      "get": {
        "operationId": "intakesIntakeNameVersionsVersionGet",
        "x-permission": "tables:read",
        "summary": "Read one version of an intake",
        "description": "One version of the intake, by its number.",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "intakeName",
            "in": "path",
            "required": true,
            "description": "The intake's API name.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,62}$"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "description": "The version's number.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The version.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeVersion"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No intake with this name, or no such version.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/intakes/{intakeName}/deliveries": {
      "post": {
        "operationId": "intakesIntakeNameDeliveriesPost",
        "x-permission": "records:read",
        "summary": "Deliver a document to an intake",
        "description": "Turns one document into records with the intake's published version:\nthe document is checked, its values selected and converted, its\nreferences looked up, and every record, file and evidence row written\nin one record-graph write. Either all of it is kept or none of it.\n\n**Runs as its caller.** A delivery grants nothing: each record needs\nthe caller's `records:create` on its table, each evidence row the\ncaller's grant on its metadata table, and each staged file must be\none the caller staged. A caller who can write no record is refused\nup front.\n\n**What could not be mapped is reported, not refused.** A value that\ndoes not convert to its field's type is left empty (`blanked`), and a\nreference that matches no single record the caller can read is left\nempty (`unresolved`); in both cases the evidence row keeps the text\nthat was read. A record's own rule, such as a required field left\nempty, still refuses the delivery, naming the operation.\n\n**Retrying.** Send an `Idempotency-Key`: a retry with the same key and\nbody answers the first result with `replayed: true` and writes\nnothing, for 24 hours.\n",
        "tags": [
          "Intakes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "intakeName",
            "in": "path",
            "required": true,
            "description": "The intake's name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key the client chooses for this delivery, so a retry after a timeout does not write twice. Reusing it with a different body is refused with `IDEMPOTENCY_KEY_REUSED`.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntakeDeliveryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The records were written (or, for `dryRun`, would be), or this is the stored answer to an earlier delivery with the same key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeDeliveryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Nothing was written. The document is not one the intake accepts (`DOCUMENT_INVALID`, each problem at its JSON pointer), the request gives the document both staged and inline or neither (`DOCUMENT_SOURCE`), `draft` was sent without `dryRun` (`DRAFT_NEEDS_DRY_RUN`), or a record was refused (the record-graph write's error, naming the operation).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/IntakeDocumentError"
                    },
                    {
                      "$ref": "#/components/schemas/RecordGraphError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller may not write records at all, or a record, field, file or evidence row needs a permission the caller lacks. Nothing was written.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordGraphError"
                }
              }
            }
          },
          "404": {
            "description": "There is no intake with this name.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Nothing was written. The intake has no published version (`INTAKE_NOT_PUBLISHED`), its definition no longer fits the workspace's tables (`INTAKE_DEFINITION_STALE`, with the issues), the first delivery with this key is still running (`IDEMPOTENCY_KEY_IN_FLIGHT`), or the record-graph write's own conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/IntakeIssuesError"
                    },
                    {
                      "$ref": "#/components/schemas/RecordGraphError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "The `Idempotency-Key` was used for a different request in the last 24 hours.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows": {
      "get": {
        "operationId": "flowsGet",
        "x-permission": "flows:read",
        "summary": "List flows",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Every flow in the workspace (meta + version summaries)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "flowsPost",
        "x-permission": "flows:create",
        "summary": "Create a flow with its initial draft document",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateFlowRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created flow with its draft document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowDetail"
                }
              }
            }
          },
          "400": {
            "description": "Hard structural document errors (teaching issues) or the workspace flow limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "The `apiName` in the request is one another flow already has. A flow whose `name` another flow has is refused the same way.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{flowId}": {
      "get": {
        "operationId": "flowsFlowIdGet",
        "x-permission": "flows:read",
        "summary": "Get a flow (meta + draft document + published pointer)",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The flow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowDetail"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "flowsFlowIdPatch",
        "x-permission": "flows:update",
        "summary": "Update flow metadata (name, description, enabled, runAsMode)",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateFlowRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated flow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flow"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "flowsFlowIdDelete",
        "x-permission": "flows:delete",
        "summary": "Delete a flow (runs cascade; run history goes with it)",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{flowId}/draft": {
      "put": {
        "operationId": "flowsFlowIdDraftPut",
        "x-permission": "flows:update",
        "summary": "Autosave the draft document",
        "description": "Saves with warnings — the response carries teaching issues for the builder to render. Only hard structural errors (unparseable document, duplicate block ids, depth/size floors) refuse the save with a 400.",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveFlowDraftRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved; issues are advisory",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowDraftSaveResult"
                }
              }
            }
          },
          "400": {
            "description": "Hard structural errors (teaching issues); nothing saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{flowId}/publish": {
      "post": {
        "operationId": "flowsFlowIdPublishPost",
        "x-permission": "flows:update",
        "summary": "Publish the draft as a new immutable version",
        "description": "Strict validation (errors block publish), then the draft becomes published version n+1, a fresh draft copy is seeded, and trigger registration (schedule horizon, inbound token hash) syncs to the published trigger. Publishing an inbound_webhook flow with no token mints one, returned exactly once in this response.",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishFlowResult"
                }
              }
            }
          },
          "400": {
            "description": "Validation errors (teaching issues); nothing published",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{flowId}/versions": {
      "get": {
        "operationId": "flowsFlowIdVersionsGet",
        "x-permission": "flows:read",
        "summary": "List a flow's versions",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Version summaries, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowVersionList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{flowId}/versions/{version}": {
      "get": {
        "operationId": "flowsFlowIdVersionsVersionGet",
        "x-permission": "flows:read",
        "summary": "Get one version's document",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The version with its document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowVersionDetail"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow or version in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{flowId}/test-runs": {
      "post": {
        "operationId": "flowsFlowIdTestRunsPost",
        "x-permission": "flows:execute",
        "summary": "Enqueue a test run of the DRAFT document",
        "description": "Real, labeled side effects. The run executes under the CALLER's permission snapshot regardless of runAsMode — a tester can never borrow the automation identity's access — and pins a frozen copy of the draft, so nothing is published. For record_event flows the sample record is loaded under the caller's row visibility.",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FlowTestRunRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Enqueued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowTestRunResult"
                }
              }
            }
          },
          "400": {
            "description": "Draft invalid, or the trigger kind needs a sample this request did not carry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow (or sample record) in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{flowId}/sample-records": {
      "get": {
        "operationId": "flowsFlowIdSampleRecordsGet",
        "x-permission": "records:read",
        "summary": "Records to test a record-event flow against",
        "description": "The picker behind the test panel: the trigger table's records, most recently updated first, so choosing a sample never means knowing an id. `q` narrows as-you-type by label (every whitespace-separated term must appear as an accent-folded, case-insensitive substring).\n\nThe table is the flow's own DRAFT trigger table — the builder tests the draft — and results honour the caller's row scope and field masking, the same visibility the test run itself loads the sample under. Labels come from the record layout's title field, falling back to the first readable text field and then the record id, so they read as the app titles them.",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search text; empty behaves as absent.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum records to return (default 25).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching records, most recently updated first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowSampleRecordList"
                }
              }
            }
          },
          "400": {
            "description": "The flow's trigger takes no sample record, or a parameter is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow in this workspace, or its trigger table is gone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{flowId}/record-runs": {
      "post": {
        "operationId": "flowsFlowIdRecordRunsPost",
        "x-permission": "flows:execute",
        "summary": "Run a record-action flow on one record",
        "description": "The manual \"run on this record\" button: enqueues one REAL run of the PUBLISHED version with the named record as the trigger record. Only flows whose published trigger is `record_action` accept it, only while enabled, and the record is loaded under the caller's row visibility — you cannot run a flow on a record you cannot see. The caller initiates; runAsMode decides whose permissions the run resolves. The workspace's daily execution limit admits or drops it exactly like an event firing.",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "description": "The flow's id, or its API name (`apiName`), which stays the same when the flow is renamed and in a copy of the workspace.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FlowRecordRunRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Enqueued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowTestRunResult"
                }
              }
            }
          },
          "400": {
            "description": "The flow is not a record-action flow, is disabled, has no published version, or the daily execution limit is reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow (or record) in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{flowId}/blocks/test": {
      "post": {
        "operationId": "flowsFlowIdBlocksTestPost",
        "x-permission": "flows:execute",
        "summary": "Synchronously dry-run one pure/read-only block",
        "description": "Executes code, condition, find_records or run_query under the CALLER's snapshot and returns the output (a run_query draws on the query allowance as a run from the query page would). Effectful kinds (record writes, email, HTTP) are refused with a teaching error — use a test run for those.",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FlowBlockTestRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The dry-run outcome (ok false carries the teaching error)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowBlockTestResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{flowId}/runs": {
      "get": {
        "operationId": "flowsFlowIdRunsGet",
        "x-permission": "flows:read",
        "summary": "List a flow's runs (paged, newest first)",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The runs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowRunList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{flowId}/stats": {
      "get": {
        "operationId": "flowsFlowIdStatsGet",
        "x-permission": "flows:read",
        "summary": "Daily outcome counts for the health view",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Window length in days (default 30, max 90)"
          }
        ],
        "responses": {
          "200": {
            "description": "Per-day outcome counts, oldest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowStats"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such flow in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/runs": {
      "get": {
        "operationId": "flowsRunsGet",
        "x-permission": "flows:read",
        "summary": "Workspace-wide run activity feed",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "flowId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tableId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "itemId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching runs, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowRunList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/runs/{runId}": {
      "get": {
        "operationId": "flowsRunsRunIdGet",
        "x-permission": "flows:read",
        "summary": "Run detail",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "runId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The run",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowRun"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such run in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/runs/{runId}/steps": {
      "get": {
        "operationId": "flowsRunsRunIdStepsGet",
        "x-permission": "flows:read",
        "summary": "Step traces for a run",
        "description": "Skeleton fields (status, timings, error class) are visible to anyone with flows:read. Per-step input/output payloads are returned only to callers who also hold flows:update or flows:execute — they can carry record field values the run principal could see, which must not leak to ordinary members via the history surface. Decrypted workspace secret VALUES are scrubbed from payloads before they are stored, so they cannot appear even for privileged readers. Payloads also null out once the retention window prunes them.",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "runId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The steps in execution order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowRunStepList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such run in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/runs/{runId}/cancel": {
      "post": {
        "operationId": "flowsRunsRunIdCancelPost",
        "x-permission": "flows:execute",
        "summary": "Cancel a queued or waiting run",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "runId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The cancelled run",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowRun"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such run in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The run already finished (or is mid-execution) and cannot be cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flow-approvals": {
      "get": {
        "operationId": "flowApprovalsGet",
        "x-permission": "approvals:request",
        "summary": "List flow approval requests routed to you (the approvals inbox)",
        "description": "Requests created by flow `approval` blocks, newest first — the same inbox surface as pending changes, and scoped the same way: you see the requests routed to YOU (named on the request's frozen approver route, or holding its role), not the whole workspace queue. That scoping is confidentiality, not just ergonomics — a request's title and detail are rendered from the run's masked context, so they may carry field values, and routing them is the author's deliberate act. Each row carries `canDecide`, true only while the request is still open.",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by lifecycle status (default all).",
            "schema": {
              "type": "string",
              "x-known-values": "KnownFlowApprovalStatus"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowApprovalRequestList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flow-approvals/{approvalId}/decide": {
      "post": {
        "operationId": "flowApprovalsApprovalIdDecidePost",
        "x-permission": "approvals:decide",
        "summary": "Approve or reject a flow approval request",
        "description": "Records the decision and wakes the parked run. The decider must match the request's frozen approver route — the action gate is necessary, never sufficient. Rejection is DATA to the flow (its approval block outputs `approved: false` and the run continues); it does not fail the run. A request that already resolved (decided, or expired by its own timeout) returns 409 with the settled status.",
        "tags": [
          "Flows"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "approvalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FlowApprovalDecisionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The decided request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowApprovalRequest"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller is not on the request's approver route",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such request in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The request already resolved (decided or expired)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/hooks/flows/{workspaceId}/{flowId}/{token}": {
      "post": {
        "operationId": "hooksFlowsWorkspaceIdFlowIdTokenPost",
        "summary": "Inbound webhook ingress for a flow",
        "description": "The one deliberately unauthenticated flow surface: the unguessable URL token is the credential, verified against the primary registry before any shard is touched. Every identity/credential mismatch returns the same 404 (no enumeration). The request body becomes the run's payload ({{payload.*}}). api_key-mode hooks additionally require a workspace API token bearer.",
        "tags": [
          "Flows"
        ],
        "security": [],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "description": "The flow's workspace. A flow id is unique only within its workspace, so the URL names both.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "flowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "description": "The webhook body; becomes payload.* in the run context. Untyped."
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Run enqueued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboundFlowHookResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "api_key-mode hook without a valid workspace API token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Unknown flow/token (uniform for every mismatch)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The flow is disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "415": {
            "description": "Unsupported content type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/resource-limits/{measure}/{resourceType}/{resourceId}": {
      "get": {
        "operationId": "resourceLimitsMeasureResourceTypeResourceIdGet",
        "x-permission": "flows:read",
        "summary": "Get the effective quota for one resource",
        "description": "The full resolution for a resource in the caller's workspace: the value actually enforced, which tier bound it, the maximum a workspace admin may configure, whatever is currently configured (even when it is being clamped), and current usage in the open window.\n",
        "tags": [
          "Limits"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "measure",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resourceType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resourceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The resource's effective quota and usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourceLimitStatus"
                }
              }
            }
          },
          "400": {
            "description": "Unknown measure or resource type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "resourceLimitsMeasureResourceTypeResourceIdPut",
        "x-permission": "limits:manage",
        "summary": "Configure the quota for one resource",
        "description": "Sets the resource's own limit (T1). The value must not exceed the maximum in force above it; a request that does is rejected with the maximum in the error so the UI can explain it. Sending null clears the configuration, so the resource inherits the maximum.\n",
        "tags": [
          "Limits"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "measure",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resourceType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resourceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateResourceLimitRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Limit updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourceLimitStatus"
                }
              }
            }
          },
          "400": {
            "description": "Value exceeds the maximum in force, or unknown measure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/usage": {
      "get": {
        "operationId": "organizationsOrganizationIdUsageGet",
        "x-org-permission": "org:billing:manage",
        "summary": "Get organization usage (current and monthly history)",
        "description": "The organization's metered resource usage: a live current reading and the persisted monthly history per measure. Visible to org owners and admins. Usage figures only — no pricing information.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "monthsBack",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 24,
              "default": 12
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The organization's usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationUsageResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/billing": {
      "get": {
        "operationId": "organizationsOrganizationIdBillingGet",
        "x-org-permission": "org:billing:manage",
        "summary": "Get the organization's billing account",
        "description": "Current plan and subscription state, trial countdown, the payment method on file, and outstanding balance. The single read the billing settings surface needs.\n",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The organization's billing account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingAccountResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found, access denied, or payment collection not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/profile": {
      "get": {
        "operationId": "organizationsOrganizationIdBillingProfileGet",
        "x-org-permission": "org:billing:manage",
        "summary": "Get the organization's billing identity",
        "description": "The \"bill to\" party printed on every invoice, plus the tax numbers on file and the issuing authority's verdict on each.\nDeliberately NOT gated on payment collection being enabled: a customer must be able to enter their legal details, address and VAT number before anyone decides to start charging them.\n",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The organization's billing profile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingProfileResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "organizationsOrganizationIdBillingProfilePut",
        "x-org-permission": "org:billing:manage",
        "summary": "Update the organization's billing identity",
        "description": "Partial update. The profile row is created on first write rather than with the organization, so that \"has this customer given us their details?\" stays an answerable question.\n",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateBillingProfileRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated billing profile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingProfileResponse"
                }
              }
            }
          },
          "400": {
            "description": "A field failed validation (unsupported currency, malformed country, bad email)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/tax-ids": {
      "put": {
        "operationId": "organizationsOrganizationIdBillingTaxIdsPut",
        "x-org-permission": "org:billing:manage",
        "summary": "Record a tax identifier",
        "description": "Adds or replaces the organization's tax number for one country. Changing the number discards the previous verdict and its consultation number — they evidenced a different registration.\n",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetBillingTaxIdRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated billing profile, including the new tax id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingProfileResponse"
                }
              }
            }
          },
          "400": {
            "description": "Malformed country code or tax number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/tax-ids/{countryCode}": {
      "delete": {
        "operationId": "organizationsOrganizationIdBillingTaxIdsCountryCodeDelete",
        "x-org-permission": "org:billing:manage",
        "summary": "Remove a tax identifier",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "countryCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization or tax id not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/plans": {
      "get": {
        "operationId": "organizationsOrganizationIdBillingPlansGet",
        "x-org-permission": "org:billing:manage",
        "summary": "List the plans this organization may move to",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Selectable plans",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingPlansResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found, access denied, or payment collection not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/plan": {
      "put": {
        "operationId": "organizationsOrganizationIdBillingPlanPut",
        "x-org-permission": "org:billing:manage",
        "summary": "Change the organization's plan",
        "description": "Self-serve plan change. An upgrade (a plan with a higher monthly fee in the organization's billing currency) applies immediately, and the whole current period is billed on it — there is no proration. Any other change takes effect at the start of the next billing period, so the current period is billed, and limited, on the plan in force; the response's `pendingPlanChange` shows it, and choosing the current plan again cancels it. An upgrade also cancels a scheduled change. Leaving a trial by choosing any plan applies immediately.\n",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangeBillingPlanRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated billing account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingAccountResponse"
                }
              }
            }
          },
          "400": {
            "description": "Unknown or unavailable plan",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found, access denied, or payment collection not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/payment-method-session": {
      "post": {
        "operationId": "organizationsOrganizationIdBillingPaymentMethodSessionPost",
        "x-org-permission": "org:billing:manage",
        "summary": "Start hosted payment-method capture",
        "description": "Returns a provider-hosted URL to send the browser to. Card details go straight from the browser to the payment provider and never reach this API, which is what keeps card handling out of scope here. The completion is recorded from the provider's signed webhook, never from the browser's return trip — so after returning, poll GET /organizations/{id}/billing until the method appears.\n",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartPaymentMethodSetupRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "A hosted capture session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentMethodSetupSession"
                }
              }
            }
          },
          "400": {
            "description": "Invalid return or cancel URL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found, access denied, or payment collection not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "The payment provider could not be reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/payment-methods/{paymentMethodId}": {
      "delete": {
        "operationId": "organizationsOrganizationIdBillingPaymentMethodsPaymentMethodIdDelete",
        "x-org-permission": "org:billing:manage",
        "summary": "Remove a payment method",
        "description": "The LAST payment method on file is refused (409) while anything still bills to it — an outstanding invoice, or a live subscription on a plan with a positive base price. Add a replacement card first, settle the balance, or cancel the subscription. Once nothing depends on it, the last card can always be removed.\n",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "paymentMethodId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization, payment method, or billing not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "This is the org's last payment method and it is still needed — an invoice is outstanding, or a live subscription on a paid plan bills to it\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "The payment provider could not be reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/invoices": {
      "get": {
        "operationId": "organizationsOrganizationIdBillingInvoicesGet",
        "x-org-permission": "org:billing:manage",
        "summary": "List the organization's invoices",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 24
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invoices, newest period first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingInvoiceListResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found, access denied, or payment collection not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/invoices/{invoiceId}": {
      "get": {
        "operationId": "organizationsOrganizationIdBillingInvoicesInvoiceIdGet",
        "x-org-permission": "org:billing:manage",
        "summary": "Get one invoice with its itemized lines",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice and its lines",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingInvoiceDetail"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Invoice not found, access denied, or payment collection not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/invoices/{invoiceId}/pay": {
      "post": {
        "operationId": "organizationsOrganizationIdBillingInvoicesInvoiceIdPayPost",
        "x-org-permission": "org:billing:manage",
        "summary": "Retry payment for an unpaid invoice",
        "description": "Attempts collection immediately against the payment method on file, and resets the retry ladder — a person asking for this has usually just fixed the card, and making them wait for the next scheduled sweep is how an invoice stays unpaid.\n",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The outcome of the attempt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayInvoiceResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Invoice not found, access denied, or payment collection not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/invoices/{invoiceId}/pdf": {
      "get": {
        "operationId": "organizationsOrganizationIdBillingInvoicesInvoiceIdPdfGet",
        "x-org-permission": "org:billing:manage",
        "summary": "Download an invoice as a PDF",
        "description": "Renders the invoice as a PDF document: our details as the seller, the organization's billing profile as the bill-to party, the invoice reference, issue and due dates, the billing period, the itemized lines, the totals and the amount already paid. Only an issued invoice is a document — a draft is still being prepared and is refused with 409. A void invoice is rendered marked VOID, so the cancelled document can still be filed.\n",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization whose invoice is downloaded.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "description": "The invoice to render, as listed by the invoices endpoint.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice PDF, sent as an attachment named after the invoice reference. The client saves it as a file.\n",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "The PDF document's bytes."
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Invoice not found, access denied, or payment collection not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "No document can be produced yet. `code` says why: `invoice_not_issued` for a draft, `issuer_not_configured` while our own company details (which every document prints) are not set up.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/billing/invoice-export": {
      "get": {
        "operationId": "organizationsOrganizationIdBillingInvoiceExportGet",
        "x-org-permission": "org:billing:manage",
        "summary": "Export invoices for an accounting system",
        "description": "Exports the organization's issued invoices as a CSV file to import into an accounting system. `format=xero_bills` follows Xero's bill import template: our invoices are the organization's purchases, so they import as bills from us as the supplier. One row per invoice line; an invoice whose lines all came to nothing exports as one zero-value row, so every invoice appears. `AccountCode` and `TaxType` are left empty for the importer to fill from the contact's defaults, because both name entries in the importing organization's own chart of accounts. Drafts and void invoices are never exported. Pass `invoiceId` for one invoice, or `from`/`to` for the invoices dated in a range; with neither, every issued invoice is exported.\n",
        "tags": [
          "Billing"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization whose invoices are exported.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": true,
            "description": "The file layout. `xero_bills` is Xero's bill (purchase invoice) import template.\n",
            "schema": {
              "type": "string",
              "enum": [
                "xero_bills"
              ]
            }
          },
          {
            "name": "invoiceId",
            "in": "query",
            "required": false,
            "description": "Export just this invoice. A draft or void invoice is refused with 409; one of another organization is not found.\n",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "First invoice date to include (inclusive), as YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Last invoice date to include (inclusive), as YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The CSV file (UTF-8 with a byte-order mark, CRLF line endings), sent as an attachment. A range with no invoices in it is a file with only the header row.\n",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "The CSV file's bytes."
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Invoice not found, access denied, or payment collection not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "No export can be produced. `code` says why: `invoice_not_issued` when the requested invoice is a draft or void, `issuer_not_configured` while our own company details (the supplier on every bill) are not set up.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/members": {
      "get": {
        "operationId": "organizationsOrganizationIdMembersGet",
        "x-org-permission": "org:read",
        "summary": "List organization members",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeInactive",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of organization members",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrganizationMember"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/members/{userId}": {
      "patch": {
        "operationId": "organizationsOrganizationIdMembersUserIdPatch",
        "x-org-permission": "org:members:manage",
        "summary": "Update an organization member's role",
        "description": "Requires org owner or admin. Only owners may grant owner/admin; admins cannot modify admins or owners; the last active owner cannot be demoted.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateOrganizationMemberRoleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Member updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationMember"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Member not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "organizationsOrganizationIdMembersUserIdDelete",
        "x-org-permission": "org:members:manage",
        "summary": "Deactivate an organization member",
        "description": "Soft delete. Also deactivates the user's active workspace memberships in this organization's workspaces (enforced by a database trigger) and revokes their workspace-bound API tokens. The last active owner cannot be deactivated. Admins cannot deactivate admins or owners (other than themselves).",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Member deactivated"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Member not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/members/{userId}/reactivate": {
      "post": {
        "operationId": "organizationsOrganizationIdMembersUserIdReactivatePost",
        "x-org-permission": "org:members:manage",
        "summary": "Reactivate a deactivated organization member",
        "description": "Restores the organization membership only — workspace memberships deactivated alongside it are not restored and must be re-granted per workspace. Only owners can reactivate owners or admins.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Member reactivated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationMember"
                }
              }
            }
          },
          "400": {
            "description": "Member is already active",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Member not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/invites": {
      "post": {
        "operationId": "organizationsOrganizationIdInvitesPost",
        "x-org-permission": "org:members:manage",
        "summary": "Create organization invitation",
        "description": "Invite a user to the organization. Requires org owner or admin; owner/admin invites require the owner role.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOrganizationInviteRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Invitation created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationInvite"
                }
              }
            }
          },
          "400": {
            "description": "User already a member or invite already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "get": {
        "operationId": "organizationsOrganizationIdInvitesGet",
        "x-org-permission": "org:members:manage",
        "summary": "List pending organization invitations",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of pending invitations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrganizationInvite"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/invites/{inviteId}": {
      "patch": {
        "operationId": "organizationsOrganizationIdInvitesInviteIdPatch",
        "x-org-permission": "org:members:manage",
        "summary": "Update a pending organization invitation",
        "description": "Change the organization role or the workspace grants of an invitation that has not been accepted yet. Supplying workspaceGrants replaces the whole set. Granting the owner or admin organization role stays owner-only, as it is on create.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "inviteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateOrganizationInviteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Invitation updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationInvite"
                }
              }
            }
          },
          "400": {
            "description": "Invitation has already been accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Invitation not found, or a granted workspace is not in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "organizationsOrganizationIdInvitesInviteIdDelete",
        "x-org-permission": "org:members:manage",
        "summary": "Revoke an organization invitation",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "inviteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Invitation revoked"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Invitation not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/invites/{inviteId}/resend": {
      "post": {
        "operationId": "organizationsOrganizationIdInvitesInviteIdResendPost",
        "x-org-permission": "org:members:manage",
        "summary": "Re-issue an invitation's shareable link",
        "description": "Rotates the invitation's token and extends its expiry, returning the new link. Needed because the token is stored hashed and so cannot be shown again after creation. Rotating invalidates the previous link.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "inviteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invitation re-issued, with a fresh token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationInvite"
                }
              }
            }
          },
          "400": {
            "description": "Invitation has already been accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Invitation not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/invites/bulk": {
      "post": {
        "operationId": "organizationsOrganizationIdInvitesBulkPost",
        "x-org-permission": "org:members:manage",
        "summary": "Create many organization invitations at once",
        "description": "Invites up to 500 people in one request — the onboarding step of a migration, where a whole user directory arrives as a list of addresses. Each entry is judged on its own and the response says what became of every one: an invitation (with its shareable token, shown once), or why none was made — the address already belongs to an active member, a pending invitation already exists, the entry repeats an earlier one, or the role is one the caller may not grant. Every invitation the request earns is created in one transaction, so a refused entry never leaves the others half done. Requires org owner or admin; owner/admin roles are owner-only, as on the single invite.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkOrganizationInviteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Every entry judged; see each result's `outcome`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkOrganizationInviteResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization, or a granted workspace, not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/org-invites/pending": {
      "get": {
        "operationId": "orgInvitesPendingGet",
        "summary": "List pending organization invitations for current user",
        "description": "Returns all pending organization invitations matching the user's email",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of pending invitations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrganizationInvite"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/org-invites/{inviteId}/accept": {
      "post": {
        "operationId": "orgInvitesInviteIdAcceptPost",
        "summary": "Accept organization invitation (authenticated)",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "inviteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invitation accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AcceptOrganizationInviteResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Email mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Invitation not found or expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/org-invites/token/{token}/accept": {
      "post": {
        "operationId": "orgInvitesTokenTokenAcceptPost",
        "summary": "Accept organization invitation via shareable link",
        "description": "Accept an organization invitation using the shareable token.\nIf user is authenticated and email matches, accepts immediately.\nOtherwise, returns invite details for login/registration flow.\n",
        "tags": [
          "Organizations"
        ],
        "security": [],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invitation accepted or requires authentication",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accepted": {
                      "type": "boolean"
                    },
                    "requiresAuth": {
                      "type": "boolean"
                    },
                    "invite": {
                      "$ref": "#/components/schemas/OrganizationInvite"
                    },
                    "membership": {
                      "type": "object",
                      "properties": {
                        "organizationId": {
                          "type": "string"
                        },
                        "organizationName": {
                          "type": "string"
                        },
                        "role": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "description": "Invitation not found or expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/parts": {
      "get": {
        "operationId": "organizationsOrganizationIdLibraryPartsGet",
        "x-org-permission": "org:read",
        "summary": "List the organization's schema parts",
        "description": "Every part the organization publishes, whatever its visibility, newest first.\nWithdrawn parts are included, with the operator's reason only for a caller who\nmanages the organization's library.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization whose library this is.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The organization's parts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SchemaPartSummary"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions: the caller does not hold the organization role this needs, or is not calling from their own signed-in session (code `PERMISSION_DENIED`): API tokens, OAuth clients, assumed sessions and hosted-site sessions are always refused here; publishing is a person's act.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "organizationsOrganizationIdLibraryPartsPost",
        "x-org-permission": "org:library:manage",
        "summary": "Publish a schema part",
        "description": "Publishes a new part under the organization from a posted document (composed\nin a workspace, downloaded from another part, or written by hand), as its\nversion 1. The document is validated standalone; its slots, stats,\ncapabilities and platform pin are derived from it, never taken from the\nrequest. The caller becomes the version's credited user. Requires the\norganization owner or admin role.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization whose library this is.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublishSchemaPartRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The published part",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPart"
                }
              }
            }
          },
          "400": {
            "description": "The request did not match this specification, or the document did not validate: the refusal names the problem and, for a document, `issues` carries the `PlanIssue`s that explain how to fix it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the organization role this needs (API tokens, OAuth clients, assumed sessions and hosted-site sessions are always refused here, code `PERMISSION_DENIED`); the organization has reached its part limit (code `LIMIT_EXCEEDED`, limit `library.maxPartsPerOrganization`); or the organization's plan does not allow organization visibility (code `LIBRARY_ORGANIZATION_VISIBILITY_DISABLED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The organization already publishes a part with this slug (code `PART_SLUG_TAKEN`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/parts/{partId}": {
      "patch": {
        "operationId": "organizationsOrganizationIdLibraryPartsPartIdPatch",
        "x-org-permission": "org:library:manage",
        "summary": "Change a schema part's metadata, visibility or deprecation",
        "description": "Edits what a publisher may change after publishing: name, summary, tags,\ncategory, visibility, and deprecation (with a note and optionally a\nsuccessor; null undoes it). Versions never change. Narrowing visibility does\nnot revoke copies already installed.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization whose library this is.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchSchemaPartRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated part",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPart"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the organization role this needs (API tokens, OAuth clients, assumed sessions and hosted-site sessions are always refused here, code `PERMISSION_DENIED`), or the organization's plan does not allow organization visibility (code `LIBRARY_ORGANIZATION_VISIBILITY_DISABLED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied, or the organization publishes no part with this id (code `PART_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/parts/{partId}/versions": {
      "post": {
        "operationId": "organizationsOrganizationIdLibraryPartsPartIdVersionsPost",
        "x-org-permission": "org:library:manage",
        "summary": "Publish a new version of a schema part",
        "description": "Publishes the part's next version from a posted document, numbered one past\nthe latest. Any member with the organization's library role may publish one\nand becomes its credited user. A document identical to the latest version is\nrefused; one identical to an earlier version (a revert) publishes as a new\nversion. A part takes at most 20 versions a day (429, code\n`PART_VERSION_RATE`).\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization whose library this is.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublishSchemaPartVersionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The published version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartVersion"
                }
              }
            }
          },
          "400": {
            "description": "The request did not match this specification, or the document did not validate: the refusal names the problem and, for a document, `issues` carries the `PlanIssue`s that explain how to fix it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions: the caller does not hold the organization role this needs, or is not calling from their own signed-in session (code `PERMISSION_DENIED`): API tokens, OAuth clients, assumed sessions and hosted-site sessions are always refused here; publishing is a person's act.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied, or the organization publishes no part with this id (code `PART_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The document is identical to the part's latest version (code `PART_VERSION_UNCHANGED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/parts/{partId}/compose": {
      "post": {
        "operationId": "organizationsOrganizationIdLibraryPartsPartIdComposePost",
        "x-org-permission": "org:library:manage",
        "summary": "Recompose a schema part from its workspace",
        "description": "Republish from the workspace: composes the same tables the part was composed\nfrom, in the named workspace, and returns the new document with its diff\nagainst the latest version — what \"Publish as version N+1\" would publish.\nNothing is published. The caller must be able to read that workspace's tables.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization whose library this is.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ComposeFromWorkspaceRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The recomposed document and its diff",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComposeFromWorkspaceResult"
                }
              }
            }
          },
          "400": {
            "description": "The request did not match this specification, or the latest version was published from a posted document rather than composed from a workspace, so there are no tables to compose again (code `PART_NOT_COMPOSED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions: the caller does not hold the organization role this needs, is not calling from their own signed-in session (API tokens, OAuth clients, assumed sessions and hosted-site sessions are always refused here), or cannot read the named workspace's tables, or the workspace is not the organization's (code `PERMISSION_DENIED` for each)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied, or the organization publishes no part with this id (code `PART_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/parts/{partId}/versions/{number}/fork": {
      "post": {
        "operationId": "organizationsOrganizationIdLibraryPartsPartIdVersionsNumberForkPost",
        "x-org-permission": "org:library:manage",
        "summary": "Fork a schema part version into the organization",
        "description": "Creates a new part under this organization whose version 1 copies the named\nversion of any part the caller may see (`partId` names the source, which\nneed not be this organization's), with the lineage recorded and counted on the\nsource. A deprecated or withdrawn source is refused.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization whose library this is.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The source part to fork.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "description": "The source version to fork.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ForkSchemaPartRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new part",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPart"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the organization role this needs (API tokens, OAuth clients, assumed sessions and hosted-site sessions are always refused here, code `PERMISSION_DENIED`); the organization has reached its part limit (code `LIMIT_EXCEEDED`, limit `library.maxPartsPerOrganization`); or the organization's plan does not allow organization visibility (code `LIBRARY_ORGANIZATION_VISIBILITY_DISABLED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied, or no such part or version is visible to the caller (code `PART_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The source cannot be forked because it is deprecated or withdrawn (code `PART_FORK_REFUSED`), or the organization already publishes a part with this slug (code `PART_SLUG_TAKEN`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/kits": {
      "get": {
        "operationId": "organizationsOrganizationIdLibraryKitsGet",
        "x-org-permission": "org:read",
        "summary": "List the organization's kits",
        "description": "Every kit the organization publishes, whatever its visibility, newest first, withdrawn ones included, with pending credits.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization acting: the kit's publisher, or for `kit-credits` the credited organization.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The organization's kits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LibraryKitSummary"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the organization role this needs, or is not calling from their own signed-in session (code `PERMISSION_DENIED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "organizationsOrganizationIdLibraryKitsPost",
        "x-org-permission": "org:library:manage",
        "summary": "Publish a kit",
        "description": "Publishes a new kit under the organization with its version 1: part versions in install order,\n     the bindings between them, an optional extension source and a readme written as a setup guide.\n     Every part must be readable wherever the kit is, installable and not withdrawn; the source is\n     validated as a site archive and each placement must name a declared `record.block` extension and\n     a table a kit part creates. Requires the organization owner or admin role.\n     Only the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization acting: the kit's publisher, or for `kit-credits` the credited organization.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublishLibraryKitRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The published kit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryKit"
                }
              }
            }
          },
          "400": {
            "description": "The request did not match this specification, or the kit version did not validate (code `KIT_INVALID`): `issues` names each part, binding, source or placement problem and how to fix it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the organization role this needs, or is not calling from their own signed-in session (code `PERMISSION_DENIED`); or the organization's plan does not allow organization visibility (code `LIBRARY_ORGANIZATION_VISIBILITY_DISABLED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The organization already publishes a kit with this slug (code `KIT_SLUG_TAKEN`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/kits/{kitId}/versions": {
      "post": {
        "operationId": "organizationsOrganizationIdLibraryKitsKitIdVersionsPost",
        "x-org-permission": "org:library:manage",
        "summary": "Publish a kit version",
        "description": "Publishes the next version of one of the organization's kits, validated as on publishing. Versions are immutable.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization acting: the kit's publisher, or for `kit-credits` the credited organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kitId",
            "in": "path",
            "required": true,
            "description": "The kit's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublishLibraryKitVersionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The kit, with the new version as its latest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryKit"
                }
              }
            }
          },
          "400": {
            "description": "The request did not match this specification, or the kit version did not validate (code `KIT_INVALID`): `issues` names each part, binding, source or placement problem and how to fix it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the organization role this needs, or is not calling from their own signed-in session (code `PERMISSION_DENIED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied, or the organization publishes no kit with this id (code `KIT_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The kit is withdrawn and takes no new versions (code `KIT_WITHDRAWN`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/kits/{kitId}/collaborators": {
      "post": {
        "operationId": "organizationsOrganizationIdLibraryKitsKitIdCollaboratorsPost",
        "x-org-permission": "org:library:manage",
        "summary": "Credit an organization on a kit",
        "description": "Credits another organization on one of the organization's kits. The credit is pending, and invisible on the kit, until an admin of that organization accepts it (`POST /organizations/{organizationId}/library/kit-credits/{kitId}/accept`). Crediting an organization already credited answers its current state.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization acting: the kit's publisher, or for `kit-credits` the credited organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kitId",
            "in": "path",
            "required": true,
            "description": "The kit's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddLibraryKitCollaboratorRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The kit, its collaborators including the pending credit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryKitSummary"
                }
              }
            }
          },
          "400": {
            "description": "The request did not match this specification, or names the publisher itself (code `KIT_COLLABORATOR_INVALID`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the organization role this needs, or is not calling from their own signed-in session (code `PERMISSION_DENIED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied, no kit with this id, or no organization with the credited id (codes `KIT_NOT_FOUND`, `ORGANIZATION_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/kits/{kitId}/collaborators/{collaboratorId}": {
      "delete": {
        "operationId": "organizationsOrganizationIdLibraryKitsKitIdCollaboratorsCollaboratorIdDelete",
        "x-org-permission": "org:library:manage",
        "summary": "Remove a credit from a kit",
        "description": "Removes an organization's credit, pending or accepted, from one of the organization's kits.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization acting: the kit's publisher, or for `kit-credits` the credited organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kitId",
            "in": "path",
            "required": true,
            "description": "The kit's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "collaboratorId",
            "in": "path",
            "required": true,
            "description": "The credited organization's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the organization role this needs, or is not calling from their own signed-in session (code `PERMISSION_DENIED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied, no kit with this id, or the organization is not credited on it (codes `KIT_NOT_FOUND`, `KIT_COLLABORATOR_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/kit-credits": {
      "get": {
        "operationId": "organizationsOrganizationIdLibraryKitCreditsGet",
        "x-org-permission": "org:library:manage",
        "summary": "List the kits that credit the organization",
        "description": "Every kit that credits the organization, pending and accepted, newest first. A pending credit is the one place an organization sees a kit it was credited on before accepting.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization acting: the kit's publisher, or for `kit-credits` the credited organization.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The organization's credits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LibraryKitCredit"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the organization role this needs, or is not calling from their own signed-in session (code `PERMISSION_DENIED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/kit-credits/{kitId}/accept": {
      "post": {
        "operationId": "organizationsOrganizationIdLibraryKitCreditsKitIdAcceptPost",
        "x-org-permission": "org:library:manage",
        "summary": "Accept a credit on a kit",
        "description": "Accepts the organization's credit on a kit, which then shows it beside the publisher (\"Curated by Tessule with <organization>\" on a curated kit). Accepting an accepted credit changes nothing.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization acting: the kit's publisher, or for `kit-credits` the credited organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kitId",
            "in": "path",
            "required": true,
            "description": "The kit's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The credit, accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryKitCredit"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the organization role this needs, or is not calling from their own signed-in session (code `PERMISSION_DENIED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied, or the organization is not credited on this kit (code `KIT_CREDIT_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/kit-credits/{kitId}": {
      "delete": {
        "operationId": "organizationsOrganizationIdLibraryKitCreditsKitIdDelete",
        "x-org-permission": "org:library:manage",
        "summary": "Decline or withdraw a credit on a kit",
        "description": "Removes the organization's credit from a kit, pending or accepted; the kit stops showing it.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization acting: the kit's publisher, or for `kit-credits` the credited organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kitId",
            "in": "path",
            "required": true,
            "description": "The kit's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the organization role this needs, or is not calling from their own signed-in session (code `PERMISSION_DENIED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied, or the organization is not credited on this kit (code `KIT_CREDIT_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/library/parts/{partId}/analytics": {
      "get": {
        "operationId": "organizationsOrganizationIdLibraryPartsPartIdAnalyticsGet",
        "x-org-permission": "org:library:manage",
        "summary": "Read a schema part's usage",
        "description": "How the organization's part is used: its counters and, per version, distinct\ninstalls, installs still active and forks.\nOnly the person's own signed-in session may call it: API tokens, OAuth clients,\nassumed (impersonated) sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The organization whose library this is.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The part's usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartAnalytics"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions: the caller does not hold the organization role this needs, or is not calling from their own signed-in session (code `PERMISSION_DENIED`): API tokens, OAuth clients, assumed sessions and hosted-site sessions are always refused here; publishing is a person's act.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied, or the organization publishes no part with this id (code `PART_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/workspaces": {
      "get": {
        "operationId": "organizationsOrganizationIdWorkspacesGet",
        "x-org-permission": "org:read",
        "summary": "List workspaces owned by the organization",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of workspaces",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrganizationWorkspace"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "organizationsOrganizationIdWorkspacesPost",
        "x-org-permission": "org:workspaces:manage",
        "summary": "Create a workspace in the organization",
        "description": "Requires org owner or admin. The creator becomes the workspace owner member.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOrganizationWorkspaceRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Workspace created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationWorkspace"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/workspaces/{workspaceId}": {
      "patch": {
        "operationId": "organizationsOrganizationIdWorkspacesWorkspaceIdPatch",
        "x-org-permission": "org:workspaces:manage",
        "summary": "Rename a workspace or toggle its deletable flag",
        "description": "Management-only surface - requires org owner or admin; the workspace must belong to the organization.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateOrganizationWorkspaceRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Workspace updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationWorkspace"
                }
              }
            }
          },
          "400": {
            "description": "No properties provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Workspace not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/workspaces/{workspaceId}/delete-request": {
      "post": {
        "operationId": "organizationsOrganizationIdWorkspacesWorkspaceIdDeleteRequestPost",
        "x-org-permission": "org:workspaces:manage",
        "summary": "Begin the two-step hard delete of a deletable workspace",
        "description": "Step one of the two-step delete. Issues a short-lived confirmation token that must accompany the delete call together with the workspace's exact name. Only the most recent request per workspace is kept — issuing a new token invalidates any previous one. Refused (409) for workspaces not marked deletable.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmation token issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceDeleteRequestResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Workspace not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Workspace is not deletable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/workspaces/{workspaceId}/delete": {
      "post": {
        "operationId": "organizationsOrganizationIdWorkspacesWorkspaceIdDeletePost",
        "x-org-permission": "org:workspaces:manage",
        "summary": "Confirm and execute the hard delete of a deletable workspace",
        "description": "Step two of the two-step delete. Requires the confirmation token from the delete-request endpoint plus the workspace's exact current name. Hard-deletes the workspace immediately and irreversibly - its Postgres schema (all tables and rows), its control-plane rows (members, tokens, roles, automations, ...), and its stored attachments. Organization-level backups of the workspace survive and remain restorable. Refused for non-deletable workspaces, on token/name mismatch, and while a shard move is in flight.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfirmWorkspaceDeleteRequest"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Workspace permanently deleted"
          },
          "400": {
            "description": "Name does not match the workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Workspace not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Workspace is not deletable, no valid delete request is pending (missing, superseded, or expired token), or the workspace is quiesced by an operator action (e.g. a shard move in flight)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "410": {
            "description": "Confirmation token has expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/directory": {
      "get": {
        "operationId": "organizationsOrganizationIdDirectoryGet",
        "x-org-permission": "org:directory:read",
        "summary": "Organization user directory",
        "description": "Deduplicated union of org members and members of all org workspaces. Requires org owner or admin (reveals cross-workspace membership).",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Directory entries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrganizationDirectoryEntry"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/backups": {
      "get": {
        "operationId": "organizationsOrganizationIdBackupsGet",
        "x-org-permission": "org:backups:manage",
        "summary": "List the organization's workspace backups",
        "description": "Newest first. Backups are a DR control surface, so the read side is management-gated too (same convention as SSO connections).\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of workspace backups",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkspaceBackup"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "organizationsOrganizationIdBackupsPost",
        "x-org-permission": "org:backups:manage",
        "summary": "Start a backup of one of the organization's workspaces",
        "description": "Queues an async export of the whole workspace (schema, records with the recycle bin, saved queries/charts/dashboards, roles/groups/shares, flows, settings, files) into an org-scoped backup artifact. Records and configuration are captured as one consistent snapshot (a `pg_dump` of the workspace schema); files are copied just after it, so a file uploaded while the export runs may or may not be included. The caller must be an active admin of the workspace being backed up as well as holding `org:backups:manage`: the export reads every row unscoped, and organization roles never grant workspace data access on their own.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorkspaceBackupRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Backup queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceBackup"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions — requires `org:backups:manage` AND an active admin membership of the source workspace (policy `backups.sourceWorkspaceAdmin`; the response names it).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization or workspace not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Stored-backup limit reached — delete an existing backup first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "A backup of this workspace is already running, or the organization already has as many backup and restore jobs in flight as it may run at once.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/backups/{backupId}": {
      "get": {
        "operationId": "organizationsOrganizationIdBackupsBackupIdGet",
        "x-org-permission": "org:backups:manage",
        "summary": "Get one workspace backup, including live job progress",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "backupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The backup",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceBackup"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Backup not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "organizationsOrganizationIdBackupsBackupIdDelete",
        "x-org-permission": "org:backups:manage",
        "summary": "Delete a workspace backup and its stored artifacts",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "backupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Backup deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Backup not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A backup or restore job is currently running for this backup",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/backups/{backupId}/download": {
      "get": {
        "operationId": "organizationsOrganizationIdBackupsBackupIdDownloadGet",
        "x-org-permission": "org:backups:manage",
        "summary": "Get the state of a backup's downloadable archive",
        "description": "Returns `none` until a download has been requested with POST. Poll this while `preparing`; when `ready` the response carries a short-lived pre-signed URL for the packaged `.tar`. The URL is a credential for the whole workspace's data, so — as for POST — the caller must be an active admin of the backup's source workspace unless that workspace no longer exists.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "backupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Download state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BackupDownload"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions — requires `org:backups:manage` AND an active admin membership of the backup's source workspace (policy `backups.sourceWorkspaceAdmin`; the response names it). Waived once the source workspace no longer exists.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Backup not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "organizationsOrganizationIdBackupsBackupIdDownloadPost",
        "x-org-permission": "org:backups:manage",
        "summary": "Package a backup for download",
        "description": "Queues a job that copies the backup's objects into a single `.tar` archive in object storage, then hands back a short-lived pre-signed URL. Idempotent: while an archive is already being packaged, or a packaged one is still valid, this returns that state rather than queueing a second job. The archive is the whole workspace's data, so the caller must be an active admin of the backup's source workspace as well as holding `org:backups:manage` — waived once the source workspace no longer exists.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "backupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "An archive is already packaged and still valid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BackupDownload"
                }
              }
            }
          },
          "202": {
            "description": "Packaging queued (or already in progress)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BackupDownload"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions — requires `org:backups:manage` AND an active admin membership of the backup's source workspace (policy `backups.sourceWorkspaceAdmin`; the response names it). Waived once the source workspace no longer exists.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Backup not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The backup is not in a downloadable state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Another backup or restore job is already running for this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/backup-schedules": {
      "get": {
        "operationId": "organizationsOrganizationIdBackupSchedulesGet",
        "x-org-permission": "org:backups:manage",
        "summary": "List the organization's recurring backup schedules",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of backup schedules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BackupSchedule"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "organizationsOrganizationIdBackupSchedulesPost",
        "x-org-permission": "org:backups:manage",
        "summary": "Create a recurring backup schedule for a workspace",
        "description": "Each firing starts the same export an on-demand backup does. Before firing, the schedule deletes its own oldest backups down to `retainCount`, so it keeps running instead of wedging against the organization's stored-backup ceiling. Each firing runs with the creator's authority, so the creator must be an active admin of the workspace (as for an on-demand backup); a schedule whose creator later loses that membership stops firing and records why in `lastError`.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBackupScheduleRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Schedule created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BackupSchedule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid cron expression",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions — requires `org:backups:manage` AND an active admin membership of the source workspace (policy `backups.sourceWorkspaceAdmin`; the response names it).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization or workspace not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "This workspace already has a schedule, the organization is at its schedule limit, or the schedules would collectively keep more backups than the organization may store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/backup-schedules/{scheduleId}": {
      "patch": {
        "operationId": "organizationsOrganizationIdBackupSchedulesScheduleIdPatch",
        "x-org-permission": "org:backups:manage",
        "summary": "Update a backup schedule",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scheduleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateBackupScheduleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated schedule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BackupSchedule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid cron expression",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Schedule not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Raising this schedule's retention would take the organization's schedules past what it may store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "organizationsOrganizationIdBackupSchedulesScheduleIdDelete",
        "x-org-permission": "org:backups:manage",
        "summary": "Delete a backup schedule",
        "description": "Stops future runs. Backups the schedule already took are kept — they become ordinary on-demand backups (their `scheduleId` clears).\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scheduleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Schedule deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Schedule not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/backups/{backupId}/restore": {
      "post": {
        "operationId": "organizationsOrganizationIdBackupsBackupIdRestorePost",
        "x-org-permission": "org:backups:manage",
        "summary": "Restore a backup into a new workspace",
        "description": "Queues an async restore. Always provisions a NEW workspace in the organization — never overwrites an existing one. The new workspace stays invisible until the restore completes; the caller becomes its first admin member, and the source's members who are still active in the organization are granted their roles again. Every id in the workspace survives the restore. Access-granting rows (role assignments, group memberships, record shares) held by anyone who is not a member of the restored workspace, and every role held by an API token, are removed and reported as warnings. Flows come back switched off, each with `disabledReason` `restored`, and the job names them in its warnings: none runs until an admin switches it on. Because the restore hands the caller a full copy of the source workspace, they must be an active admin of that workspace as well as holding `org:backups:manage` — waived once the source workspace no longer exists, which is the disaster-recovery case backups exist for.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "backupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RestoreWorkspaceBackupRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Restore queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BackupRestoreJob"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions — requires `org:backups:manage` AND an active admin membership of the backup's source workspace (policy `backups.sourceWorkspaceAdmin`; the response names it). Waived once the source workspace no longer exists.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Backup not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The backup is not in a restorable state (not completed), its format version has left support — one year after being superseded (see WorkspaceBackup.expiresAt; the backup's age is immaterial) — or it has more tables than the organization's table limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Another backup or restore job is already running for this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/restores/{jobId}": {
      "get": {
        "operationId": "organizationsOrganizationIdRestoresJobIdGet",
        "x-org-permission": "org:backups:manage",
        "summary": "Get the status of a restore job",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The restore job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BackupRestoreJob"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Restore job not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/sso-connections": {
      "get": {
        "operationId": "organizationsOrganizationIdSsoConnectionsGet",
        "x-org-permission": "org:sso:manage",
        "summary": "List an organization's SSO connections",
        "description": "Returns the org's OIDC SSO connections. Requires org owner or admin. Client secrets are never returned (write-only) — only whether one is set.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SSO connections",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SsoConnection"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Org SSO is not configured on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "organizationsOrganizationIdSsoConnectionsPost",
        "x-org-permission": "org:sso:manage",
        "summary": "Create an SSO connection",
        "description": "Create an OIDC SSO connection for the organization. Requires org owner or admin. The client secret is stored encrypted at rest and never returned.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSsoConnectionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Connection created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SsoConnection"
                }
              }
            }
          },
          "400": {
            "description": "Invalid connection configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Org SSO is not configured on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/sso-connections/{connectionId}": {
      "get": {
        "operationId": "organizationsOrganizationIdSsoConnectionsConnectionIdGet",
        "x-org-permission": "org:sso:manage",
        "summary": "Get an SSO connection",
        "description": "Requires org owner or admin. The client secret is never returned.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SSO connection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SsoConnection"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Connection or organization not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Org SSO is not configured on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "organizationsOrganizationIdSsoConnectionsConnectionIdPatch",
        "x-org-permission": "org:sso:manage",
        "summary": "Update an SSO connection",
        "description": "Partially update a connection. Requires org owner or admin. Omit the client secret to keep the existing one; supply it to rotate. Only provided fields are changed.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSsoConnectionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Connection updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SsoConnection"
                }
              }
            }
          },
          "400": {
            "description": "Invalid connection configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Connection or organization not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Org SSO is not configured on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "organizationsOrganizationIdSsoConnectionsConnectionIdDelete",
        "x-org-permission": "org:sso:manage",
        "summary": "Delete an SSO connection",
        "description": "Requires org owner or admin.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Connection deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Connection or organization not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Org SSO is not configured on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/connected-apps": {
      "get": {
        "operationId": "organizationsOrganizationIdConnectedAppsGet",
        "x-org-permission": "org:sso:manage",
        "summary": "List an organization's connected apps",
        "description": "A connected app is a frontend on the customer's own origin, signed in through the organization's identity provider, that exchanges that provider's `id_token` for a token capped to the app's scopes. Requires org owner or admin.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Connected apps",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ConnectedApp"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "organizationsOrganizationIdConnectedAppsPost",
        "x-org-permission": "org:sso:manage",
        "summary": "Register a connected app",
        "description": "A connected app is a frontend on the customer's own origin, signed in through the organization's identity provider, that exchanges that provider's `id_token` for a token capped to the app's scopes. Requires org owner or admin. Registering an app is admin consent for every member of the organization who signs in to it.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateConnectedAppRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Connected app registered",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectedApp"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Org SSO is not configured on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/connected-apps/{appId}": {
      "get": {
        "operationId": "organizationsOrganizationIdConnectedAppsAppIdGet",
        "x-org-permission": "org:sso:manage",
        "summary": "Get a connected app",
        "description": "A connected app is a frontend on the customer's own origin, signed in through the organization's identity provider, that exchanges that provider's `id_token` for a token capped to the app's scopes. Requires org owner or admin.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "appId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Connected app",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectedApp"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "organizationsOrganizationIdConnectedAppsAppIdPatch",
        "x-org-permission": "org:sso:manage",
        "summary": "Update a connected app",
        "description": "A connected app is a frontend on the customer's own origin, signed in through the organization's identity provider, that exchanges that provider's `id_token` for a token capped to the app's scopes. Requires org owner or admin. Changing a field that governs what a token may do raises `policyVersion`.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "appId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateConnectedAppRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Connected app updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectedApp"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Org SSO is not configured on this server and the request binds an SSO connection (`ssoConnectionId`); every other edit, disabling included, works without SSO",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "organizationsOrganizationIdConnectedAppsAppIdDelete",
        "x-org-permission": "org:sso:manage",
        "summary": "Delete a connected app",
        "description": "A connected app is a frontend on the customer's own origin, signed in through the organization's identity provider, that exchanges that provider's `id_token` for a token capped to the app's scopes. Requires org owner or admin. Deleting the app refuses every later token exchange for its client id.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "appId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Connected app deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/domains": {
      "get": {
        "operationId": "organizationsOrganizationIdDomainsGet",
        "x-org-permission": "org:domains:manage",
        "summary": "List an organization's claimed email domains",
        "description": "Requires org owner or admin.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Claimed domains",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrgDomain"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "organizationsOrganizationIdDomainsPost",
        "x-org-permission": "org:domains:manage",
        "summary": "Claim an email domain for the organization",
        "description": "Creates a pending claim and returns the DNS TXT record to publish. Requires org owner or admin. Public mailbox providers are rejected.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "domain"
                ],
                "properties": {
                  "domain": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Domain claimed (pending verification)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrgDomain"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or public domain, or already added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Organization not found or access denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/domains/{domainId}": {
      "patch": {
        "operationId": "organizationsOrganizationIdDomainsDomainIdPatch",
        "x-org-permission": "org:domains:manage",
        "summary": "Update a claimed domain's login policy",
        "description": "Toggle capture/auto-join/enforce-SSO. Requires org owner or admin. Enforcing SSO requires attaching one of the org's SSO connections.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "domainId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateOrgDomainRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Domain updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrgDomain"
                }
              }
            }
          },
          "400": {
            "description": "Invalid update (e.g. unknown SSO connection)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Domain or organization not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "organizationsOrganizationIdDomainsDomainIdDelete",
        "x-org-permission": "org:domains:manage",
        "summary": "Remove a claimed domain",
        "description": "Requires org owner or admin. Removes the claim and its policy.",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "domainId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Domain removed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Domain or organization not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/organizations/{organizationId}/domains/{domainId}/verify": {
      "post": {
        "operationId": "organizationsOrganizationIdDomainsDomainIdVerifyPost",
        "x-org-permission": "org:domains:manage",
        "summary": "Check DNS and verify the domain now",
        "description": "Looks up the verification TXT record immediately. Requires org owner or admin. 409 when another organization already holds the verified claim.\n",
        "tags": [
          "Organizations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "domainId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Verification attempted; see status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrgDomainVerifyResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Domain or organization not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Another organization holds the verified claim for this domain",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/system-entities": {
      "get": {
        "operationId": "systemEntitiesGet",
        "x-permission": "tables:read",
        "summary": "List available system entities",
        "description": "Returns metadata about system entities (users, groups) that can be referenced from table fields. These are distinct from user-created tables and cannot be modified.",
        "tags": [
          "System Entities"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of system entities with their schemas",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SystemEntity"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/system-entities/{entityId}/items": {
      "get": {
        "operationId": "systemEntitiesEntityIdItemsGet",
        "x-permission": "tables:read",
        "summary": "Get items for a system entity",
        "description": "Returns the items (users or groups) of a system entity, for displaying reference values and for browsing the read-only system tables. A `users` item is one of the workspace's people, present or former, with `id`, `name`, `email` and `status` (`KnownWorkspacePersonStatus`); a picker offers only the `active` ones. A `groups` item is one active group, with `id`, `name` and `description`. The rows are those of the entity's `sqlTable` view.",
        "tags": [
          "System Entities"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "entityId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "users",
                "groups"
              ]
            },
            "description": "The system entity ID"
          }
        ],
        "responses": {
          "200": {
            "description": "List of items",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TableItem"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "System entity not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups": {
      "get": {
        "operationId": "groupsGet",
        "x-permission": "groups:read",
        "summary": "List groups in current workspace",
        "description": "Returns all groups in the user's current workspace",
        "tags": [
          "Groups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "includeInactive",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Include inactive groups"
          }
        ],
        "responses": {
          "200": {
            "description": "List of groups",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Group"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "groupsPost",
        "x-permission": "groups:manage",
        "summary": "Create a new group",
        "description": "Creates a new group in the user's current workspace. Requires admin or owner role.",
        "tags": [
          "Groups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateGroupRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Group created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                }
              }
            }
          },
          "400": {
            "description": "Group with this name already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups/{groupId}": {
      "get": {
        "operationId": "groupsGroupIdGet",
        "x-permission": "groups:read",
        "summary": "Get group details",
        "tags": [
          "Groups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Group details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Group not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "groupsGroupIdPatch",
        "x-permission": "groups:manage",
        "summary": "Update a group",
        "description": "Update group name, description, or active status. Requires admin or owner role.",
        "tags": [
          "Groups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateGroupRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Group updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Group not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "groupsGroupIdDelete",
        "x-permission": "groups:manage",
        "summary": "Delete a group",
        "description": "Permanently deletes a group and all memberships. Requires admin or owner role.",
        "tags": [
          "Groups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Group deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Group not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups/{groupId}/members": {
      "get": {
        "operationId": "groupsGroupIdMembersGet",
        "x-permission": "groups:read",
        "summary": "List group members",
        "tags": [
          "Groups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of group members",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/GroupMember"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Group not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "groupsGroupIdMembersPost",
        "x-permission": "groups:manage",
        "summary": "Add member to group",
        "description": "Adds a user to the group. Requires admin or owner role.",
        "tags": [
          "Groups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddGroupMemberRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Member added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GroupMember"
                }
              }
            }
          },
          "400": {
            "description": "User is already a member of this group",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Group or user not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups/{groupId}/members/{userId}": {
      "delete": {
        "operationId": "groupsGroupIdMembersUserIdDelete",
        "x-permission": "groups:manage",
        "summary": "Remove member from group",
        "description": "Removes a user from the group. Requires admin or owner role.",
        "tags": [
          "Groups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Member removed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Group or membership not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups/{groupId}/effective-permissions": {
      "get": {
        "operationId": "groupsGroupIdEffectivePermissionsGet",
        "x-permission": "permissions:manage",
        "summary": "What each member of a group can do on one table",
        "description": "Answers \"what can a member of group X do in table Y\" for whoever configures roles (issue 49972328dacb). Roles here attach to members and tokens, never to a group, so a group has no permissions of its own: the answer is each active member's effective access on the table — their base role and assigned roles, the record actions they hold, their row scope for each verb and the fields kept from them — plus the records shared with the group as a whole. A group with no members answers with an empty list, which is itself the fact a demo builder needs to know.\n\nRead-only and about other people, so it needs `permissions:manage` rather than the caller's own `/me/permissions` freedom. It resolves the same snapshots enforcement uses; nothing here is an authorization input.",
        "tags": [
          "Groups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tableId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "The table the answer is about."
          }
        ],
        "responses": {
          "200": {
            "description": "Each member's effective access on the table, and the group's shares",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GroupEffectivePermissions"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Group or table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/me": {
      "get": {
        "operationId": "meGet",
        "summary": "Who I am in the current workspace",
        "description": "The caller's identity, the workspace the request acts in, and their membership role there (display only; permissions are `/me/permissions`). Ungated for the same reason as `/me/permissions`: it is a fact about the caller. It is part of the workspace API surface, so an integration, an MCP client and a hosted site (through `/_api/me`, @tessule/client's `me()`) can each ask who they act as.",
        "tags": [
          "Authentication"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The caller in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceMe"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/me/permissions": {
      "get": {
        "operationId": "mePermissionsGet",
        "summary": "Get my effective permissions in the current workspace",
        "description": "Returns the caller's permission snapshot: effective actions (base role union any assigned roles), per-table record scopes for private tables, and field restrictions. Intended for UI gating — enforcement always happens server-side.",
        "tags": [
          "Authentication"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Effective permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyPermissions"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/me/active-group": {
      "get": {
        "operationId": "meActiveGroupGet",
        "summary": "Get my active group (which group's arrangement I see)",
        "description": "The caller's own presentation preference, plus the groups they could choose. Ungated for the same reason as `/me/permissions`: it is a fact about the caller and acts only on their own resource. In particular it is NOT `groups:read` — an ordinary member must be able to pick their own arrangement without being able to enumerate the workspace's groups.\n\nThis decides ARRANGEMENT ONLY — which home page, record layout and default list view resolve when more than one could apply. It is never an authorization input: the caller keeps seeing every record shared with every group they belong to, whichever one is active.",
        "tags": [
          "Authentication"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The effective active group and the caller's groups",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyActiveGroup"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "meActiveGroupPut",
        "summary": "Choose my active group",
        "description": "Persists the choice as the caller's default for this workspace, so the arrangement survives a reload and a new device. Self-scoped, and stored per (user, workspace) because groups are workspace-scoped.\n\n400 for a group the caller does not belong to: the choice is theirs to make among their own groups, and accepting any other would make this an oracle for the workspace's group ids.",
        "tags": [
          "Authentication"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetActiveGroupRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The stored selection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyActiveGroup"
                }
              }
            }
          },
          "400": {
            "description": "Not a group this caller belongs to",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/roles": {
      "get": {
        "operationId": "rolesGet",
        "x-permission": "workspace:members:read",
        "summary": "List roles in current workspace",
        "description": "Returns all roles (system + custom) with their action grants",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of roles",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Role"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "rolesPost",
        "x-permission": "permissions:manage",
        "summary": "Create a custom role",
        "description": "Creates a workspace-defined role with an explicit set of action grants",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRoleRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Role created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Role"
                }
              }
            }
          },
          "400": {
            "description": "Invalid role definition (unknown action, bad scope)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "A role with this name already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/roles/{roleId}": {
      "get": {
        "operationId": "rolesRoleIdGet",
        "x-permission": "workspace:members:read",
        "summary": "Get a role",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Role details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Role"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Role not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "rolesRoleIdPatch",
        "x-permission": "permissions:manage",
        "summary": "Update a custom role",
        "description": "Updates name, description, action grants, or record scopes. System roles cannot be modified.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRoleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Role updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Role"
                }
              }
            }
          },
          "400": {
            "description": "Invalid update (unknown action, or role is a system role)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Role not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A role with this name already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "rolesRoleIdDelete",
        "x-permission": "permissions:manage",
        "summary": "Delete a custom role",
        "description": "Deletes a workspace-defined role and its assignments. System roles cannot be deleted.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Role deleted"
          },
          "400": {
            "description": "System roles cannot be deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Role not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/roles/{roleId}/assignments": {
      "get": {
        "operationId": "rolesRoleIdAssignmentsGet",
        "x-permission": "workspace:members:read",
        "summary": "List principals assigned to a role",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Role assignments",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RoleAssignment"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Role not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "rolesRoleIdAssignmentsPost",
        "x-permission": "permissions:manage",
        "summary": "Assign a role to a principal",
        "description": "Assigns the role to a workspace member (by userId) or an API token. A principal may hold several roles; permissions are the union.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssignRoleRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Role assigned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoleAssignment"
                }
              }
            }
          },
          "400": {
            "description": "Invalid principal (not a member of this workspace, or both/neither principal fields set)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Role not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Principal already has this role",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/roles/{roleId}/assignments/{assignmentId}": {
      "delete": {
        "operationId": "rolesRoleIdAssignmentsAssignmentIdDelete",
        "x-permission": "permissions:manage",
        "summary": "Remove a role assignment",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "assignmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Assignment removed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Assignment not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/roles/{roleId}/fields": {
      "get": {
        "operationId": "rolesRoleIdFieldsGet",
        "x-permission": "workspace:members:read",
        "summary": "List a role's field grants",
        "description": "Every private-field grant this role carries, one row per granted field. The audit surface for field masking: a field absent from this list is not granted through this role. Grants are set (and removed) one field at a time via PUT /roles/{roleId}/fields/{fieldId}.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The role's field grants",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RoleFieldGrant"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Role not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/roles/{roleId}/fields/{fieldId}": {
      "put": {
        "operationId": "rolesRoleIdFieldsFieldIdPut",
        "x-permission": "permissions:manage",
        "summary": "Set a role's grant on a governed field",
        "description": "Grants (or revokes) read, update and create access to a field for this role. The first grant row on a field that is not `private` GOVERNS it: every role without a grant row then loses the field, so a grant that denies one role something is written as grants to the roles that keep it. All three false removes the grant row entirely, and the last row removed on a non-private field opens it again.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "The three bits the role gets on the field; one left out is false.",
                "properties": {
                  "canRead": {
                    "description": "Principals with this role may read the field's value.",
                    "type": "boolean"
                  },
                  "canUpdate": {
                    "description": "Principals with this role may change the field's value on an existing record.",
                    "type": "boolean"
                  },
                  "canCreate": {
                    "description": "Principals with this role may set the field when creating a record. Left out, it follows `canUpdate`, which is what every grant meant before the bit existed.",
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Field grant updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "The grant as stored, with every bit stated.",
                  "required": [
                    "roleId",
                    "fieldId",
                    "canRead",
                    "canUpdate",
                    "canCreate"
                  ],
                  "properties": {
                    "roleId": {
                      "description": "The role the grant is on.",
                      "type": "string"
                    },
                    "fieldId": {
                      "description": "The field the grant is on.",
                      "type": "string"
                    },
                    "canRead": {
                      "description": "Whether the role may read the field.",
                      "type": "boolean"
                    },
                    "canUpdate": {
                      "description": "Whether the role may change the field on an existing record.",
                      "type": "boolean"
                    },
                    "canCreate": {
                      "description": "Whether the role may set the field on a new record.",
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Role or field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/roles/{roleId}/metadata-tables": {
      "get": {
        "operationId": "rolesRoleIdMetadataTablesGet",
        "x-permission": "permissions:manage",
        "summary": "List a role's metadata-table grants",
        "description": "The metadata tables this role may write, with the bits it holds on each. A metadata table a role holds no grant on is absent: the baseline member and reader roles hold none. A baseline admin holds create and delete on every metadata table without a grant.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "description": "The role's id.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The role's grants, one per metadata table.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RoleMetadataGrant"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The role or the metadata table was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/roles/{roleId}/metadata-tables/{metadataTableId}": {
      "put": {
        "operationId": "rolesRoleIdMetadataTablesMetadataTableIdPut",
        "x-permission": "permissions:manage",
        "summary": "Set a role's grant on a metadata table",
        "description": "Grants (or revokes) creating, updating and deleting rows of one metadata table to this role. A grant is one check of several: the writer must also hold the record action, be able to edit the host record and field, the field must be covered, and an append-only table refuses every update. All three false removes the grant. An editor may grant only what they hold themselves, unless they are a baseline admin (403 `METADATA_GRANT_WIDENS`).",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "description": "The role's id.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "metadataTableId",
            "in": "path",
            "required": true,
            "description": "The metadata table's backing table id (`tableId` on the declaration).",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RoleMetadataGrantRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The grant as stored, every bit stated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoleMetadataGrant"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The role or the metadata table was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "rolesRoleIdMetadataTablesMetadataTableIdDelete",
        "x-permission": "permissions:manage",
        "summary": "Remove a role's grant on a metadata table",
        "description": "The role then holds nothing on the metadata table. Removing a grant that is not there is not an error.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "description": "The role's id.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "metadataTableId",
            "in": "path",
            "required": true,
            "description": "The metadata table's backing table id (`tableId` on the declaration).",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The grant is gone."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The role or the metadata table was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/roles/{roleId}/row-rules": {
      "get": {
        "operationId": "rolesRoleIdRowRulesGet",
        "x-permission": "workspace:members:read",
        "summary": "List a role's row rules",
        "description": "Every row rule this role carries, across tables and verbs. The audit surface for row visibility beside the field grants: a table and verb with no rule on any role is open, one with rules on other roles but not this one is closed to this role's principals.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The role's row rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RowRule"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Role not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "rolesRoleIdRowRulesPost",
        "x-permission": "permissions:manage",
        "summary": "Add a row rule to a role",
        "description": "Adds a rule granting the role's principals `verb` on the records of `tableId` that match `filter`. The filter is checked against the table's fields as a saved view's would be; the current-user and current-groups tokens resolve per reader. The caller must hold unrestricted read access to the table (403 otherwise: nobody grants rows they cannot see). A system role cannot carry rules (400). The first rule on a table and verb governs it; the response is the stored rule.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRowRuleRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The rule as stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RowRule"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Role or table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/roles/{roleId}/row-rules/{ruleId}": {
      "put": {
        "operationId": "rolesRoleIdRowRulesRuleIdPut",
        "x-permission": "permissions:manage",
        "summary": "Replace a row rule's filter",
        "description": "Replaces the filter of one rule, checked as on creation. The same unrestricted-read requirement on the rule's table applies.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRowRuleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rule as stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RowRule"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Role or rule not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "rolesRoleIdRowRulesRuleIdDelete",
        "x-permission": "permissions:manage",
        "summary": "Delete a row rule",
        "description": "Removes the rule. Removing the last rule on a table and verb opens that table for the verb again: every principal with the verb's action sees every record, as before the first rule. Because that can widen access, the caller must read the rule's table without restriction (403 otherwise), exactly as when adding a rule.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "roleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Rule deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Role or rule not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/permissions/effective": {
      "get": {
        "operationId": "permissionsEffectiveGet",
        "x-permission": "permissions:manage",
        "summary": "What one member can do on one table, across all their roles",
        "description": "Answers \"what can this person do in this table\" for whoever configures roles: the union of every role they hold, as enforcement sees it. For each verb it says whether the table is governed there and, if so, every row rule that grants them records (with the role it comes from, and a legacy scope shown as the `ownedBy` filter it compiles to); otherwise the row scope that applies. Beside that, the record actions they hold, the fields kept from them, and whether they are a baseline admin, to whom rules and field checks do not apply. Computed from the same permission snapshot enforcement resolves, at the workspace's current permissions version, so it is what the member's next request gets. Read-only and about another person, so it needs `permissions:manage`; `GET /me/permissions` is the caller's own.",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12
            },
            "description": "The member the answer is about, by user id; must be an active member of this workspace."
          },
          {
            "name": "tableId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "The table the answer is about."
          }
        ],
        "responses": {
          "200": {
            "description": "The member's effective access on the table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MemberEffectivePermissions"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The member is not an active member of this workspace, or the table does not exist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/permissions/explain": {
      "post": {
        "operationId": "permissionsExplainPost",
        "x-permission": "permissions:manage",
        "x-replica-reads": true,
        "summary": "Explain why a principal may or may not reach a record",
        "description": "Answers \"why can (or can't) this principal read, update or delete this record\" for whoever configures roles: the row rules of their roles the record satisfies, the legacy scope or record share that grants it, or nothing. Computed from the same permission snapshot enforcement resolves, at the workspace's current permissions version, so the answer is what the next request would get. The record is loaded through the CALLER's own read access: a record the caller cannot read is a 404, which keeps the endpoint from confirming hidden ids. A baseline admin reads every row, so an admin can ask about any record. The principal must belong to this workspace (404 otherwise).",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PermissionExplainRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The explanation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PermissionExplanation"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table, record or principal not found, or the record is outside the caller's read access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/billing/webhooks/{provider}": {
      "post": {
        "operationId": "billingWebhooksProviderPost",
        "summary": "Receive a payment-provider webhook",
        "description": "Ingress for signed provider events (payment settled, payment failed, card stored or removed, refund, dispute). Public by design: the credential is the provider's HMAC signature over the raw body, verified against the shared signing secret before anything is read. An unverifiable request gets a uniform 400 with no detail.\nThese events are the SOURCE OF TRUTH for asynchronous outcomes — the browser redirect after hosted card capture is only a hint and is never trusted. Delivery is at-least-once, so processing is idempotent on the provider's event id: a redelivery is recorded as a duplicate and still answers 200. Always 200 on a verified event, even one that fails to process, because a non-2xx makes the provider retry forever and a poison event would then block everything behind it.",
        "tags": [
          "Billing"
        ],
        "security": [],
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "description": "The provider whose signing secret to verify against, e.g. 'stripe'.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "The provider's raw event payload. Read as bytes — the signature covers the exact body.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verified and acknowledged",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingWebhookAck"
                }
              }
            }
          },
          "400": {
            "description": "Signature verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Unknown provider, or payments are not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/hooks/mirrors/{workspaceId}/{connectionId}/{token}": {
      "post": {
        "operationId": "hooksMirrorsWorkspaceIdConnectionIdTokenPost",
        "summary": "Push changes to a mirrored table's source connection",
        "description": "Ingress for a source that pushes its changes instead of (or as well as) being polled. Public by design: the credential is the unguessable URL token issued for the inbound connection, stored only as a hash and checked before the body is read. An unknown workspace or connection, a wrong token, or a connection that takes no pushes all answer the same 404. The body is the source's own payload, read as raw bytes so the connection's adapter can verify the source's signature. Accepted changes are queued and applied by the next sync cycle, usually within a minute.",
        "tags": [
          "Mirrors"
        ],
        "security": [],
        "parameters": [
          {
            "name": "workspaceId",
            "in": "path",
            "required": true,
            "description": "The workspace that owns the inbound connection.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "description": "The inbound connection the source pushes to.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "token",
            "in": "path",
            "required": true,
            "description": "The push token issued for the connection.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "The source's change payload, in the shape its adapter reads. Sent as JSON.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted and queued for the next sync cycle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MirrorPushResult"
                }
              }
            }
          },
          "400": {
            "description": "The connection's adapter could not read the payload, or its signature did not verify.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such connection, or the token does not match; every mismatch is the same answer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "The payload is larger than 256 KiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "415": {
            "description": "The payload is not JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/approval-rules": {
      "get": {
        "operationId": "approvalRulesGet",
        "x-permission": "approvals:manage",
        "summary": "List approval rules",
        "description": "Every approval rule in the workspace. Rules name approvers and shape who can change data, so reading them sits at the same admin tier as managing them — ordinary members learn which rule intercepted their write from the 409 body and from the pending change itself.",
        "tags": [
          "Approvals"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Restrict to rules on one table."
          }
        ],
        "responses": {
          "200": {
            "description": "Approval rules in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ApprovalRule"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "approvalRulesPost",
        "x-permission": "approvals:manage",
        "summary": "Create an approval rule",
        "description": "The table must exist in this workspace, every condition field must exist on it, and every approver must be an active workspace member or an existing group. Rules name approvers, not powers — there is no privilege lattice to check at save time; the apply-time re-validation and the requester ceiling are what keep a rule from becoming an escalation channel.",
        "tags": [
          "Approvals"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateApprovalRuleRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Rule created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApprovalRule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "A rule with this name already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/approval-rules/{ruleId}": {
      "get": {
        "operationId": "approvalRulesRuleIdGet",
        "x-permission": "approvals:manage",
        "summary": "Get an approval rule",
        "tags": [
          "Approvals"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rule details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApprovalRule"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Rule not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "approvalRulesRuleIdPut",
        "x-permission": "approvals:manage",
        "summary": "Update an approval rule",
        "tags": [
          "Approvals"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateApprovalRuleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rule updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApprovalRule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Rule not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A rule with this name already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "approvalRulesRuleIdDelete",
        "x-permission": "approvals:manage",
        "summary": "Delete an approval rule",
        "description": "Deletes the rule and cancels any pending changes it was holding — a request nobody can decide any more must not sit open forever.",
        "tags": [
          "Approvals"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Rule deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Rule not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/pending-changes": {
      "get": {
        "operationId": "pendingChangesGet",
        "x-permission": "approvals:request",
        "summary": "List pending changes",
        "description": "The approvals inbox. `scope=for_me` lists changes this principal may decide (named by the rule, row visible); `scope=by_me` lists their own requests. Field values in every row are masked through the CALLER's snapshot.",
        "tags": [
          "Approvals"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "for_me",
                "by_me"
              ],
              "default": "for_me"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Filter by lifecycle status (see KnownPendingChangeStatus). Defaults to `pending`; pass `all` for the full history."
          },
          {
            "name": "tableId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "itemId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "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": "Pending changes (newest first)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PendingChange"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "pendingChangesPost",
        "x-permission": "approvals:request",
        "summary": "Request approval for a record change",
        "description": "Creates a pending change for a write an approval rule intercepted. The patch must match a rule (otherwise just do the write) and is capped by the requester's own ceiling: records:update on the row plus field-write permission for every proposed field, and the patch is validated against the table schema now so an invalid proposal cannot be parked for someone else to approve.",
        "tags": [
          "Approvals"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePendingChangeRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Pending change created; approvers have been notified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingChange"
                }
              }
            }
          },
          "400": {
            "description": "No approval rule matches this change (make the write directly), or the proposed data failed validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The requester may not write one of the proposed fields, or may not update the row",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table or record not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The matched rule already has an open request on this record (code APPROVAL_ALREADY_PENDING, with pendingChangeId), or another open request already proposes one of the same fields (code APPROVAL_FIELDS_ALREADY_PENDING, with pendingChangeId and fields). Open requests on one record run in parallel per rule but must propose disjoint field sets. Or the table is mirrored: code `MIRRORED_TABLE_READ_ONLY` (its records are created, deleted and restored only by its sync) or `MIRRORED_FIELD_READ_ONLY` (the write changes mirrored fields, named in `details.fields`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/pending-changes/{pendingChangeId}": {
      "get": {
        "operationId": "pendingChangesPendingChangeIdGet",
        "x-permission": "approvals:request",
        "summary": "Get a pending change",
        "description": "Visible to the requester and to the rule's approvers. Field values are masked through the CALLER's snapshot — an approver may see fewer fields than were proposed (hiddenFieldCount).",
        "tags": [
          "Approvals"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "pendingChangeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pending change detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingChange"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found (or not visible to this principal)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/pending-changes/{pendingChangeId}/decision": {
      "post": {
        "operationId": "pendingChangesPendingChangeIdDecisionPost",
        "x-permission": "approvals:decide",
        "summary": "Approve or decline a pending change",
        "description": "The decider must be named by the rule (holding approvals:decide alone grants nothing) and must be able to see the row — but NOT to write the proposed fields: an approver authorizes, they do not author. Approving applies the change as the system, attributed to the requester, with full re-validation. A rejected apply leaves status=failed with applyError — the decision stands, the outcome is recorded separately.",
        "tags": [
          "Approvals"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "pendingChangeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DecidePendingChangeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Decision recorded (check status/applyError for the apply outcome)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingChange"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not a listed approver, cannot see the row, or self-approval (the requester is not named as an approver by the rule)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or not visible to this principal)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Already decided, or the record changed since the request was made and acknowledgeStale was not set (code STALE_APPROVAL)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/pending-changes/{pendingChangeId}/cancel": {
      "post": {
        "operationId": "pendingChangesPendingChangeIdCancelPost",
        "x-permission": "approvals:request",
        "summary": "Withdraw your own pending change",
        "tags": [
          "Approvals"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "pendingChangeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pending change cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingChange"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Only the requester may cancel a request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or not visible to this principal)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Already decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/secrets": {
      "get": {
        "operationId": "secretsGet",
        "x-permission": "secrets:manage",
        "summary": "List workspace secrets (metadata only)",
        "tags": [
          "Secrets"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Secret metadata — values are never returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkspaceSecret"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "secretsPost",
        "x-permission": "secrets:manage",
        "summary": "Create a workspace secret",
        "description": "Stores a named secret encrypted at rest. The value cannot be read back — rotate it with PUT /secrets/{name} if lost.",
        "tags": [
          "Secrets"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorkspaceSecretRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Secret stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceSecret"
                }
              }
            }
          },
          "400": {
            "description": "Invalid name/value, secret limit reached, or secret storage not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "A secret with this name already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/secrets/{name}": {
      "put": {
        "operationId": "secretsNamePut",
        "x-permission": "secrets:manage",
        "summary": "Rotate a workspace secret's value",
        "tags": [
          "Secrets"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RotateWorkspaceSecretRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Secret rotated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceSecret"
                }
              }
            }
          },
          "400": {
            "description": "Invalid value or secret storage not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Secret not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "secretsNameDelete",
        "x-permission": "secrets:manage",
        "summary": "Delete a workspace secret",
        "description": "Flows referencing a deleted secret render it as empty on their next run — disable or update them first.",
        "tags": [
          "Secrets"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Secret deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Secret not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/warehouse-exports": {
      "get": {
        "operationId": "warehouseExportsGet",
        "x-permission": "exports:manage",
        "summary": "List the workspace's warehouse exports",
        "description": "Every warehouse export in the workspace, oldest first, with what the organization's plan and settings allow. Exports stay listed while the feature is switched off, so an admin can see and delete them.",
        "tags": [
          "WarehouseExports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The exports and what the plan allows",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WarehouseExportList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "warehouseExportsPost",
        "x-permission": "exports:manage",
        "summary": "Create a warehouse export",
        "description": "Configures a destination for the workspace's records and stage history. An export reads every record and field of the tables it names, whoever can see them in the app, less the fields it excludes. For a `customerS3` destination the response carries the `externalId` to put in the IAM role's trust policy; the role must allow `s3:PutObject` on the bucket and prefix. For a `hosted` destination the response carries the reader role the warehouse assumes; the role is created once the reader's principal and external id are both set, here or later with a PATCH. Refused with 403 `WAREHOUSE_EXPORT_DISABLED` unless the organization has switched warehouse export on and its plan includes it, and with 403 `HOSTED_EXPORT_UNAVAILABLE` for a hosted destination unless `availability.hostedAvailable` is true.",
        "tags": [
          "WarehouseExports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWarehouseExportRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The export, as stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WarehouseExport"
                }
              }
            }
          },
          "400": {
            "description": "A table does not exist or is a SQL view (`UNKNOWN_TABLE`, `NOT_A_TABLE`), an excluded field is not on its table (`UNKNOWN_FIELD`), a table is named twice (`DUPLICATE_TABLE`), the interval is shorter than the plan allows (`INTERVAL_BELOW_PLAN_MINIMUM`), or the workspace already holds as many exports as the plan allows (`WAREHOUSE_EXPORT_LIMIT`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "Another export in the workspace already has this name (`NAME_TAKEN`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/warehouse-exports/{exportId}": {
      "parameters": [
        {
          "name": "exportId",
          "in": "path",
          "required": true,
          "description": "The export's id.",
          "schema": {
            "type": "string",
            "minLength": 12,
            "maxLength": 12,
            "pattern": "^[0-9a-f]{12}$"
          }
        }
      ],
      "get": {
        "operationId": "warehouseExportsExportIdGet",
        "x-permission": "exports:manage",
        "summary": "Read one warehouse export",
        "tags": [
          "WarehouseExports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The export",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WarehouseExport"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "warehouseExportsExportIdPatch",
        "x-permission": "exports:manage",
        "summary": "Change a warehouse export",
        "description": "Changes the name, tables, interval, enabled state or, for a hosted destination, the warehouse principal allowed to read it. The bucket, role and region of a `customerS3` destination are fixed: to send elsewhere, create a new export and delete this one, so the new destination starts from a full snapshot. Switching an export on is refused with 403 `WAREHOUSE_EXPORT_DISABLED` unless the organization has warehouse export on and its plan includes it; switching one off is always allowed.",
        "tags": [
          "WarehouseExports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWarehouseExportRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The export, as stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WarehouseExport"
                }
              }
            }
          },
          "400": {
            "description": "Same refusals as creating one, or reader settings sent for a `customerS3` destination (`NOT_HOSTED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Another export in the workspace already has this name (`NAME_TAKEN`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "warehouseExportsExportIdDelete",
        "x-permission": "exports:manage",
        "summary": "Delete a warehouse export",
        "description": "Stops the export and forgets its configuration. Files already written to the destination stay where they are.",
        "tags": [
          "WarehouseExports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "operationId": "webhooksGet",
        "x-permission": "webhooks:manage",
        "summary": "List the workspace's webhook subscriptions",
        "description": "Every outbound webhook subscription in the workspace, newest first. The signing secret is never included; it is shown once, when the subscription is created or its secret rotated.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The subscriptions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WebhookSubscription"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "webhooksPost",
        "x-permission": "webhooks:manage",
        "summary": "Subscribe a URL to a table's record events",
        "description": "Registers an HTTPS endpoint that receives a signed `WebhookEvent` for every matching event on one table. The subscription runs as the caller: each delivery carries only the records and fields the caller can read at the time of delivery, and stops once they can no longer read the table. The URL is checked when the subscription is created and again on every delivery; addresses inside private networks are refused. The response carries the signing secret, which is never shown again — store it now, or rotate it later with `POST /webhooks/{webhookId}/rotate-secret`. A delivery the endpoint answers with 408, 429 or a 5xx, or that cannot connect, is retried after 1 minute, 5 minutes, 30 minutes, 2 hours and then every 8 hours, for up to 3 days; a 429's `Retry-After` (up to 8 hours) sets the wait. Any other 4xx is final. A subscription whose deliveries have failed continuously for 3 days is switched off, and holders of `webhooks:manage` are notified.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookSubscriptionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Subscription created; the response is the only time the secret is shown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSubscriptionWithSecret"
                }
              }
            }
          },
          "400": {
            "description": "The URL is refused (not https, unresolvable, or a private address), a field in the allow-list does not exist on the table, the subscription limit is reached, or secret storage is not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The table does not exist in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/webhooks/{webhookId}": {
      "get": {
        "operationId": "webhooksWebhookIdGet",
        "x-permission": "webhooks:manage",
        "summary": "Read one webhook subscription",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "description": "The subscription's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The subscription (without its secret)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSubscription"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such subscription in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "webhooksWebhookIdPatch",
        "x-permission": "webhooks:manage",
        "summary": "Change a webhook subscription",
        "description": "Changes the URL, the events, the field allow-list or the description, or switches the subscription on or off. Switching it on clears its failure streak, including after it was switched off automatically. Only the fields present are changed. Changing the URL to a new address makes the subscription run as the caller from then on (`createdBy`), so deliveries carry what the caller can read; every other change leaves it running as before.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "description": "The subscription's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWebhookSubscriptionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The changed subscription",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSubscription"
                }
              }
            }
          },
          "400": {
            "description": "The new URL is refused, or a field in the allow-list does not exist on the table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such subscription in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "webhooksWebhookIdDelete",
        "x-permission": "webhooks:manage",
        "summary": "Delete a webhook subscription",
        "description": "Deletes the subscription and its delivery history. Deliveries still waiting to be sent are dropped.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "description": "The subscription's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Subscription deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such subscription in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/webhooks/{webhookId}/rotate-secret": {
      "post": {
        "operationId": "webhooksWebhookIdRotateSecretPost",
        "x-permission": "webhooks:manage",
        "summary": "Replace a webhook subscription's signing secret",
        "description": "Generates a new signing secret and returns it once. Deliveries sent from now on, including retries of earlier events, are signed with the new secret. Only the subscription's `createdBy` user may rotate it (403 `NOT_SUBSCRIPTION_PRINCIPAL` otherwise); another holder of `webhooks:manage` takes a subscription over by changing its URL.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "description": "The subscription's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The subscription with its new secret, shown only in this response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSubscriptionWithSecret"
                }
              }
            }
          },
          "400": {
            "description": "Secret storage is not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such subscription in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/webhooks/{webhookId}/deliveries": {
      "get": {
        "operationId": "webhooksWebhookIdDeliveriesGet",
        "x-permission": "webhooks:manage",
        "summary": "List a subscription's deliveries (newest first)",
        "description": "The delivery log: one entry per event sent (or due to be sent) to the subscription, with its status, attempts, and the last response code and error. The body that was signed is included only for the user it was built for (the subscription's `createdBy` when it was sent), since it carries what that user could read. Delivery history is kept for 30 days.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "description": "The subscription's id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only deliveries in this status (`pending`, `succeeded`, `failed` or `skipped`).",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "succeeded",
                "failed",
                "skipped"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1–200 (default 50).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "Return only deliveries whose `sequence` is lower than this — pass the previous page's `nextBefore` to read on.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of deliveries",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such subscription in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/webhooks/{webhookId}/deliveries/{deliveryId}/redeliver": {
      "post": {
        "operationId": "webhooksWebhookIdDeliveriesDeliveryIdRedeliverPost",
        "x-permission": "webhooks:manage",
        "summary": "Send a finished delivery again",
        "description": "Queues a delivery that has finished (succeeded, failed or skipped) to be sent again, with the same id, sequence and `Idempotency-Key`, so a receiver that already processed it can recognise the repeat. The record and field visibility are evaluated afresh as the subscription's creator, and the body is signed with the current secret.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "description": "The subscription's id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "deliveryId",
            "in": "path",
            "required": true,
            "description": "The delivery's id (also its `X-CRM-Delivery` header and `WebhookEvent.id`).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "The delivery is queued again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDelivery"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such subscription or delivery in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The delivery is still pending, or the subscription is switched off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integrations/connections": {
      "get": {
        "operationId": "integrationsConnectionsGet",
        "x-permission": "integrations:read",
        "summary": "List marketing-platform connections (metadata only)",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Connection metadata — credentials are never returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/IntegrationConnection"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "integrationsConnectionsPost",
        "x-permission": "integrations:manage",
        "summary": "Connect a marketing platform",
        "description": "Stores the provider API key encrypted at rest. The credential cannot be read back — rotate it with PUT if lost.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateIntegrationConnectionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Connection stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationConnection"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, connection limit reached, or secret storage not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "A connection with this name already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integrations/connections/{connectionId}": {
      "put": {
        "operationId": "integrationsConnectionsConnectionIdPut",
        "x-permission": "integrations:manage",
        "summary": "Rename a connection and/or rotate its credential",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateIntegrationConnectionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Connection updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationConnection"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or secret storage not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Connection not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A connection with this name already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "integrationsConnectionsConnectionIdDelete",
        "x-permission": "integrations:manage",
        "summary": "Delete a connection",
        "description": "Refused while audience syncs still reference it — delete those first, so no sync is silently orphaned.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Connection deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Connection not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Audience syncs still reference this connection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integrations/connections/{connectionId}/test": {
      "post": {
        "operationId": "integrationsConnectionsConnectionIdTestPost",
        "x-permission": "integrations:manage",
        "summary": "Verify a connection's credential against the provider",
        "description": "Makes one authenticated read-only call to the provider and records the outcome on the connection. Never returns credential material.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Probe completed — check `ok` for the result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationConnectionTestResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Connection not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Provider call quota reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integrations/connections/{connectionId}/audiences": {
      "get": {
        "operationId": "integrationsConnectionsConnectionIdAudiencesGet",
        "x-permission": "integrations:manage",
        "summary": "List the lists/audiences that exist on the provider side",
        "description": "Populates the audience picker when configuring a sync.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider-side audiences",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RemoteAudience"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Connection not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Provider call quota reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "The provider rejected the request or was unreachable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/audience-syncs": {
      "get": {
        "operationId": "integrationsAudienceSyncsGet",
        "x-permission": "integrations:read",
        "summary": "List audience syncs",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Configured syncs with their last-run state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AudienceSync"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "integrationsAudienceSyncsPost",
        "x-permission": "integrations:manage",
        "summary": "Activate a table or SQL view as a provider audience",
        "description": "The source table/view plus its email field is the audience definition — defined once here, activated into the provider. Membership is workspace-owned; the provider is told who belongs, never asked.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAudienceSyncRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sync created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AudienceSync"
                }
              }
            }
          },
          "400": {
            "description": "Unknown table, unknown field, or sync limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Connection not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integrations/audience-syncs/{syncId}": {
      "put": {
        "operationId": "integrationsAudienceSyncsSyncIdPut",
        "x-permission": "integrations:manage",
        "summary": "Update an audience sync",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "syncId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAudienceSyncRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sync updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AudienceSync"
                }
              }
            }
          },
          "400": {
            "description": "Unknown field",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Sync not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "integrationsAudienceSyncsSyncIdDelete",
        "x-permission": "integrations:manage",
        "summary": "Delete an audience sync",
        "description": "Deletes the sync and its ledger. Provider-side list membership is left exactly as it is — we never mass-remove people because a record was deleted.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "syncId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sync deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Sync not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integrations/audience-syncs/{syncId}/run": {
      "post": {
        "operationId": "integrationsAudienceSyncsSyncIdRunPost",
        "x-permission": "integrations:manage",
        "summary": "Run an audience sync now",
        "description": "Enqueues a run and returns immediately. This is the primary trigger — scheduled jobs are disabled in some deployments.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "syncId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Run enqueued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AudienceSyncRunAccepted"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Sync not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A run is already in flight for this sync",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/oauth/authorize": {
      "get": {
        "operationId": "oauthAuthorizeGet",
        "summary": "OAuth 2.0 authorization endpoint - redirects to login",
        "description": "Initiates OAuth 2.0 authorization code flow. Redirects user to login page.\nAfter successful login, redirects back to redirect_uri with authorization code.\n",
        "tags": [
          "OAuth"
        ],
        "security": [],
        "parameters": [
          {
            "name": "response_type",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "code"
              ]
            }
          },
          {
            "name": "client_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Client identifier (use 'mcp' for MCP clients)"
          },
          {
            "name": "redirect_uri",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "URI to redirect after authorization"
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque state value for CSRF protection"
          },
          {
            "name": "code_challenge",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "PKCE code challenge (recommended)"
          },
          {
            "name": "code_challenge_method",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "S256",
                "plain"
              ]
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Space-separated list of requested scopes. Omit it to receive the\nserver's default set. Scopes this server does not issue are dropped\nfrom the grant, so a request naming a mix of known and unknown\nscopes is narrowed to the known ones — but a request naming ONLY\nunknown scopes is refused with `invalid_scope` rather than issuing a\ntoken that grants nothing.\n"
          },
          {
            "name": "resource",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Protected resource URI (RFC 9728) — identifies which resource the client wants to access"
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to login page"
          },
          "400": {
            "description": "Invalid request parameters. The `error` field distinguishes them:\n`invalid_request` (missing/malformed parameter, or absent PKCE),\n`unsupported_response_type`, `invalid_client` (unknown client_id),\nor `invalid_scope` (none of the requested scopes are issued here).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/token": {
      "post": {
        "operationId": "oauthTokenPost",
        "summary": "OAuth 2.0 token endpoint - exchange code for access token",
        "tags": [
          "OAuth"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/OAuthTokenRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OAuthTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Access token issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthTokenResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid grant or request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid client credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/OAuthTooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "The database could not be reached, so no grant was decided: `error` is `temporarily_unavailable` (RFC 6749 §4.1.2.1) and a `Retry-After` header says how many seconds to wait. No token was issued; retry the same request then rather than discarding the refresh token or restarting authorization.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying the same request.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/register": {
      "post": {
        "operationId": "oauthRegisterPost",
        "summary": "OAuth 2.0 Dynamic Client Registration (RFC 7591)",
        "description": "Allows MCP clients to register themselves dynamically. Registering a `software_id` that already exists returns the stored client rather than replacing it: name and grants stand, and only loopback redirect URIs are added (a native client takes a new ephemeral port each run).",
        "tags": [
          "OAuth"
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OAuthClientRegistrationRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Client registered successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthClientRegistrationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid client metadata (`invalid_client_metadata`), or a redirect_uri outside the loopback interface (`invalid_redirect_uri`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/oauth/callback": {
      "get": {
        "operationId": "oauthCallbackGet",
        "summary": "OAuth callback - internal endpoint for login redirect",
        "description": "Handles redirect from login page, issues authorization code",
        "tags": [
          "OAuth"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "access_token",
            "in": "query",
            "required": false,
            "deprecated": true,
            "description": "Bearer token passed as a query parameter, for clients that reach this endpoint by browser navigation and cannot set headers. A token in a URL lands in access logs, browser history and Referer headers, so prefer the Authorization header with `response_mode=json`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workspace_id",
            "in": "query",
            "required": false,
            "description": "Workspace the user picked on the consent screen. Ignored when the grant is locked to a workspace by an RFC 8707 resource indicator.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "response_mode",
            "in": "query",
            "required": false,
            "description": "Set to `json` to receive the client redirect as a body instead of a 302, so the consent SPA can send the user's token in the Authorization header rather than the URL.",
            "schema": {
              "type": "string",
              "enum": [
                "json"
              ]
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "description": "Space-separated scopes the user ticked on the consent screen. The grant is narrowed to these, and only scopes the request offered (the `scopes` of `GET /oauth/authorize/info`) count — a name outside that list is ignored, never added. Omitted means every offered scope, which is what the screen selects by default; an empty value is a selection of nothing, not the default. A selection that leaves nothing is refused with `invalid_scope`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Client redirect returned as JSON (response_mode=json)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthCallbackRedirect"
                }
              }
            }
          },
          "302": {
            "description": "Redirect to client with authorization code"
          },
          "400": {
            "description": "Invalid state or session, or a scope selection that grants nothing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/tables": {
      "get": {
        "operationId": "tablesGet",
        "x-permission": "tables:read",
        "summary": "Get all data tables for current user",
        "tags": [
          "DataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of data tables",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DataTable"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesPost",
        "x-permission": "tables:manage",
        "summary": "Create a new data table",
        "tags": [
          "DataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDataTableRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Data table created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataTable"
                }
              }
            }
          },
          "400": {
            "description": "Invalid data, or a name that is not free: `code` is `TABLE_ALREADY_EXISTS` when a table already uses it, and `TABLE_NAME_RETAINED` when a deleted table, whose data is kept, still holds it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}": {
      "get": {
        "operationId": "tablesTableIdGet",
        "x-permission": "tables:read",
        "summary": "Get a specific data table with its schema",
        "tags": [
          "DataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Data table details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataTable"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "tablesTableIdPut",
        "x-permission": "tables:manage",
        "summary": "Update a data table",
        "description": "Changes a table's own settings — label, description, AI hint, record visibility, comments, searchability — without touching its fields. The response is the table's metadata; because a settings write never changes the fields, `fields` is left out unless `include=fields` asks for it (a two-string edit used to echo every field definition).",
        "tags": [
          "DataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "fields"
              ]
            },
            "description": "`fields` adds the table's field list to the response, the full shape `GET /tables/{tableId}` returns. Left out, the response carries the table's metadata only."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDataTableRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Data table updated. `fields` is present only when the request passed `include=fields`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataTable"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdDelete",
        "x-permission": "tables:manage",
        "summary": "Delete a data table",
        "description": "Deletes a table or SQL view. When reference fields or automation rules on other tables point at it, the delete is refused with 409 TABLE_HAS_INCOMING_REFERENCES listing them, because they stop resolving once it is gone; repeat the call with `force=true` to delete anyway. A SQL view that other views are built on is refused with 409 VIEW_HAS_DEPENDENTS whatever `force` says.",
        "tags": [
          "DataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "force",
            "in": "query",
            "required": false,
            "description": "Delete even though other tables reference this one. Send it only after showing the person the incomingReferences a refused delete listed.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Table deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Other tables reference this one (TABLE_HAS_INCOMING_REFERENCES, listed in incomingReferences; retry with force=true to delete anyway), or the table is a SQL view other views are built on (VIEW_HAS_DEPENDENTS) — drop those first Also returned when the table is mirrored and the change would alter a mirrored field, or break the sync (code `MIRRORED_FIELD_LOCKED`; `suggestion` says what to do instead).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableDeleteConflict"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/fields": {
      "get": {
        "operationId": "tablesTableIdFieldsGet",
        "x-permission": "tables:read",
        "summary": "Get all fields for a data table",
        "tags": [
          "TableFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of table fields",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TableField"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesTableIdFieldsPost",
        "x-permission": "fields:manage",
        "summary": "Add a field to a data table",
        "description": "Adds a field and its stored column. A name a deleted field still holds is refused with 400 `FIELD_NAME_RETAINED`: restore that field or delete its values permanently first (`GET /tables/{tableId}/deleted-fields`).",
        "tags": [
          "TableFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTableFieldRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Field added to table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableField"
                }
              }
            }
          },
          "400": {
            "description": "Invalid field data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The table is mirrored and the change would alter a mirrored field, or break the sync (code `MIRRORED_FIELD_LOCKED`; `suggestion` says what to do instead).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/fields/order": {
      "put": {
        "operationId": "tablesTableIdFieldsOrderPut",
        "x-permission": "fields:manage",
        "summary": "Set a table's default field order",
        "description": "Rewrites `displayOrder` across the table in one transaction, so the order `GET /tables/{tableId}/fields` returns — and with it the default column order of every grid, the field order of the record form, and the fallback order a saved view falls back to — becomes the order sent here.\n\nThis is deliberately NOT `PUT /tables/{tableId}/fields/{fieldId}` repeated. That endpoint is a full-replace that runs the field-update rules engine: it takes a table-level lock and can swap physical columns, drop constraints and rewrite data. Moving a field up one position must not be able to do any of that, and moving ten fields must not be ten of them. Nothing here touches the workspace's data schema — only the metadata row's position.\n\nOrdering is presentation, never permission: a field's position says nothing about who may read it, and this endpoint cannot hide a field from anyone.",
        "tags": [
          "TableFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReorderTableFieldsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The table's fields, in their new order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TableField"
                  }
                }
              }
            }
          },
          "400": {
            "description": "An id that is not a live field of this table, a duplicate id, or the table is a SQL view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/fields/{fieldId}": {
      "put": {
        "operationId": "tablesTableIdFieldsFieldIdPut",
        "x-permission": "fields:manage",
        "summary": "Update a table field",
        "tags": [
          "TableFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTableFieldRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Field updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableField"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The table is mirrored and the change would alter a mirrored field, or break the sync (code `MIRRORED_FIELD_LOCKED`; `suggestion` says what to do instead).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "tablesTableIdFieldsFieldIdPatch",
        "x-permission": "fields:manage",
        "summary": "Partially update a table field",
        "description": "Change only the properties you send — e.g. `{\"aiHint\": \"...\"}` to fix a field's AI hint — and leave every other one as it is. Properties left out keep their current value; properties sent replace it (`fieldConfig` is replaced whole, not deep-merged; `null` clears a nullable property; an empty string clears `description` / `aiHint`). The server merges the patch over the stored field and then runs exactly the `PUT` update path, so every rule the `PUT` enforces — type compatibility with existing data, flag transitions, the built-in-field lock, the immutable internal name — applies and fails with the same 400. An empty body is refused (400). The MCP `update_field` tool is this operation addressed by table and field name.",
        "tags": [
          "TableFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchTableFieldRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Field updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableField"
                }
              }
            }
          },
          "400": {
            "description": "Empty body, or the merged field fails the same validation as `PUT` (incompatible type change, data violates a new rule, …)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The table is mirrored and the change would alter a mirrored field, or break the sync (code `MIRRORED_FIELD_LOCKED`; `suggestion` says what to do instead).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdFieldsFieldIdDelete",
        "x-permission": "fields:manage",
        "summary": "Delete a table field",
        "description": "Removes the field from the table and keeps its values: the field is listed under `GET /tables/{tableId}/deleted-fields` until it is restored or its values are deleted permanently, and its name stays taken until then. Refused (409, `FieldInUseError`) while a lookup, rollup, formula, computed column, table constraint, stage requirement or SQL view still depends on it — the body lists every dependant so the caller can remove or change them and retry.",
        "tags": [
          "TableFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Field deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Other schema objects still depend on the field; nothing was changed. Also returned when the table is mirrored and the change would alter a mirrored field, or break the sync (code `MIRRORED_FIELD_LOCKED`; `suggestion` says what to do instead).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FieldInUseError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/deleted-fields": {
      "get": {
        "operationId": "tablesTableIdDeletedFieldsGet",
        "x-permission": "fields:manage",
        "summary": "List a table's deleted fields",
        "description": "Deleting a field removes it from the table but keeps its values (#1549). This lists the table's deleted fields, newest first, each with the definition it had when it was deleted. A deleted field can be restored (`POST /tables/{tableId}/deleted-fields/{deletedFieldId}/restore`) or its values deleted permanently (`DELETE /tables/{tableId}/deleted-fields/{deletedFieldId}`). Entries for fields deleted before deletions were recorded carry no definition: they can be deleted permanently but not restored.",
        "tags": [
          "TableFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The table's deleted fields",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DeletedField"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such table, or no such deleted field on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/deleted-fields/{deletedFieldId}/restore": {
      "post": {
        "operationId": "tablesTableIdDeletedFieldsDeletedFieldIdRestorePost",
        "x-permission": "fields:manage",
        "summary": "Restore a deleted field",
        "description": "Brings a deleted field back with the id and definition it had and the values it held; records created while it was deleted have no value (or its default). Its place in record layouts, its stage history and comments anchored to it return with it. What cannot be restored is reported in `adjustments` rather than refused: a required field whose values now include empty ones comes back optional, and a label field comes back as a plain field when the table has another label. Role grants on a private field are not restored: it comes back private. Refused with 409 when its name is now used by another field (`FIELD_NAME_TAKEN`), a table it references no longer exists (`REFERENCE_TARGET_GONE`), its definition was never recorded (`FIELD_DEFINITION_UNKNOWN`), or its values are gone (`RETAINED_COLUMN_MISSING`).",
        "tags": [
          "TableFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "deletedFieldId",
            "in": "path",
            "required": true,
            "description": "The deleted field's entry id, from the list.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The field is back on the table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestoreDeletedFieldResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such table, or no such deleted field on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The field cannot be restored; the code says why and nothing was changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/deleted-fields/{deletedFieldId}": {
      "delete": {
        "operationId": "tablesTableIdDeletedFieldsDeletedFieldIdDelete",
        "x-permission": "fields:manage",
        "summary": "Permanently delete a deleted field's values",
        "description": "The irreversible half of a field delete (#1549): drops the deleted field's stored values for good, after which its name is free for a new field. Refused (409, `FieldInUseError`) while a SQL view still reads them.",
        "tags": [
          "TableFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "deletedFieldId",
            "in": "path",
            "required": true,
            "description": "The deleted field's entry id, from the list.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted permanently"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such table, or no such deleted field on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A SQL view still reads the values; nothing was changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FieldInUseError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/metadata-tables": {
      "get": {
        "operationId": "tablesTableIdMetadataTablesGet",
        "x-permission": "tables:read",
        "summary": "List a table's metadata tables",
        "description": "The metadata tables declared on this host table, in name order. A metadata table's rows are each about one field of one of the host's records: where a value was read on a source document and how sure the reader was, say. Metadata describes fields that exist; it is never a substitute for a missing field.",
        "tags": [
          "MetadataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "The host table's id."
          }
        ],
        "responses": {
          "200": {
            "description": "The host's metadata tables.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MetadataTable"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesTableIdMetadataTablesPost",
        "x-permission": "tables:manage",
        "summary": "Declare a metadata table on a table",
        "description": "Creates a metadata table on this host: a backing table named `_meta_<host>_<name>`, in the platform's reserved namespace, with the locked system columns `_record` (the host record) and `_field` (the host field a row is about), the declared fields, and one row per record and field. It runs as a one-entry schema plan (`addMetadata`), so a refusal comes back as teaching plan issues. Needs `fields:manage` as well as `tables:manage`.",
        "tags": [
          "MetadataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "The host table's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MetadataTableCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The metadata table was declared.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetadataTable"
                }
              }
            }
          },
          "400": {
            "description": "The declaration was refused (code `METADATA_DECLARATION_REFUSED`); `issues` says why, with a fix for each.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetadataTableRefusal"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/metadata-tables/{metadataName}": {
      "get": {
        "operationId": "tablesTableIdMetadataTablesMetadataNameGet",
        "x-permission": "tables:read",
        "summary": "Read one metadata table",
        "tags": [
          "MetadataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "The host table's id."
          },
          {
            "name": "metadataName",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63,
              "pattern": "^[a-z][a-z0-9_]*$"
            },
            "description": "The metadata table's API name, unique on its host."
          }
        ],
        "responses": {
          "200": {
            "description": "The metadata table.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetadataTable"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "tablesTableIdMetadataTablesMetadataNamePatch",
        "x-permission": "tables:manage",
        "summary": "Change a metadata table's label, description, editability, summary field or coverage",
        "description": "Changes what the declaration says. Narrowing the coverage keeps the rows about a field it drops: they stay readable, marked out of coverage, until purged. Its fields are changed through the ordinary field endpoints on the backing table (`tableId` in the response).",
        "tags": [
          "MetadataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "The host table's id."
          },
          {
            "name": "metadataName",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63,
              "pattern": "^[a-z][a-z0-9_]*$"
            },
            "description": "The metadata table's API name, unique on its host."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MetadataTableUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The metadata table as changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetadataTable"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdMetadataTablesMetadataNameDelete",
        "x-permission": "tables:manage",
        "summary": "Delete a metadata table",
        "description": "Removes the declaration and deletes its backing table, as deleting a table does: the rows are kept with the table until it is purged, and its name stays taken until then.",
        "tags": [
          "MetadataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "The host table's id."
          },
          {
            "name": "metadataName",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63,
              "pattern": "^[a-z][a-z0-9_]*$"
            },
            "description": "The metadata table's API name, unique on its host."
          }
        ],
        "responses": {
          "204": {
            "description": "The metadata table was deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/constraints": {
      "get": {
        "operationId": "tablesTableIdConstraintsGet",
        "x-permission": "tables:read",
        "summary": "List table-level constraints",
        "tags": [
          "TableConstraints"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of table constraints",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TableConstraint"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesTableIdConstraintsPost",
        "x-permission": "fields:manage",
        "summary": "Add a table-level constraint",
        "description": "Adds a composite-unique, no-overlap, check, same-parent or capacity constraint, enforced by the database. Fails with 400 (listing offending row ids) when existing data already violates the constraint.",
        "tags": [
          "TableConstraints"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTableConstraintRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Constraint added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableConstraint"
                }
              }
            }
          },
          "400": {
            "description": "Invalid constraint or existing data violates it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The table is mirrored and the change would alter a mirrored field, or break the sync (code `MIRRORED_FIELD_LOCKED`; `suggestion` says what to do instead).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/constraints/{constraintId}": {
      "put": {
        "operationId": "tablesTableIdConstraintsConstraintIdPut",
        "x-permission": "fields:manage",
        "summary": "Replace a table-level constraint",
        "description": "Edits an existing constraint in place. A composite-unique, no-overlap or check rule cannot be ALTERed in Postgres, so the physical constraint is dropped and re-added from the new definition within a single transaction, keeping the constraint id (and therefore the violation messages that name it) stable. Fails with 400 — leaving the previous rule enforcing — when the new definition is invalid, duplicates another constraint on the table, or existing data violates it.",
        "tags": [
          "TableConstraints"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "constraintId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTableConstraintRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Constraint replaced",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableConstraint"
                }
              }
            }
          },
          "400": {
            "description": "Invalid constraint or existing data violates it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or constraint not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The table is mirrored and the change would alter a mirrored field, or break the sync (code `MIRRORED_FIELD_LOCKED`; `suggestion` says what to do instead).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdConstraintsConstraintIdDelete",
        "x-permission": "fields:manage",
        "summary": "Delete a table-level constraint",
        "tags": [
          "TableConstraints"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "constraintId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Constraint deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or constraint not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/constraints/{constraintId}/occupancy": {
      "get": {
        "operationId": "tablesTableIdConstraintsConstraintIdOccupancyGet",
        "x-permission": "records:read",
        "summary": "Read how full each resource of a capacity constraint is over a window",
        "description": "For a `capacity` constraint, the load of each scope group (each resource) over `[from, to)`: the peak and the maximal intervals of constant load, with the group's limit. What an occupancy strip draws, and what an integration reads to find free capacity before it books.\n\nRow-scoped like the items list: only rows the caller may read count, and `partial` says when their scope is restricted. Every field the constraint names (scope, start, end, weight and the condition's fields) must be readable by the caller, or the read is 403. A limit read off a resource row is returned only when the caller may read that row and its limit field on the resource table; otherwise the group carries `limitHidden`. The window may span at most 366 days. Without `resource` the 100 fullest groups are returned and `truncated` is set beyond that.",
        "tags": [
          "TableConstraints"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "constraintId",
            "in": "path",
            "required": true,
            "description": "A `capacity` constraint on the table.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "description": "The start of the window: a `YYYY-MM-DD` day or an ISO 8601 instant. A date-range constraint reads an instant as its UTC day; a datetime one reads a day as its UTC midnight.",
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "description": "The end of the window, exclusive, in the same forms; after `from` and at most 366 days on.",
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "resource",
            "in": "query",
            "required": false,
            "description": "Read one resource only: a value of the constraint's resource field (the limit's reference field, or else its first scope field), such as a room's record id.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The occupancy of each scope group over the window",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapacityOccupancy"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/fields/{fieldId}/stage-config": {
      "get": {
        "operationId": "tablesTableIdFieldsFieldIdStageConfigGet",
        "x-permission": "tables:read",
        "summary": "Read the stage machine attached to a field",
        "description": "Returns the field's stage configuration, or 404 when the field is not stage-designated. Designating a field is creating this row; there is no separate pipeline object.",
        "tags": [
          "StageConfig"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The field's stage configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StageConfig"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or field not found, or the field is not stage-designated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "tablesTableIdFieldsFieldIdStageConfigPut",
        "x-permission": "fields:manage",
        "summary": "Designate a field as a stage field, or replace its machine",
        "description": "Creates the stage configuration when absent and replaces it when present — deliberately mutable, unlike table constraints: a transition matrix is edited routinely and compiles to no DDL, so there is nothing to rebuild and no rows to re-scan.\n\nDesignating a field never breaks existing writes: the default policy is `any`, which adds no transition rules at all.",
        "tags": [
          "StageConfig"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StageConfigRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stage configuration saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StageConfig"
                }
              }
            }
          },
          "400": {
            "description": "Invalid configuration — an unsupported source kind, a field that is not a picklist, or a stage value that is not one of the field's options.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdFieldsFieldIdStageConfigDelete",
        "x-permission": "fields:manage",
        "summary": "Undesignate a stage field",
        "description": "Removes the machine. The field keeps its options and its data — only the transition rules go away.",
        "tags": [
          "StageConfig"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Stage configuration removed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or field not found, or the field is not stage-designated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/fields/{fieldId}/stage-config/snapshot": {
      "post": {
        "operationId": "tablesTableIdFieldsFieldIdStageConfigSnapshotPost",
        "x-permission": "fields:manage",
        "summary": "Write baseline stage history for records that predate the machine",
        "description": "For a field already designated as a stage field, write one `snapshot` transition (`fromValue` null, `toValue` the current value, dated now) per live record whose value is set and that has no history for the field yet. The one-off form of `StageConfigRequest.snapshotExisting`, for fields designated before that option existed or without it. Idempotent: re-running it writes nothing, and a record with real history is never given a fake start. 404 when the field is not a stage field. With `snapshotDating` the baseline is dated from the records' own date fields (see StageSnapshotDating) instead of now.",
        "tags": [
          "StageConfig"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StageSnapshotRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Baseline rows written",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StageSnapshotResult"
                }
              }
            }
          },
          "400": {
            "description": "The dating names a field that is not a date field of the table, or a value that is not an option",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table, field, or stage designation not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/derived-fields/{derivedFieldId}/stage-config": {
      "get": {
        "operationId": "tablesTableIdDerivedFieldsDerivedFieldIdStageConfigGet",
        "x-permission": "tables:read",
        "summary": "Read the stage machine attached to a derived column",
        "description": "The computed-source half of stage designation. A derived column's stage carries a declared `valueSet` rather than an option list, and is never writable — its value is a consequence of the fields the formula reads.",
        "tags": [
          "StageConfig"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "derivedFieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The derived column's stage configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StageConfig"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or derived field not found, or the column is not stage-designated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "tablesTableIdDerivedFieldsDerivedFieldIdStageConfigPut",
        "x-permission": "fields:manage",
        "summary": "Designate a derived column as a computed stage",
        "description": "Requires a **stored** formula column returning text. A virtual column is refused: it is computed as it is read, so there is nothing to record a change of, group a board by, or filter on.\n\n`valueSet` is required and is the whole machine — transitions, initialStages, stageRequirements and allowClear are refused rather than stored, because a computed value moves when its inputs move and there is no write to this column to allow or deny. Refusing an edit to the field that *implies* a stage change would name a field nobody calls the stage.",
        "tags": [
          "StageConfig"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "derivedFieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StageConfigRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stage configuration saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StageConfig"
                }
              }
            }
          },
          "400": {
            "description": "Invalid configuration — a virtual or non-formula column, a non-text result type, a missing or duplicated `valueSet`, or a hard guard that does not apply to a computed source.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or derived field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdDerivedFieldsDerivedFieldIdStageConfigDelete",
        "x-permission": "fields:manage",
        "summary": "Undesignate a computed stage",
        "description": "Removes the machine. The column and its data are untouched; it simply stops being tracked as a stage.",
        "tags": [
          "StageConfig"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "derivedFieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Stage configuration removed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or derived field not found, or the column is not stage-designated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/derived-fields": {
      "get": {
        "operationId": "tablesTableIdDerivedFieldsGet",
        "x-permission": "derivedViews:read",
        "summary": "List derived fields (computed columns) on a table",
        "description": "Returns the derived fields visible to the caller: workspace-shared, plus the caller's own personal fields, plus fields owned by any group the caller belongs to.",
        "tags": [
          "DerivedFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Visible derived fields",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DerivedField"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesTableIdDerivedFieldsPost",
        "x-permission": "derivedViews:read",
        "summary": "Create a derived field (computed column)",
        "description": "Creates a read-only computed column (formula / lookup / rollup) in the derived-views layer. ownerScope 'user' (a personal view) is allowed with derivedViews:read; 'workspace' or 'group' scope requires derivedViews:manage (enforced in the controller). The definition is validated at create time.",
        "tags": [
          "DerivedFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DerivedFieldCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Derived field created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DerivedField"
                }
              }
            }
          },
          "400": {
            "description": "Invalid definition or name collides with an existing column",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Caller lacks derivedViews:manage for a workspace/group-scoped field",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/formula/validate": {
      "post": {
        "operationId": "tablesTableIdFormulaValidatePost",
        "x-permission": "derivedViews:read",
        "summary": "Validate a formula expression against a table's fields",
        "description": "Type-checks a formula expression against the table's fields without creating anything — the live-validation counterpart of the create path. Returns `{ valid: true, resultType, referencedFields }` on success (the result type is inferred when the request omits one), or `{ valid: false, error }` with a stable code, message, teaching suggestion, and character position when a formula is malformed. Always responds 200 for a syntactically-processable request; a bad formula is reported in the body, not as an HTTP error.",
        "tags": [
          "DerivedFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FormulaValidationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result (valid or not)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormulaValidationResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/derived-fields/{derivedFieldId}": {
      "delete": {
        "operationId": "derivedFieldsDerivedFieldIdDelete",
        "x-permission": "derivedViews:read",
        "summary": "Delete a derived field",
        "description": "Deleting your own personal derived field needs derivedViews:read; deleting a workspace- or group-shared field needs derivedViews:manage (enforced in the controller).",
        "tags": [
          "DerivedFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "derivedFieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Derived field deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Caller lacks derivedViews:manage for a workspace/group-scoped field",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Derived field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/summaries": {
      "get": {
        "operationId": "tablesTableIdSummariesGet",
        "x-permission": "derivedViews:read",
        "summary": "List summary rows visible to the caller",
        "tags": [
          "TableSummaries"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Visible summary rows",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TableSummary"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesTableIdSummariesPost",
        "x-permission": "derivedViews:read",
        "summary": "Create a summary row",
        "description": "ownerScope 'user' (personal) is creatable with derivedViews:read; 'workspace'/'group' require derivedViews:manage. Every cell is validated against the table's fields at create time.",
        "tags": [
          "TableSummaries"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TableSummaryCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Summary created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableSummary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid summary cell",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Caller lacks derivedViews:manage for a workspace/group summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/summaries/compute": {
      "post": {
        "operationId": "tablesTableIdSummariesComputePost",
        "x-permission": "derivedViews:read",
        "summary": "Compute the visible summary rows' values",
        "description": "Aggregates each visible summary's cells over the table with the caller's row-scope filter and field visibility applied — a total never reveals rows or columns the caller cannot see.",
        "tags": [
          "TableSummaries"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Computed values, one entry per visible summary row",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SummaryValues"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/summaries/{summaryId}": {
      "put": {
        "operationId": "summariesSummaryIdPut",
        "x-permission": "derivedViews:read",
        "summary": "Update a summary row (label + cells)",
        "description": "Your own personal summary needs derivedViews:read; a workspace- or group-scoped summary needs derivedViews:manage. ownerScope is immutable. Every provided cell is validated against the table's fields.",
        "tags": [
          "TableSummaries"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "summaryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TableSummaryUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Summary updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableSummary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid summary cell",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Caller lacks derivedViews:manage for a workspace/group summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Summary not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "summariesSummaryIdDelete",
        "x-permission": "derivedViews:read",
        "summary": "Delete a summary row",
        "description": "Your own personal summary needs derivedViews:read; a workspace- or group-scoped summary needs derivedViews:manage.",
        "tags": [
          "TableSummaries"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "summaryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Summary deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Caller lacks derivedViews:manage for a workspace/group summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Summary not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/views": {
      "get": {
        "operationId": "viewsGet",
        "x-permission": "tables:read",
        "summary": "List SQL views with their definitions",
        "description": "Every data-level SQL view of the workspace with the SELECT that defines it, by name. The views are also `DataTable`s of `kind: view` in `GET /tables`, where their derived columns are read; this is where to read a view definition (the SELECT) before replacing it with `PUT /views/{viewId}`. Gated like the columns and like a schema export (`tables:read`): the definition is workspace configuration, not record data — reading the view's rows is gated separately.",
        "tags": [
          "Views"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The workspace's SQL views, ordered by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SqlView"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "viewsPost",
        "x-permission": "tables:manage",
        "summary": "Create a data-level SQL view",
        "description": "A read-only derived table backed by a validated single SELECT, created as a real Postgres view and registered in the tables surface (UI, MCP, records read API). Reading a view's rows requires unrestricted record visibility (same rule as POST /query).",
        "tags": [
          "Views"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateViewRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "View created (with derived fields)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataTable"
                }
              }
            }
          },
          "400": {
            "description": "Invalid name or SQL. A name that is not free carries `code` `TABLE_ALREADY_EXISTS` when a table or view already uses it, and `TABLE_NAME_RETAINED` when a deleted table, whose data is kept, still holds it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/views/{viewId}": {
      "get": {
        "operationId": "viewsViewIdGet",
        "x-permission": "tables:read",
        "summary": "Read a SQL view's definition",
        "description": "One data-level SQL view with the single SELECT that defines it, by id (the same id the tables surface reports for the view). Read it before replacing the definition with `PUT /views/{viewId}`, or to copy the SELECT into a saved query. Gated like the view's columns and a schema export (`tables:read`). A plain table's id is a 404: a table has no definition to read.",
        "tags": [
          "Views"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "viewId",
            "in": "path",
            "required": true,
            "description": "The view's id, as the tables surface reports it.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The view and its definition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlView"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No SQL view has this id (a plain table's id is also a 404)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "viewsViewIdPut",
        "x-permission": "tables:manage",
        "summary": "Update a SQL view's definition or display metadata",
        "description": "Replaces the view's SELECT (its fields are re-derived from it) and/or its display name and description; only the fields present change. The current definition is read with `GET /views/{viewId}` (or `GET /views` for every view), so a change starts from what is stored rather than a copy.",
        "tags": [
          "Views"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "viewId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateViewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "View updated (fields re-derived when the SQL changed)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataTable"
                }
              }
            }
          },
          "400": {
            "description": "Invalid SQL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "View not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Other views are built on this one (VIEW_HAS_DEPENDENTS), so its definition cannot be replaced",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/automations": {
      "get": {
        "operationId": "tablesTableIdAutomationsGet",
        "x-permission": "tables:read",
        "summary": "List automation rules touching a table (as source or target)",
        "tags": [
          "AutomationRules"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of automation rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AutomationRule"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesTableIdAutomationsPost",
        "x-permission": "permissions:manage",
        "summary": "Create an automation rule with this table as the source",
        "description": "Declarative cross-row derivation. materialize_range_children keeps one target row per date of the source row's span; interval_lookup keeps a target reference pointed at the covering source row. An initial reconcile runs on creation. Gated by permissions:manage because the engine applies derived writes without the caller's row/field scope (workspace-level invariants) — members with only fields:manage must not be able to rewrite private records they cannot update via REST.",
        "tags": [
          "AutomationRules"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAutomationRuleRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Automation rule created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutomationRule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The table is mirrored and the change would alter a mirrored field, or break the sync (code `MIRRORED_FIELD_LOCKED`; `suggestion` says what to do instead).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/automations/{ruleId}": {
      "delete": {
        "operationId": "tablesTableIdAutomationsRuleIdDelete",
        "x-permission": "permissions:manage",
        "summary": "Delete an automation rule (generated rows are kept)",
        "tags": [
          "AutomationRules"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Automation rule deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or rule not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/automations/{ruleId}/reconcile": {
      "post": {
        "operationId": "tablesTableIdAutomationsRuleIdReconcilePost",
        "x-permission": "permissions:manage",
        "summary": "Run a full reconcile pass for an automation rule",
        "description": "Recomputes the rule's derived state from scratch (bounded per pass; idempotent). Use after bulk imports or partial-failure warnings. Same privilege as rule creation — reconcile writes without row scope.",
        "tags": [
          "AutomationRules"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Reconcile pass result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutomationReconcileResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or rule not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/fields/{fieldId}/visibility": {
      "put": {
        "operationId": "tablesTableIdFieldsFieldIdVisibilityPut",
        "x-permission": "permissions:manage",
        "summary": "Set a field's visibility",
        "description": "'workspace' (default) = anyone with record access sees the field; 'private' = hidden except from owner/admin and roles holding a field grant.",
        "tags": [
          "TableFields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "visibility"
                ],
                "properties": {
                  "visibility": {
                    "$ref": "#/components/schemas/FieldVisibility"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Field visibility updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableField"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/fields/{fieldId}/reference-options": {
      "get": {
        "operationId": "tablesTableIdFieldsFieldIdReferenceOptionsGet",
        "x-permission": "records:read",
        "summary": "Search or resolve the picker options of a reference field",
        "description": "The server-side backing for reference-field dropdowns on referenced tables too large to load wholesale. Addressed by the REFERENCING field: the server resolves the referenced table and the display field from the field's own configuration (`referencedFieldId`, else the referenced table's display label — a stored field or a read-time computed column — falling back to a field named name/displayName/title, then the record id) — so the label returned here is, by construction, the same label the picker shows, independent of the table's record-layout title or global-search settings. Works for system-entity references (users/groups) too, and for a `multiReference` field: `q` searches its target table and `ids` resolves a stored set's labels, so a set is labelled the way a single reference is. With a computed label, `q` is matched against the label's SOURCE columns (the fields its expression reads and the label fields of the tables its lookups reach) rather than the rendered label — the label is never indexed, so a term must appear in one of the facts it is built from.\n\nTwo modes, combinable: `q` filters options to those whose label contains every term as an accent-folded, case-insensitive substring (the picker's as-you-type search; an empty or absent `q` returns the first page ordered by label, so the dropdown has content on focus); `ids` resolves specific record ids to labels (how clients render already-stored reference values — grid cells, pre-selected pickers — without fetching the referenced table).\n\nResults honour the caller's visibility of the referenced table: rows outside the caller's record scope are absent, and a display field the caller may not read is never used for labels (the fallback chain skips it). Ordering is by label, case- and accent-insensitively, with id as the final tie-break. Unlike GET /search, this endpoint does not depend on the referenced table's `isSearchable` flag — a picker must work even for tables an admin keeps out of global search.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "description": "The table the REFERENCING field belongs to.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "description": "The reference field whose options to search or resolve.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search text. Split on whitespace into terms; every term must appear in the label as an accent-folded, case-insensitive substring. Empty behaves as absent.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          },
          {
            "name": "ids",
            "in": "query",
            "required": false,
            "description": "Comma-separated referenced-record ids to resolve to labels, at most 200 per request. Ids the caller cannot see (or that do not exist) are simply absent from the result — render the raw id. Combines with `q` as an intersection, though clients typically pass one or the other. On a `polymorphicReference` field each entry is `tableId:recordId`, naming which target table the record is in.",
            "schema": {
              "type": "string",
              "maxLength": 4000
            }
          },
          {
            "name": "tableId",
            "in": "query",
            "required": false,
            "description": "For a `polymorphicReference` field, the target table to search with `q`; required with `q` on that type and ignored on a single-target reference. Must be one of the field's `referencedTableIds`.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum options to return (default 50).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "parentField",
            "in": "query",
            "required": false,
            "description": "Offer only the referenced records under one parent: the name of a reference field on the REFERENCED table, set together with `parentId`. The record form passes it for a `same_parent` constraint with a `directReference` — a reservation's table picker offers only the tables of the chosen venue. The field must be a table reference the caller can read; anything else is a 400. Only for a reference or multiReference field pointing at a table.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63
            }
          },
          {
            "name": "parentId",
            "in": "query",
            "required": false,
            "description": "The parent record id `parentField` must hold; set together with `parentField`.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching options, ordered by label",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReferenceOptionsResponse"
                }
              }
            }
          },
          "400": {
            "description": "The field is not a reference field, or a parameter is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table, field, or referenced table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/field-aggregates": {
      "get": {
        "operationId": "tablesTableIdFieldAggregatesGet",
        "x-permission": "records:read",
        "summary": "Aggregate a table's records per option value of one picklist field",
        "description": "One row per option value of `groupBy` (plus a `value: null` row for records where the field is empty), each carrying a record count and, when `sum` names a numeric field, that field's sum. Row-scoped exactly like the items list — the caller's row filter is applied before grouping, so the numbers describe only records the caller can see — and both named fields must be readable by the caller (naming a masked or non-existent field is a 400 with the same message for both). The cross-record half of process reporting (GATED_PROCESSES_DESIGN §6): with a stage-designated `groupBy` this is the gate-distribution query, and the kanban board's column counts. `filter` narrows the records counted exactly as it narrows the items list, so a filtered board's lane counts describe the records it draws. Not available for a table of kind `view`.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "groupBy",
            "in": "query",
            "required": true,
            "description": "fieldName of a picklist field on the table to group by.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          },
          {
            "name": "sum",
            "in": "query",
            "required": false,
            "description": "fieldName of a numeric field to sum per group.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "description": "A `RecordFilter` document, JSON-encoded (URL-encode the result), with the same grammar and the same rules as the items list's `filter` parameter: it is AND-ed onto the caller's row scope and can only narrow it, and naming a field the caller cannot read is a 400. Absent counts every record the caller can see.",
            "schema": {
              "type": "string",
              "maxLength": 4000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One aggregate row per option value present",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FieldAggregates"
                }
              }
            }
          },
          "400": {
            "description": "groupBy/sum is not a readable field of the right type, or the filter is malformed or names a field the caller cannot read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/aggregate": {
      "post": {
        "operationId": "tablesTableIdAggregatePost",
        "x-replica-reads": true,
        "x-permission": "records:read",
        "summary": "Aggregate a table's records — grouped counts, sums and the like — within the caller's row scope",
        "description": "Runs a structured aggregate (`RecordAggregateSpec`) over the records the caller can see: the row scope is applied before grouping, every field named must be readable (a masked or non-existent field is a 400 with the same message for both), and `filter` can only narrow the result. This is the execution path for charts drawn from a table's records (`ChartConfig.source`), and the reason such a chart renders for a viewer whose record visibility is restricted — the audience for whom `POST /query` is unavailable. Not available for a table of kind `view`.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecordAggregateSpec"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One row per group (or a single row when ungrouped)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordAggregateResult"
                }
              }
            }
          },
          "400": {
            "description": "A named field is not readable or not of a type the function accepts, or the filter is refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/report": {
      "post": {
        "operationId": "tablesTableIdReportPost",
        "x-replica-reads": true,
        "x-permission": "records:read",
        "summary": "Report on a table's records grouped by up to three dimensions, with subtotals, within the caller's row scope",
        "description": "Runs a grouped report (`RecordReportSpec`) over the records the caller can see: the row scope is applied before grouping, every field named must be readable (a masked or non-existent field is a 400 with the same message for both), and `filter` can only narrow the result. Dimensions may be a picklist or text, a date (bucketed), a single-valued reference (keyed by the referenced record's id) or a lookup (keyed by its value); a subtotal row per level and a grand total come back with the leaves. This is what a grouped grid view and a pivot tile run for whoever views them. Not available for a table of kind `view`.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecordReportSpec"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The report's rows in report order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordReportResult"
                }
              }
            }
          },
          "400": {
            "description": "A field that is not readable, a dimension of a type that cannot be grouped, a metric over the wrong type, a malformed filter, or a SQL view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/duplicates/check": {
      "post": {
        "operationId": "tablesTableIdDuplicatesCheckPost",
        "x-replica-reads": true,
        "x-permission": "records:read",
        "summary": "Check a candidate record against the table's existing records for duplicates",
        "description": "Answers \"is this already in here?\" for a record that has not been saved yet — or one being edited, via `excludeItemId`. The candidate's values are folded the same way the scan folds stored values (case and surrounding space, or digits-only for a phone number), so the near-miss a plain unique index admits is caught while the person can still change their mind.\nThis is a record READ: the caller's row scope is applied, so a record they cannot see is never reported, and only dedupe keys they may read are compared — an unreadable key is neither checked nor returned. Not available for a table of kind `view`.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DuplicateCheckRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The keys checked and what each one matched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DuplicateCheckResult"
                }
              }
            }
          },
          "400": {
            "description": "The table is a view, which has no records of its own",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/duplicates": {
      "get": {
        "operationId": "tablesTableIdDuplicatesGet",
        "x-permission": "records:read",
        "summary": "Find records that already duplicate each other on one of the table's dedupe keys",
        "description": "Groups the records the caller can see by each dedupe key's folded value and returns the collisions, largest first — the after-the-fact half of duplicate detection, for cleaning up what is already there.\nScoped like any record read: rows outside the caller's scope are not grouped and keys they cannot read are not compared. Caps are visible — a group reports its full `count` even when it lists fewer records, and `groupsOmitted` reports groups the cap cut, because a silently truncated report reads exactly like a clean one. Not available for a table of kind `view`.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The table's dedupe keys and the duplicate groups found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DuplicateScanResult"
                }
              }
            }
          },
          "400": {
            "description": "The table is a view, which has no records of its own",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/fields/{fieldId}/occurrences": {
      "get": {
        "operationId": "tablesTableIdFieldsFieldIdOccurrencesGet",
        "x-permission": "records:read",
        "summary": "Expand a recurrence field's series into the occurrences in a window",
        "tags": [
          "TableItems"
        ],
        "description": "The occurrences of every record's series (`fieldId` names a `recurrence` field) that overlap `[from, to)`, in start order, with the records they belong to. This is what the calendar view draws when it is placed on a recurrence field, and what an integration reads to see what a rota or a maintenance schedule actually produces over the coming weeks. Nothing is stored: each series is expanded from its value on the way out, with its exceptions applied — a cancelled slot is absent, a moved one appears at its new start.\n\nRow-scoped exactly like the items list: `filter` is AND-ed onto the caller's row scope and can only narrow it, and a record is returned through the caller's visible columns. A field the caller cannot read — or that is not a `recurrence` field — does not exist to them (404). The window may span at most 366 days; `limit` caps the records expanded (the series are read in the list's own order) and the occurrences returned are capped at 5000 — either cut sets `truncated`. Not available for a table of kind `view`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "description": "The `recurrence` field whose series to expand.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "description": "The start of the window, an ISO 8601 instant (`2026-10-01T00:00:00Z`) or day.",
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "description": "The end of the window, exclusive, in the same form; at most 366 days after `from`.",
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "description": "A `RecordFilter` document, JSON-encoded, with the same grammar and the same narrowing-only rule as the items list.",
            "schema": {
              "type": "string",
              "maxLength": 4000
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Records expanded at most (default 500).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The occurrences in the window, and their records",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordOccurrencesResponse"
                }
              }
            }
          },
          "400": {
            "description": "The window is malformed or wider than 366 days, the filter could not be honoured, or the table is a SQL view (`VIEW_READ_ONLY`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The table, or a recurrence field the caller can read, was not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items": {
      "get": {
        "operationId": "tablesTableIdItemsGet",
        "x-permission": "records:read",
        "summary": "Get items from a data table",
        "description": "Returns the table's records, row- and field-scoped to the caller. Unsorted requests keep the historical `created_at ASC` order, and `id` is always the final tie-break so paging with limit/offset is stable.\n\nA table of kind `view` (a SQL view) takes the same `filter`, `sort`, `order`, `limit` and `offset`, over the columns its SELECT projects: a view has no system columns, so `createdAt` and the like are sort or filter keys only when the view projects a column of that name, and `id` is the tie-break only when it projects one. Unsorted, the rows come by `id` when the view projects one (so pages are stable) and otherwise in the view's own order. Each row's `data` holds every projected column; `createdBy`, `updatedBy`, `ownedBy`, `createdAt` and `updatedAt` are empty, and `id` is the view's `id` column or a positional `row_<n>`. A text `contains` / `startsWith` on a view matches case-insensitively but accent-sensitively. Reading a view requires unrestricted record visibility (`PERMISSION_DENIED` otherwise), as `POST /query` does, because a view's SELECT may read any table; a filter value the column's type cannot take is a 400 with the SQL error's code.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Field to sort by: a field name on the table, one of the system columns `id`, `createdAt`, `updatedAt`, or a stage clock — `<stageField>.enteredAt` (time in the current stage) or `<stageField>.activeSeconds` (time on the running clock across every visit; records with no exact history sort last in either direction). Only fields the caller can see are accepted — an unknown or hidden name is a 400, never a silent fallback (which would leak ordering over invisible data).\n\nUp to three names, comma-separated, sort by each in turn: `sort=stage,-amount` is \"by stage, then by amount descending\". A leading `-` reverses that one key; a name without one takes `order`. Whatever the keys, `id` is appended as the final tie-break so paging is stable.",
            "schema": {
              "type": "string",
              "maxLength": 800
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "Sort direction (default asc) for every `sort` key that carries no `-` prefix of its own. Ignored without `sort`.",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum rows to return. When omitted the server still caps the response at 10000 rows — page with limit/offset to read beyond that.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Rows to skip before returning results.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "stageEnteredAt",
            "in": "query",
            "required": false,
            "description": "When true, each item additionally carries `stageEnteredAt` — when the record entered the CURRENT value of each stage-designated field the caller can read (the latest recorded transition; `approximate: true` marks the `updatedAt` fallback used when the history predates the machine, since transitions are not backfilled). Off by default: the lookup is an extra query, and most list reads do not need card aging. Ignored for a table of kind `view`.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "description": "A `RecordFilter` document, JSON-encoded (URL-encode the result). See that schema for the grammar; briefly, it is an `all`/`any` combination of `{ field, op, value }` conditions plus at most one level of parenthesised groups.\n\nThe compiled predicate is **AND-ed onto the caller's row scope**, never substituted for it: a filter narrows what the caller can already see and can never widen it, including when `match` is `any`. Only fields the caller can read are filterable — naming a masked or non-existent field is a 400 with the same message for both, since distinguishing them would itself leak the field's existence, and silently dropping the clause would show the caller rows they believe they excluded. Read-time computed columns (`lookup`, `rollup`, and virtual derived fields) are not filterable and say so; every other visible field is.\n\nOn a table of kind `view` the filterable fields are the columns the view's SELECT projects, each in the domain of its SQL type; the current-user value has no user column to compare against there.",
            "schema": {
              "type": "string",
              "maxLength": 4000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of table items",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TableItem"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The sort, window, or filter could not be honoured — a malformed filter document, an unknown or unreadable field, or an operator or value that the field's type does not accept.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesTableIdItemsPost",
        "x-permission": "records:create",
        "summary": "Create a new item in a data table",
        "description": "Creates a record. An attachment field's value may be included by first\nuploading the file through the staged-attachment endpoint for that\nfield (POST /tables/{tableId}/fields/{fieldId}/attachments/staged) and\npassing the resulting metadata (staged s3Key/filename/mimeType/size/\nuploadedAt) as the field's value — the server verifies the staged\nobject and promotes it to its canonical per-record key. Attachment\nvalues that do not reference a staged upload are rejected, and a\nstaged upload can only be bound by the user who staged it.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTableItemRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Item created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableItem"
                }
              }
            }
          },
          "400": {
            "description": "Invalid item data: `details` says what is wrong per field. When a stage field refused the write the body additionally carries code `TRANSITION_NOT_ALLOWED` and a `transition` object naming the allowed targets; when a unique field or a composite-unique constraint refused it, code `UNIQUE_VIOLATION` and `conflict`, the record it collides with.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordWriteError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The table is mirrored (code `MIRRORED_TABLE_READ_ONLY`): its records are created, deleted and restored only by its sync.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/bulk": {
      "post": {
        "operationId": "tablesTableIdItemsBulkPost",
        "x-permission": "records:create",
        "summary": "Create many records in one call",
        "description": "Bulk create: one call, many records, each a full single-record write\n(admin issue 2d62413fc111). `items` carries one CreateTableItemRequest\nper record, in the order the ids come back.\n\n**Every record goes through the same write path as a single-record\ncreate.** Field-write permissions, validation, unique and other\nconstraints, stage rules, automations, derived-field recalculation and\naudit events all apply per record, exactly as one at a time. There is\nno privileged bulk path, which is also why this is not a substitute\nfor the CSV import (`POST /tables/{tableId}/import`): an import is the\nbulk-load path that skips automation rules and streams a file; this\nis N ordinary creates.\n\n**This is not one transaction.** Each record is created independently\nand `results` reports every outcome in request order, with the new\nrecord's id on each success — a unique collision or a validation error\nfails only its own record, and the rest are created. Read `results`;\na 200 does NOT mean every record was created.\n\n**Sending a batch again.** With `onMatch: update` (or `skip`) and a\n`matchBy` key, an item whose key matches an existing record updates it\n(or leaves it) instead of creating a duplicate, so a retried batch\nconverges. `update` needs `records:update` too, and each update goes\nthrough the single-record PATCH path. `dryRun` checks the batch and\nwrites nothing; each outcome's `action` says what would happen.\n\n**References are ids unless `resolve` says otherwise.** The import\nresolves a reference cell by the target's key on its own; here a\nreference value must be the record's id, or the request names the\nkey to look it up by in `resolve` (`{ \"service_partner\": \"name\" }`,\nor `\"referenceKey\"` for the target's own key, an object for a\ncomposite one). `resolvedBy` on the result says which key each\nresolution used. A reference value that is neither is refused for\nits own record with the option named.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkCreateRecordsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The operation ran. Every requested record has an entry in `results`, in request order; check `failed` and each entry's `reason`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkCreateRecordsResult"
                }
              }
            }
          },
          "400": {
            "description": "The request was refused before any record was written — an empty or oversized batch, or a `resolve` entry the table cannot honour (code `RESOLVE_INVALID`: not a reference field, not a unique field of the target, or a target with no key to match on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/records/graph": {
      "post": {
        "operationId": "recordsGraphPost",
        "x-permission": "records:read",
        "summary": "Write many records in one transaction",
        "description": "The record-graph write: an ordered list of creates, updates, deletes\nand metadata rows across any tables of the workspace, applied in one\ntransaction. Either every operation is applied or none is: a refused\noperation leaves no record, no metadata row and no attached file\nbehind, and the answer is one error naming that operation.\n\n**Each operation is the single-record write.** Row scope, field\npermissions, value contracts, references, constraints, stage rules\nand the metadata guard all apply exactly as they do one at a time,\nand each operation checks its own action (`records:create`,\n`records:update` or `records:delete`). Events, history, webhooks and\nautomations follow per record once the transaction commits; their\nevents carry `metadata.graph`.\n\n**Refs.** A `create` may declare a `ref`; a later operation's `data`\npoints at that record with `{ \"ref\": \"<name>\" }` wherever a record id\ngoes. A ref only points backwards, and updates and deletes take ids\nof records that already exist.\n\n**Lock tokens.** An update or delete with `expectedUpdatedAt` is\nrefused with `STALE_RECORD` when another write has moved the record,\nincluding one made while this request was being checked.\n\n**Approvals.** An update an approval rule would intercept refuses the\nwhole request with `APPROVAL_REQUIRED`; request approval for that\nrecord on its own.\n\n**Retrying.** Send an `Idempotency-Key` header: a retry with the same\nkey and body answers the first result with `replayed: true` and\nwrites nothing, for 24 hours. A refused request stores nothing, so\nits retry runs afresh.\n\nAt most 500 operations, counting each metadata row as one.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key the client chooses for this request, so a retry after a timeout does not write twice. Reusing it with a different body is refused with `IDEMPOTENCY_KEY_REUSED`.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecordGraphRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Every operation was applied (or, for `dryRun`, would be), or this is the stored answer to an earlier request with the same key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordGraphResponse"
                }
              }
            }
          },
          "400": {
            "description": "The request or one of its operations was refused and nothing was written: `GRAPH_REF_INVALID` for a ref that is unknown, duplicated or points forwards, a value or reference the record's table refuses (with `details`), a unique clash (`conflict`), or more than 500 operations counting each metadata row (`GRAPH_TOO_LARGE`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordGraphError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller may not write records at all, or one operation needs an action, a field or a metadata grant the caller lacks. Nothing was written.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordGraphError"
                }
              }
            }
          },
          "404": {
            "description": "An operation names a table or record the caller cannot see. Nothing was written.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordGraphError"
                }
              }
            }
          },
          "409": {
            "description": "`STALE_RECORD` (another write moved a record), `APPROVAL_REQUIRED` (an approval rule would intercept an update), a metadata table's own refusal such as `METADATA_APPEND_ONLY`, or `IDEMPOTENCY_KEY_IN_FLIGHT` (the first request with this key is still running: retry later), or `TRANSACTION_CONFLICT` (another write held records this one needed: send it again). Nothing was written.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordGraphError"
                }
              }
            }
          },
          "422": {
            "description": "`IDEMPOTENCY_KEY_REUSED`: the key was used for a different request in the last 24 hours. Nothing was written.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordGraphError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/bulk-update": {
      "post": {
        "operationId": "tablesTableIdItemsBulkUpdatePost",
        "x-permission": "records:update",
        "summary": "Apply the same field changes to many records",
        "description": "Bulk edit over an explicit selection of records (#507). `data` carries\nthe fields to change; every named field is set to the given value on\nevery selected record. Fields not named are left alone — this is a\nPATCH-shaped merge per record, never a replace.\n\n**Every record goes through the same write path as a single-record\nwrite.** Row scope, field-write permissions, validation, stage\ntransition rules, database constraints, approval rules, automations,\nderived-field recalculation and audit events all apply per record,\nexactly as they would one at a time. There is no privileged bulk path.\n\n**This is not one transaction.** Each record is written independently\nand the response reports the outcome of each, because the per-record\ngates above genuinely differ per row: one record may be out of the\ncaller's row scope, another may violate a unique constraint, a third\nmay be intercepted by an approval rule. Rolling the whole selection\nback because one row failed would be less useful, not safer — and it\nwould mean suppressing the events and automations the successful\nwrites already fired. Read `results`; do not assume all-or-nothing.\n\nA bulk update is **not** undoable. Record history records what changed\nper record, but there is no one-click revert, which is why the\nresponse reports each record individually.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkUpdateRecordsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The operation ran. Every requested record has an entry in `results`; a 200 does NOT mean every record succeeded. Check `failed` and each entry's `reason`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkRecordOperationResult"
                }
              }
            }
          },
          "400": {
            "description": "The request was refused before any record was touched — an empty or oversized selection, or duplicate ids.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/bulk-patch": {
      "post": {
        "operationId": "tablesTableIdItemsBulkPatchPost",
        "x-permission": "records:update",
        "summary": "Set different field values on many records in one call",
        "description": "Bulk edit where every record carries its own values (#1503). Each entry\nof `items` names one record and the fields to change on it; fields not\nnamed are left alone — a PATCH-shaped merge per record, never a\nreplace. Use it to backfill a field whose value differs per record\n(for example before making that field required), where\n`POST /tables/{tableId}/items/bulk-update` would need one call per\ndistinct value.\n\n**Every record goes through the same write path as a single-record\nPATCH.** Row scope, field-write permissions, validation, stage\ntransition rules, database constraints, approval rules, automations,\nderived-field recalculation and audit events all apply per record,\nexactly as they would one at a time. There is no privileged bulk path.\nA record outside the caller's row scope is reported as `not_found`,\nthe same as a missing one.\n\n**Optimistic concurrency per record.** An entry that carries\n`expectedUpdatedAt` is written only if the record has not changed\nsince; otherwise that record's outcome is `reason: conflict` and the\nrest of the batch carries on.\n\n**This is not one transaction.** Each record is written independently\nand the response reports the outcome of each, as for bulk update. Read\n`results`; do not assume all-or-nothing. Like a bulk update, it is not\nundoable as a unit — record history records what changed per record.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkPatchRecordsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The operation ran. Every requested record has an entry in `results`; a 200 does NOT mean every record succeeded. Check `failed` and each entry's `reason`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkRecordOperationResult"
                }
              }
            }
          },
          "400": {
            "description": "The request was refused before any record was touched — an empty or oversized batch, duplicate record ids, or an entry with no fields to change.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/bulk-delete": {
      "post": {
        "operationId": "tablesTableIdItemsBulkDeletePost",
        "x-permission": "records:delete",
        "summary": "Delete many records as one restorable batch",
        "description": "Bulk delete over an explicit selection of records (#507).\n\n**Every record goes through the same write path as a single-record\nwrite.** Row scope, field-write permissions, validation, stage\ntransition rules, database constraints, approval rules, automations,\nderived-field recalculation and audit events all apply per record,\nexactly as they would one at a time. There is no privileged bulk path.\n\n**This is not one transaction.** Each record is written independently\nand the response reports the outcome of each, because the per-record\ngates above genuinely differ per row: one record may be out of the\ncaller's row scope, another may violate a unique constraint, a third\nmay be intercepted by an approval rule. Rolling the whole selection\nback because one row failed would be less useful, not safer — and it\nwould mean suppressing the events and automations the successful\nwrites already fired. Read `results`; do not assume all-or-nothing.\n\n**A bulk delete is undone as a unit.** Every record deleted by one\ncall shares a single recycle-bin batch, so restoring any one of them\nfrom the bin restores the whole operation — the same mechanism that\nalready pulls cascade children back with their parent. `batchId` is\nreturned for that reason. Restoring requires delete scope on every row\nin the batch, so a bulk delete cannot become a way to revive rows the\ncaller could not have deleted themselves.\n\nDeletes are soft (the recycle bin, #84), so a mistaken bulk delete is\nrecoverable.\n\nA POST, not a DELETE, because the selection travels in the body and\nDELETE bodies are not reliably carried by intermediaries.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkDeleteRecordsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The operation ran. Every requested record has an entry in `results`; a 200 does NOT mean every record succeeded. Check `failed` and each entry's `reason`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkRecordOperationResult"
                }
              }
            }
          },
          "400": {
            "description": "The request was refused before any record was touched — an empty or oversized selection, or duplicate ids.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/metadata/{metadataName}": {
      "get": {
        "operationId": "tablesTableIdItemsItemIdMetadataMetadataNameGet",
        "x-permission": "records:read",
        "summary": "Read a record's rows of one metadata table",
        "description": "This record's rows of the metadata table `metadataName`, keyed by the host field each row describes. A row is visible exactly when its record and its host field are: a field the caller cannot read is absent. The record itself must be readable, or the answer is 404. The same rows come with the record through `metadata=<name>` on `GET /tables/{tableId}/items/{itemId}`.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "description": "The host table's id.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "description": "The host record's id.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "metadataName",
            "in": "path",
            "required": true,
            "description": "The metadata table's name on its host table.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63,
              "pattern": "^[a-z][a-z0-9_]*$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record's rows of that metadata table, keyed by host field name.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordMetadata"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The table, the record or the metadata table was not found, or the record is not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/metadata/{metadataName}/{fieldName}": {
      "get": {
        "operationId": "tablesTableIdItemsItemIdMetadataMetadataNameFieldNameGet",
        "x-permission": "records:read",
        "summary": "Read a record's metadata row for one field",
        "description": "The row of metadata table `metadataName` that describes field `fieldName` of this record. 404 when there is none, or when the caller cannot read the record or the field.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "description": "The host table's id.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "description": "The host record's id.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "metadataName",
            "in": "path",
            "required": true,
            "description": "The metadata table's name on its host table.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63,
              "pattern": "^[a-z][a-z0-9_]*$"
            }
          },
          {
            "name": "fieldName",
            "in": "path",
            "required": true,
            "description": "The host field the row describes, by name.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63,
              "pattern": "^[a-z_][a-z0-9_]*$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The metadata row.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetadataRow"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such table, record, metadata table or row, or the record or the field is not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "tablesTableIdItemsItemIdMetadataMetadataNameFieldNamePut",
        "x-permission": "records:read",
        "summary": "Write a record's metadata row for one field",
        "description": "Creates the row of metadata table `metadataName` about field `fieldName` of this record, or replaces its values when one exists (never on an append-only table). The write needs, on top of reading the record: the record action (`records:create` for a new row, `records:update` to change one), a grant on the metadata table (`PUT /roles/{roleId}/metadata-tables/{metadataTableId}`; a baseline admin holds create and delete), the right to edit the record and change the field, and the field must be one the metadata table covers. The row's values are checked against its fields as any record's are.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "description": "The host table's id.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "description": "The host record's id.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "metadataName",
            "in": "path",
            "required": true,
            "description": "The metadata table's name on its host table.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63,
              "pattern": "^[a-z][a-z0-9_]*$"
            }
          },
          {
            "name": "fieldName",
            "in": "path",
            "required": true,
            "description": "The host field the row describes, by name.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63,
              "pattern": "^[a-z_][a-z0-9_]*$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MetadataRowWriteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The row existed and its values were replaced.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetadataRow"
                }
              }
            }
          },
          "201": {
            "description": "The row was created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetadataRow"
                }
              }
            }
          },
          "400": {
            "description": "The field is not one the metadata table covers (`METADATA_FIELD_NOT_COVERED`, naming those it does), `data` names a field the metadata table does not have, or a value fails its field's rules.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks the record action (`PERMISSION_DENIED`), a grant on this metadata table (`METADATA_GRANT_MISSING`), may not edit the record (`METADATA_HOST_NOT_EDITABLE`) or may not change the field (`METADATA_FIELD_NOT_WRITABLE`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such table, record or metadata table, or the record is not visible to the caller; for a delete, no row about the field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The metadata table is append-only and the row exists (`METADATA_APPEND_ONLY`), or a concurrent write created the row first (`METADATA_ROW_EXISTS`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdItemsItemIdMetadataMetadataNameFieldNameDelete",
        "x-permission": "records:read",
        "summary": "Delete a record's metadata row for one field",
        "description": "Deletes the row of metadata table `metadataName` about field `fieldName` of this record. Needs `records:delete`, a delete grant on the metadata table (a baseline admin holds one), and the right to edit the record and change the field.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "description": "The host table's id.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "description": "The host record's id.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "metadataName",
            "in": "path",
            "required": true,
            "description": "The metadata table's name on its host table.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63,
              "pattern": "^[a-z][a-z0-9_]*$"
            }
          },
          {
            "name": "fieldName",
            "in": "path",
            "required": true,
            "description": "The host field the row describes, by name.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63,
              "pattern": "^[a-z_][a-z0-9_]*$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The row is deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks the record action (`PERMISSION_DENIED`), a grant on this metadata table (`METADATA_GRANT_MISSING`), may not edit the record (`METADATA_HOST_NOT_EDITABLE`) or may not change the field (`METADATA_FIELD_NOT_WRITABLE`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such table, record or metadata table, or the record is not visible to the caller; for a delete, no row about the field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The metadata table is append-only and the row exists (`METADATA_APPEND_ONLY`), or a concurrent write created the row first (`METADATA_ROW_EXISTS`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}": {
      "get": {
        "operationId": "tablesTableIdItemsItemIdGet",
        "x-permission": "records:read",
        "summary": "Get a specific item from a data table",
        "description": "One record, row- and field-scoped to the caller. The records of other tables that point at it (`childRecords`) come only when asked for with `include=children`: one group per referencing field, each capped at `childLimit` rows (newest-updated first) and carrying `nextCursor` when more remain. Pass that cursor as `childCursor` to read the next rows of that one relation; the answer then carries that group alone.\n\nOn a table of kind `view` (a SQL view) whose SELECT projects an `id` column, the row whose `id` equals `itemId` (compared as text), with `childRecords` empty when asked for — nothing references a view's rows; reading it requires unrestricted record visibility, as listing the view does. A view with no `id` column has no per-row read: the per-table document omits this operation for it, and the route answers 404 `VIEW_NO_ITEM_ROUTE`.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "description": "`children` adds `childRecords`, the records of other tables that point at this one through a reference field, grouped by that field. Omitted, the answer carries the record alone — a related list can run to thousands of rows, so it is read on request.",
            "schema": {
              "type": "string",
              "enum": [
                "children"
              ]
            }
          },
          {
            "name": "metadata",
            "in": "query",
            "required": false,
            "description": "Adds `metadata`: this record's rows of the named metadata tables, comma-separated, or of every metadata table its table carries with `*`. A name the table does not carry is a 400 `METADATA_TABLE_NOT_FOUND`. Omitted, no metadata is read.",
            "schema": {
              "type": "string",
              "maxLength": 512,
              "pattern": "^(\\*|[a-z][a-z0-9_]{0,62}(,[a-z][a-z0-9_]{0,62})*)$"
            }
          },
          {
            "name": "childLimit",
            "in": "query",
            "required": false,
            "description": "With `include=children`: the most rows each relation's group carries, newest-updated first. Default 50, at most 200; a group with more rows carries `nextCursor`. A 400 without `include=children`.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "childCursor",
            "in": "query",
            "required": false,
            "description": "With `include=children`: a `nextCursor` from a previous answer's group. The answer then carries that one group, continued after the row the cursor names, again up to `childLimit` rows. A cursor is bound to the record it was issued for: a 400 `CHILD_CURSOR_INVALID` on any other record, as for a malformed one, and a 400 without `include=children`.",
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record; with `include=children`, its child-record groups too; with `metadata`, its metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableItemDetail"
                }
              }
            }
          },
          "400": {
            "description": "`childLimit` or `childCursor` given without `include=children`, a `childCursor` this record's relations did not issue, or `metadata` naming a metadata table this table does not carry (`METADATA_TABLE_NOT_FOUND`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Item not found; or the table is a SQL view with no `id` column (`VIEW_NO_ITEM_ROUTE`), whose rows have no per-row read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "tablesTableIdItemsItemIdPut",
        "x-permission": "records:update",
        "summary": "Update an item in a data table",
        "description": "Writes every field present in `data`. Required fields must be included. Optional fields omitted from `data` keep their existing values (this is not a SQL-style full-row null-out). Pass `expectedUpdatedAt` to reject the write with 409 `STALE_RECORD` if another writer changed the row since you last read it; omit it for last-write-wins.\n\nIf an enabled approval rule matches the would-be result, the write is rejected with 409 `APPROVAL_REQUIRED` and nothing changes — request it explicitly via POST /pending-changes. This applies to everyone, including users who could otherwise make the change directly. A write whose named fields all already hold the requested values is not performed: the response is 200 with `changed: false`, the row and its `updatedAt` are untouched, and no event, history entry or automation results.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTableItemRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Item updated, or already in the requested state (`changed` says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableItemUpdateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid item data: `details` says what is wrong per field. When a stage field refused the write the body additionally carries code `TRANSITION_NOT_ALLOWED` and a `transition` object naming the allowed targets; when a unique field or a composite-unique constraint refused it, code `UNIQUE_VIOLATION` and `conflict`, the record it collides with.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordWriteError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The move exists but is not the caller's to make — the edge carries a `transitionActors` gate the caller does not satisfy (code TRANSITION_NOT_PERMITTED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransitionNotPermittedError"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Stale write (code STALE_RECORD — the record changed since expectedUpdatedAt), or an approval rule intercepted the write (code APPROVAL_REQUIRED — nothing changed; request it via POST /pending-changes). Discriminate on `code`. Or the table is mirrored: code `MIRRORED_TABLE_READ_ONLY` (its records are created, deleted and restored only by its sync) or `MIRRORED_FIELD_READ_ONLY` (the write changes mirrored fields, named in `details.fields`).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/StaleRecordError"
                    },
                    {
                      "$ref": "#/components/schemas/ApprovalRequiredError"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "tablesTableIdItemsItemIdPatch",
        "x-permission": "records:update",
        "summary": "Partially update an item in a data table",
        "description": "Updates only the fields present in `data`; other columns are unchanged. Pass `expectedUpdatedAt` to reject the write with 409 `STALE_RECORD` if another writer changed the row since you last read it; omit it for last-write-wins.\n\nIf an enabled approval rule matches the would-be result, the write is rejected with 409 `APPROVAL_REQUIRED` and nothing changes — request it explicitly via POST /pending-changes. This applies to everyone, including users who could otherwise make the change directly. A write whose named fields all already hold the requested values is not performed: the response is 200 with `changed: false`, the row and its `updatedAt` are untouched, and no event, history entry or automation results.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTableItemRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Item updated, or already in the requested state (`changed` says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableItemUpdateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid item data: `details` says what is wrong per field. When a stage field refused the write the body additionally carries code `TRANSITION_NOT_ALLOWED` and a `transition` object naming the allowed targets; when a unique field or a composite-unique constraint refused it, code `UNIQUE_VIOLATION` and `conflict`, the record it collides with.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordWriteError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The move exists but is not the caller's to make — the edge carries a `transitionActors` gate the caller does not satisfy (code TRANSITION_NOT_PERMITTED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransitionNotPermittedError"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Stale write (code STALE_RECORD — the record changed since expectedUpdatedAt), or an approval rule intercepted the write (code APPROVAL_REQUIRED — nothing changed; request it via POST /pending-changes). Discriminate on `code`. Or the table is mirrored: code `MIRRORED_TABLE_READ_ONLY` (its records are created, deleted and restored only by its sync) or `MIRRORED_FIELD_READ_ONLY` (the write changes mirrored fields, named in `details.fields`).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/StaleRecordError"
                    },
                    {
                      "$ref": "#/components/schemas/ApprovalRequiredError"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdItemsItemIdDelete",
        "x-permission": "records:delete",
        "summary": "Move an item to the recycle bin",
        "description": "A soft delete (#84): the record leaves every live read and lands in the table's recycle bin, restorable until the retention window (`records.recycleBinRetentionDays`, default 90 days) purges it. Records referencing it through cascade reference fields go to the bin with it, as one restorable batch. Unique values it held are immediately reusable. Permanent deletion is the bin's DELETE operation.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Item moved to the recycle bin"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Historical (#158): a restrict-cascade refusal. A soft delete is always allowed, so this no longer occurs here — the refusal moved to the bin's permanent-delete operation. Retained for client compatibility during the transition. Or the table is mirrored: code `MIRRORED_TABLE_READ_ONLY` (its records are created, deleted and restored only by its sync) or `MIRRORED_FIELD_READ_ONLY` (the write changes mirrored fields, named in `details.fields`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordInUseError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/mirror-connections": {
      "get": {
        "operationId": "mirrorConnectionsGet",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "List the connections mirrors read from",
        "description": "Every inbound connection in the workspace: the external systems a mirrored table can be kept in step with. Credentials are never returned.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The workspace's inbound connections, by name.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MirrorConnection"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "mirrorConnectionsPost",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "Connect an external system to mirror from",
        "description": "Signs in to the source with the credential given, pins the source's own identity (a Salesforce org id) so the connection can never be re-pointed at another system, and stores the credential encrypted. The credential cannot be read back. For Salesforce, the credential is the consumer key and secret of an External Client App in the org with the client credentials flow enabled, running as an Integration user whose permission set grants read access to exactly what may be mirrored.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMirrorConnectionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The connection, signed in and stored.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MirrorConnection"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "A connection with this name already exists (code `CONNECTION_NAME_TAKEN`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "The source could not be reached or refused the request (code `SOURCE_UNAVAILABLE` or `SOURCE_REFUSED`); the message says why.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/mirror-connections/{connectionId}/objects": {
      "get": {
        "operationId": "mirrorConnectionsConnectionIdObjectsGet",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "List the objects a connection can mirror",
        "description": "Asks the source which of its objects the connection can read and follow, by label. Each call reaches the source and counts against its API allowance.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "description": "The inbound connection.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The source's mirrorable objects.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MirrorSourceObject"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "The source could not be reached or refused the request (code `SOURCE_UNAVAILABLE` or `SOURCE_REFUSED`); the message says why.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/mirror-connections/{connectionId}/objects/{objectName}": {
      "get": {
        "operationId": "mirrorConnectionsConnectionIdObjectsObjectNameGet",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "Describe a source object's fields",
        "description": "The fields of one source object as a mirror would carry them, the field that names a record, and the fields a mirror cannot carry with the reason. Reaches the source.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "description": "The inbound connection.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "objectName",
            "in": "path",
            "required": true,
            "description": "The source's name for the object, such as `Account`.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80,
              "pattern": "^[A-Za-z][A-Za-z0-9_]*$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The object's fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MirrorSourceObjectDescription"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "The source could not be reached or refused the request (code `SOURCE_UNAVAILABLE` or `SOURCE_REFUSED`); the message says why.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/mirrors": {
      "get": {
        "operationId": "mirrorsGet",
        "x-permission": "tables:read",
        "tags": [
          "Mirrors"
        ],
        "summary": "List mirrored tables and their sync status",
        "description": "Every live mirror in the workspace (detached ones are not listed): its table, source, state, how far behind the source it is, its last run and how many problems are open.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The workspace's live mirrors.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MirrorStatus"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "mirrorsPost",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "Mirror a source object into a new table",
        "description": "Creates a table with a field for each chosen source field, binds it to the source object and locks it, then starts the first load (the table fills within a few minutes). A reference field is created only when the object it points at is already mirrored through the same connection; otherwise it is left out and listed in `skipped`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMirrorRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new mirror and its table.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedMirror"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The table name is taken, or the workspace has as many mirrors as its limit allows (code `MIRROR_LIMIT_REACHED`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "The source could not be reached or refused the request (code `SOURCE_UNAVAILABLE` or `SOURCE_REFUSED`); the message says why.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/mirrors/{mirrorId}/fields": {
      "get": {
        "operationId": "mirrorsMirrorIdFieldsGet",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "List a mirror's fields and the source fields it could add",
        "description": "The fields the mirror carries, each with whether it still matches its source field (`drift`), and, read live from the source, the source fields it does not carry yet. Reaches the source.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mirrorId",
            "in": "path",
            "required": true,
            "description": "The mirror.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The mirror's fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MirrorFields"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The mirror has been detached (code `MIRROR_ALREADY_DETACHED`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "The source could not be reached or refused the request (code `SOURCE_UNAVAILABLE` or `SOURCE_REFUSED`); the message says why.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "mirrorsMirrorIdFieldsPost",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "Add source fields to a mirror",
        "description": "Adds a table field for each source field, puts it under the mirror's lock, and fills it on the next sync, which re-reads every record once. A reference is added only when the object it points at is mirrored through the same connection.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mirrorId",
            "in": "path",
            "required": true,
            "description": "The mirror.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MapMirrorFieldsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The mirror's fields after the change.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MirrorFields"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The mirror has been detached (code `MIRROR_ALREADY_DETACHED`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "The source could not be reached or refused the request (code `SOURCE_UNAVAILABLE` or `SOURCE_REFUSED`); the message says why.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/mirrors/{mirrorId}/fields/{fieldId}": {
      "delete": {
        "operationId": "mirrorsMirrorIdFieldsFieldIdDelete",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "Stop mirroring a field",
        "description": "The field keeps its data and becomes an ordinary field, editable in Tessule; the sync no longer writes it. This is how a field whose source field was removed or changed type is let go. The source key (`source_id`) cannot be let go: detach the table instead.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mirrorId",
            "in": "path",
            "required": true,
            "description": "The mirror.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "description": "The mirrored table field.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The field is no longer mirrored."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The mirror has been detached (`MIRROR_ALREADY_DETACHED`), or the field is the source key (`MIRROR_KEY_FIELD`) or the mirror's last field (`MIRROR_LAST_FIELD`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/mirrors/{mirrorId}/issues": {
      "get": {
        "operationId": "mirrorsMirrorIdIssuesGet",
        "x-permission": "tables:read",
        "tags": [
          "Mirrors"
        ],
        "summary": "List a mirror's open sync problems",
        "description": "Problems the sync could not resolve on its own, newest first: a value the field cannot store, a record the table refused, a reference whose target never arrived, a source field that was removed or changed type. Each resolves itself when a later sync applies cleanly. Issues name source records, so they are listed only to a caller who can read every record of the mirror's table (404 otherwise), and a field the caller may not read is not named.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mirrorId",
            "in": "path",
            "required": true,
            "description": "The mirror.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many issues to return (1 to 200, default 50).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "How many issues to skip, for paging.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of open issues.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MirrorIssuePage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/mirrors/{mirrorId}/pause": {
      "post": {
        "operationId": "mirrorsMirrorIdPausePost",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "Pause a mirror",
        "description": "Stop syncing the table. It stays locked: only detaching lifts that.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mirrorId",
            "in": "path",
            "required": true,
            "description": "The mirror.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The mirror's status after the change.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MirrorStatus"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The mirror has been detached (code `MIRROR_ALREADY_DETACHED`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/mirrors/{mirrorId}/resume": {
      "post": {
        "operationId": "mirrorsMirrorIdResumePost",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "Resume a paused mirror",
        "description": "Start syncing again; the next sync runs within a minute or so.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mirrorId",
            "in": "path",
            "required": true,
            "description": "The mirror.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The mirror's status after the change.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MirrorStatus"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The mirror has been detached (code `MIRROR_ALREADY_DETACHED`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/mirrors/{mirrorId}/reconcile": {
      "post": {
        "operationId": "mirrorsMirrorIdReconcilePost",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "Reconcile a mirror now",
        "description": "Compare the table with the source in full on the next sync, catching records deleted at the source and changes the regular sync missed.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mirrorId",
            "in": "path",
            "required": true,
            "description": "The mirror.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The mirror's status after the change.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MirrorStatus"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The mirror has been detached (code `MIRROR_ALREADY_DETACHED`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/mirror/detach": {
      "post": {
        "operationId": "tablesTableIdMirrorDetachPost",
        "x-permission": "mirrors:manage",
        "tags": [
          "Mirrors"
        ],
        "summary": "Detach a mirrored table",
        "description": "Lift a mirrored table's lock for good: the sync stops, the lock is removed, and the table's records and fields become ordinary Tessule data that the workspace's roles govern as usual. The records stay. This cannot be undone: the table is never mirrored again.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "description": "The mirrored table.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The mirror, now detached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MirrorSummary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The table has no mirror (code `MIRROR_NOT_FOUND`) or it is already detached (code `MIRROR_ALREADY_DETACHED`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/deleted-items": {
      "get": {
        "operationId": "tablesTableIdDeletedItemsGet",
        "x-permission": "records:read",
        "summary": "List a table's recycle bin",
        "description": "Soft-deleted records of this table, newest deletion first, under the caller's row scope — you see in the bin exactly what you could see alive (#84). Rows stay here until restored or purged; the retention sweep purges them after `records.recycleBinRetentionDays`. The deletion-time order plus the `id` tie-break make limit/offset paging stable.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum rows to return. When omitted the server still caps the response at 10000 rows — page with limit/offset to read beyond that.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Rows to skip before returning results.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The binned records",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DeletedTableItem"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/deleted-items/{itemId}/restore": {
      "post": {
        "operationId": "tablesTableIdDeletedItemsItemIdRestorePost",
        "x-permission": "records:delete",
        "summary": "Restore a record from the recycle bin",
        "description": "Restores the record AND everything its delete took with it (the cascade batch), atomically — all rows return or none do. Binning and un-binning are the same power, so this rides `records:delete`. A restored value colliding with a live record's unique value refuses the whole restore with a 409 naming the rule, exactly as the write path would.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record is live again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestoreDeletedItemResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such record in this table's bin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Restoring would collide with a live record's unique value (code `RESTORE_CONFLICT`), or the record's table is mirrored (code `MIRRORED_TABLE_READ_ONLY`): only its sync restores what the source deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestoreConflictError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/deleted-items/{itemId}": {
      "delete": {
        "operationId": "tablesTableIdDeletedItemsItemIdDelete",
        "x-permission": "records:delete",
        "summary": "Permanently delete a binned record",
        "description": "The irreversible half (#84): physically deletes the binned record; the database applies each reference field's cascade behaviour (cascade children — already binned with it — go too, set-null references are nulled). Any record still pointing here through a restrict reference — live, or itself binned — refuses the purge with 409, keeping the row in the bin: purge the referencing record first. A record something still references is never silently lost, and the retention sweep converges the same way, children before parents.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Purged forever"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such record in this table's bin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A record (live or binned) still references this one through a restrict-cascade reference field (#158 semantics, at purge time).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordInUseError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/record-layout": {
      "get": {
        "operationId": "tablesTableIdRecordLayoutGet",
        "x-permission": "customization:read",
        "summary": "Get the record page layout this caller sees for a table",
        "description": "With no `ownerScope`, returns the layout RESOLVED for the caller: their own document if one existed, else their active group's, else the workspace's (see `CustomizationTargetScope`) — so Sales can open a Deal on a sales-shaped page while Finance sees billing fields foregrounded. `ownerScope` on the response names which document answered.\n\nAlways 200 for a table the caller can see — one with nothing configured returns `configured: false` and an empty layout, and the client falls back to rendering every field. A role lacking customization:read degrades the same way rather than erroring.\n\nPassing `ownerScope` addresses ONE document instead of resolving, which is what the layout editor does.",
        "tags": [
          "DataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "ownerScope",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/CustomizationTargetScope"
            },
            "description": "Address one document rather than resolving for the caller."
          },
          {
            "name": "ownerGroupId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "Required with `ownerScope=group`."
          },
          {
            "name": "viewAsGroupId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "Resolve as a member of this group would see it (M8.6b \"View as\"), instead of for the caller's own active group. Needs `customization:manage`, and the group must be an active group of this workspace; membership is not required, matching the rule for WRITING a group's document.\n\nDistinct from `ownerScope`/`ownerGroupId` above, which ADDRESS one stored document and report `configured: false` when that audience has none. This RESOLVES: the group's document if it has one, the workspace's otherwise — what a member actually sees. The caller's own `user`-tier document is deliberately left out of that resolution, since it is not something the group would ever see.\n\nPresentation only. It changes which customization document is returned and nothing else: no permission, no row or field visibility, and no write is affected by it, exactly as the caller's own active group is never an authorization input. The app shows a banner while it is in force so it cannot be mistaken for acting as that group."
          }
        ],
        "responses": {
          "200": {
            "description": "The resolved (or addressed) record layout",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableRecordLayout"
                }
              }
            }
          },
          "400": {
            "description": "ownerScope=group without a valid ownerGroupId",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "tablesTableIdRecordLayoutPut",
        "x-permission": "customization:manage",
        "summary": "Replace a table's record page layout",
        "description": "Full replace. Field ids must name fields of the table or computed columns the caller can see (`DerivedField.id`) — names, or ids that resolve to nothing, are refused with 400 `LAYOUT_UNKNOWN_FIELD_IDS` and listed in `unknownFieldIds`. Once stored they are resolved at render time: a field deleted later is skipped rather than breaking the page, and any field the layout does not mention still appears in an auto-generated Details section, so a layout can never hide data.\n\nWrites the workspace's own layout unless `ownerScope: group` targets a group's, which is an independent document: a group layout arranges the same fields differently, it does not restrict them.\n\nAn `extension` block must name the workspace's own hosted site, else 400 `EXTENSION_SITE_UNKNOWN`. The extension itself need not be in the active deployment, so a layout survives a redeploy.",
        "tags": [
          "DataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRecordLayoutRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated layout",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableRecordLayout"
                }
              }
            }
          },
          "400": {
            "description": "Invalid layout (including ids that name no field or visible computed column of the table), the table is a SQL view (no record page to arrange), or an unusable group target",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordLayoutRefusal"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdRecordLayoutDelete",
        "x-permission": "customization:manage",
        "summary": "Discard a table's record page layout",
        "description": "Discards the workspace's layout (reverting to the default record page), or a group's when `ownerScope=group` is given — after which that group inherits whatever the workspace has. Idempotent — 204 whether or not a layout existed.",
        "tags": [
          "DataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "ownerScope",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/CustomizationTargetScope"
            },
            "description": "Which document to discard. Defaults to `workspace`."
          },
          {
            "name": "ownerGroupId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "Required with `ownerScope=group`."
          }
        ],
        "responses": {
          "204": {
            "description": "Layout discarded"
          },
          "400": {
            "description": "ownerScope=group without a valid ownerGroupId",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/record-layout/mine": {
      "put": {
        "operationId": "tablesTableIdRecordLayoutMinePut",
        "x-permission": "customization:read",
        "summary": "Replace my own record page layout for a table",
        "description": "Writes the caller's PERSONAL layout for this table — the tier above their group's, so from now on this is the record page they get.\n\nA separate path rather than an `ownerScope` on the shared write, because the two are different acts with different rules. Arranging your own page is an ordinary end-user act and needs only `customization:read`; writing the layout a team or the whole workspace inherits is configuration and needs `customization:manage`. Keeping them apart means this endpoint has no way to name a shared document even by mistake — the owner is the authenticated caller, full stop.\n\nA personal layout is presentation only, exactly as a shared one is: a field left out of it still renders under Details, and every value still comes through the scoped record endpoints. Arranging your own page can no more hide data from you than an admin's arrangement can.\n\nAn `extension` block must name the workspace's own hosted site, else 400 `EXTENSION_SITE_UNKNOWN`.",
        "tags": [
          "DataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMyRecordLayoutRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated personal layout",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableRecordLayout"
                }
              }
            }
          },
          "400": {
            "description": "Invalid layout, including ids that name no field or visible computed column of the table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordLayoutRefusal"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdRecordLayoutMineDelete",
        "x-permission": "customization:read",
        "summary": "Discard my own record page layout for a table",
        "description": "\"Reset to my team's\": discards the caller's personal layout for this table, after which they resolve to their active group's layout, or the workspace's. Touches no shared document and nobody else's. Idempotent — 204 whether or not a personal layout existed.",
        "tags": [
          "DataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Personal layout discarded"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/record-layout/targets": {
      "get": {
        "operationId": "tablesTableIdRecordLayoutTargetsGet",
        "x-permission": "customization:manage",
        "summary": "Which layouts exist for a table, and which groups can be targeted",
        "description": "The layout editor's target picker — the same shape as `/workspace/homepage/targets`, for one table.",
        "tags": [
          "DataTables"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Configured layouts and targetable groups",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomizationTargets"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/saved-views": {
      "get": {
        "operationId": "tablesTableIdSavedViewsGet",
        "x-permission": "customization:read",
        "summary": "List a table's saved list views",
        "description": "The caller's own private views, the views shared with the whole workspace, and the views targeted at a group they belong to — all of them, not only their active group's, because a list picker has room for every arrangement and needs no tiebreak. Another user's private views are never returned, nor another group's; a holder of `customization:manage` sees every group's, since they may write them.\n\nThese are LIST views — a remembered filter, sort and column arrangement over `GET /tables/{tableId}/items`. They are unrelated to the SQL `views` resource, which is an analyst primitive that defines a derived table.",
        "tags": [
          "SavedViews"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Saved views visible to the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedViewList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesTableIdSavedViewsPost",
        "x-permission": "customization:read",
        "summary": "Create a saved list view",
        "description": "Defaults to a private (`user`-scoped) view owned by the caller. Creating a `workspace`- or `group`-scoped view requires `customization:manage` and is refused with 403 otherwise. Names must be unique within the scope the view is created in — each group has its own namespace, so Sales and Finance may both have an \"Open pipeline\".",
        "tags": [
          "SavedViews"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSavedViewRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedView"
                }
              }
            }
          },
          "400": {
            "description": "Invalid view configuration, the table is a SQL view, or `group` scope without a group of this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A shared or group view was requested without customization:manage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "`VIEW_NAME_TAKEN` — a view of that name already exists in this scope, or `VIEW_DEFAULT_CONFLICT` — another view became the default for this table, scope and kind at the same moment. The two ask the client for opposite things: the first needs a different name, the second needs nothing changed at all and succeeds on retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/saved-views/{viewId}": {
      "get": {
        "operationId": "tablesTableIdSavedViewsViewIdGet",
        "x-permission": "customization:read",
        "summary": "Get one saved list view",
        "description": "404 for another user's private view, or a group's the caller neither belongs to nor may manage — the same answer as a view that does not exist, so the endpoint is not an existence oracle.",
        "tags": [
          "SavedViews"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "viewId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The saved view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedView"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or view not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "tablesTableIdSavedViewsViewIdPut",
        "x-permission": "customization:read",
        "summary": "Replace a saved list view's name and configuration",
        "description": "A private view can only be edited by its owner; a shared or group view requires `customization:manage`. `ownerScope` cannot be changed here — moving a view between private, group and shared changes its audience, so it is a deliberate create-and-delete.",
        "tags": [
          "SavedViews"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "viewId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSavedViewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedView"
                }
              }
            }
          },
          "400": {
            "description": "Invalid view configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A shared or group view was edited without customization:manage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table or view not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "`VIEW_NAME_TAKEN` — a view of that name already exists in this scope; `VIEW_DEFAULT_CONFLICT` — another view became the default for this table, scope and kind at the same moment; or `VIEW_LOCKED` — the view's `config.locked` is true and this write would change its config without clearing the lock. They ask the client for different things: the first needs a different name, the second needs nothing changed at all and succeeds on retry, the third needs the person to unlock the view deliberately (the `lockMessage` says why it was locked).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdSavedViewsViewIdDelete",
        "x-permission": "customization:read",
        "summary": "Delete a saved list view",
        "description": "Owner-only for a private view; `customization:manage` for a shared or group one. Idempotent for a view the caller can see and delete.",
        "tags": [
          "SavedViews"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "viewId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "View deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A shared or group view was deleted without customization:manage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table or view not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/saved-views/{viewId}/watch": {
      "put": {
        "operationId": "tablesTableIdSavedViewsViewIdWatchPut",
        "x-permission": "records:read",
        "summary": "Watch a saved list view",
        "description": "Be told when a record enters this view: every few minutes the view's filter is evaluated under the CALLER's own permissions, and each matching record raises one `record.viewMatched` notification for them — a condition that reconciles while the record stays in the view and clears by itself when it leaves. A watch on \"faults over their target\" is therefore the SLA breach notification, with no policy object, and a watcher scoped to their own records is told about their own records only. 404 for a view the caller cannot see, exactly as reading it. Idempotent.",
        "tags": [
          "SavedViews"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "viewId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Now watching",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedViewWatch"
                }
              }
            }
          },
          "400": {
            "description": "The view has no filter. Every record is a list, not a condition a record can enter, so such a watch would never notify anyone; add a condition to the view first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or view not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdSavedViewsViewIdWatchDelete",
        "x-permission": "records:read",
        "summary": "Stop watching a saved list view",
        "description": "Removes the caller's watch and resolves their open `record.viewMatched` notifications for the view at once. Not gated on still being able to see the view: a watch on a view the caller has lost sight of is the one they most need to be able to drop. Idempotent.",
        "tags": [
          "SavedViews"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "viewId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "No longer watching",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedViewWatch"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/history": {
      "get": {
        "operationId": "tablesTableIdItemsItemIdHistoryGet",
        "x-permission": "audit:read",
        "summary": "Get one record's change history",
        "description": "The audit trail for a single record, newest first, built from the application-event log.\nDeliberately narrower than `GET /audit/events`, which is workspace-wide and not row-scoped: this endpoint resolves the record through the caller's row filter first (404 if they cannot see it) and masks the before/after states to the fields they may read, so history can be shown to ordinary users beside the record itself.\nGated on `audit:read` rather than `records:read` — this is audit data, and who may see a record's change history stays a separate, grantable decision from who may see the record.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum entries to return (default 50).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record's history, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordHistory"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Record not found, or not visible to the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/stage-history": {
      "get": {
        "operationId": "tablesTableIdItemsItemIdStageHistoryGet",
        "x-permission": "records:read",
        "summary": "Get one record's stage timeline",
        "description": "Every move of this record's stage-designated fields, newest first.\n\nGated on `records:read`, not `audit:read` — unlike the change-history endpoint next door, this is **product data** rather than audit: how long a deal sat in each stage is something anyone who can see the deal should see. It is row-scoped (404 when the caller cannot see the record) and field-masked (a stage field the caller may not read contributes no entries), so it is safe to show beside the record itself.\n\nHistory starts when the field was designated: nothing is reconstructed for earlier moves, so an empty timeline on an old record means \"not recorded\", not \"never moved\". Designating with `snapshotExisting` (or the snapshot endpoint) gives such records one `snapshot` baseline row — `null → current value`, dated at the snapshot — which bounds `enteredAt` and makes their first real move measurable.",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "query",
            "required": false,
            "description": "Restrict to one stage field. Omit for every stage field on the record.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum entries to return (default 50).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from a previous response's `nextCursor`. Keyset pagination, so a page boundary stays stable while new transitions are being written.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record's stage timeline, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StageHistory"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Record not found, or not visible to the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/stage-transitions": {
      "get": {
        "operationId": "tablesTableIdStageTransitionsGet",
        "x-permission": "records:read",
        "summary": "Recent stage moves across a whole table, oldest first",
        "description": "The pollable form of the per-record stage timeline: what has moved\nsince you last looked, in the order it happened, each entry carrying\nthe record it happened to. Built for integrations — \"when a deal\nreaches Won, do something\" — which otherwise have to poll every record\nto notice a stage change.\n\n`cursor` is a watermark rather than a page boundary: keep the\n`nextCursor` from each call and send it back on the next one, and you\nreceive each move exactly once. It stays valid indefinitely. Omitting\nit starts at the beginning of the table's recorded history.\n\nSame visibility rules as anything else that returns records. A stage\nfield you cannot read contributes no entries, and a move to a record\nyou cannot see is omitted — so a page can hold fewer entries than its\nlimit, and `hasMore` rather than a full page is what tells you to poll\nagain.\n",
        "tags": [
          "StageHistory"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "query",
            "required": false,
            "description": "Restrict to one stage field. Omit for every stage field on the table.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum entries to return (default 50).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The `nextCursor` from your previous call.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stage moves since the cursor, oldest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StageTransitionFeed"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/stage-transitions/seed": {
      "post": {
        "operationId": "tablesTableIdStageTransitionsSeedPost",
        "x-permission": "fields:manage",
        "summary": "Seed backdated stage history for existing records (a migrated system's history, or sandbox demo data)",
        "description": "Write a believable stage timeline for records that already exist — the way migrated records get the history they had in the system they came from, and demo data gets one without moving records in real time. This is how stage history is backdated: the stage-config snapshot (`snapshotDating`) only dates records that have no history yet and cannot move an existing row, and a record loaded by import already carries an import-time `null → current` baseline unless the import job supplied `stageHistory` — so an already-imported table is backdated with `replace: true` (sandbox only), which removes the records' `import` and `seeded` rows first. Each entry is one move of one record's stage field at an instant in the past; entries for the same record and field are applied in `occurredAt` order, chained from the record's latest recorded transition (or from nothing), checked against the field's transition matrix exactly as a live write would be, and the last move must land on the value the record holds now (400 `SEED_FINAL_VALUE_MISMATCH`) — the log and the row may never disagree. Timestamps must be strictly increasing per record and field, not earlier than existing history (400 `OCCURRED_AT_OUT_OF_ORDER`) and not in the future. Rows are written with the request's `source`, all in one transaction. With `source` `seeded` (the default) the call is refused on a production workspace (400 `SANDBOX_ONLY`); with `source` `import` — history migrated from another system — it is allowed on any workspace for a caller who also holds `records:backfillHistory` (403 otherwise). An import job does the same from a file (`ImportJobRequest.stageHistory`). Records the caller cannot read are 404.",
        "tags": [
          "StageConfig"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StageTransitionSeedRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Seeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StageTransitionSeedResult"
                }
              }
            }
          },
          "400": {
            "description": "Not a sandbox, a move the matrix refuses, an out-of-order timestamp, or a final value that does not match the record",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table, stage field, or record not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/comments": {
      "get": {
        "operationId": "tablesTableIdItemsItemIdCommentsGet",
        "x-permission": "comments:read",
        "summary": "List the discussion on one record",
        "description": "User-authored comments on a record, oldest first (a conversation reads forwards, unlike the history timeline).\nComments derive their visibility entirely from the parent record: this endpoint resolves the record through the caller's row filter first and returns 404 if they cannot see it, so a comment can never be visible to someone the record is not. Comments carry no row-scope policy of their own.\nReturns 404 when the table has `commentsEnabled: false` — the sub-resource does not exist for that table, which is a statement about the resource rather than about the caller.",
        "tags": [
          "RecordComments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum comments to return (default 50).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record's comments, oldest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordCommentPage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Record not found, not visible to the caller, or comments are not enabled on this table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesTableIdItemsItemIdCommentsPost",
        "x-permission": "comments:create",
        "summary": "Post a comment on a record",
        "description": "Requires only READ row scope on the record, deliberately: commenting on a record is not editing it, and a person who may see a deal but not change it is exactly the person a discussion exists for. The write capability lives on the action axis (`comments:create`).\nMentions are parsed from the body by the server — never taken from the client — so the stored mention rows and the body cannot disagree. A mention of someone who cannot see the record is stored but NOT notified, and is reported back in `undeliverableMentions` so the author learns their summons went nowhere instead of waiting for a reply.",
        "tags": [
          "RecordComments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRecordCommentRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created comment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateRecordCommentResponse"
                }
              }
            }
          },
          "400": {
            "description": "Body empty, too long, or containing a malformed mention token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Record not found, not visible to the caller, or comments are not enabled on this table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/comments/{commentId}": {
      "patch": {
        "operationId": "tablesTableIdItemsItemIdCommentsCommentIdPatch",
        "x-permission": "comments:create",
        "summary": "Edit your own comment",
        "description": "AUTHOR ONLY. There is deliberately no moderator path to this operation: `comments:moderate` permits tombstoning, never rewriting, so that a comment's attribution means what it says. A non-author gets 403 however privileged they are.\nSets `editedAt`, which the UI renders as an \"(edited)\" marker — an edit is never silent. The content history is already carried by the audit log behind `audit:read`.",
        "tags": [
          "RecordComments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "commentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRecordCommentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The edited comment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateRecordCommentResponse"
                }
              }
            }
          },
          "400": {
            "description": "Body empty, too long, or containing a malformed mention token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not the author — no permission level grants editing someone else's words",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Record or comment not found, not visible to the caller, or comments are not enabled on this table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "tablesTableIdItemsItemIdCommentsCommentIdDelete",
        "x-permission": "comments:create",
        "summary": "Delete a comment",
        "description": "Permitted for the author, or for a caller holding `comments:moderate` (refined in the controller rather than the annotation, the way personal derived views are).\nTombstones rather than removes: the row survives so the thread's shape survives, but the body is emptied — a database CHECK enforces that a deleted comment holds no text, so deletion is a structural guarantee and not a rule the read path has to remember. Accountability for a moderator's deletion lives in the audit log.",
        "tags": [
          "RecordComments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "commentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The tombstoned comment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordComment"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not the author, and not holding comments:moderate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Record or comment not found, not visible to the caller, or comments are not enabled on this table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/comments/{commentId}/resolution": {
      "put": {
        "operationId": "tablesTableIdItemsItemIdCommentsCommentIdResolutionPut",
        "x-permission": "comments:create",
        "summary": "Resolve or reopen a thread",
        "description": "Settles a discussion thread, or takes it up again. Addressed at the thread's ROOT comment (a reply answers 400); any caller holding `comments:create` who may see the subject can resolve or reopen a thread, not only its author — a reviewer closes the question they asked, or the one they answered. Idempotent: resolving a resolved thread is a no-op 200. A resolved thread folds by default in the discussion, and on a record the change is also an entry in the record's history (`CommentResolved` / `CommentReopened`).",
        "tags": [
          "RecordComments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "commentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommentResolutionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The root comment, with its resolution as it now stands",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordComment"
                }
              }
            }
          },
          "400": {
            "description": "The comment is a reply, not a thread's root, or the body is malformed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Record or comment not found, not visible to the caller, or comments are not enabled on this table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/activities": {
      "get": {
        "operationId": "tablesTableIdItemsItemIdActivitiesGet",
        "x-permission": "records:read",
        "summary": "The record's activity timeline",
        "description": "Activities linked to this record, newest first. Two visibility axes, both enforced: the parent record resolves through the caller's row filter first (404 when they cannot see it), and each linked activity is then re-fetched under the ACTIVITIES table's own read scope with field masking — an activity the caller cannot read, a binned one, or a dangling link is silently omitted, so a page may run short of the requested limit. On a record of the activities table itself this lists activities ABOUT it, which is always empty today (activity-to-activity links are refused); its own targets are the activity-links endpoint.",
        "tags": [
          "ActivityLinks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum entries to return (default 50).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The record's linked activities, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivityTimelinePage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Record not found or not visible to the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesTableIdItemsItemIdActivitiesPost",
        "x-permission": "records:update",
        "summary": "Attach an activity to this record",
        "description": "Idempotent 200 — attaching a link that already exists returns the existing link (attaches serialize per activity, so retries, agents and bulk callers converge on the same link; a 409 would encode nothing the caller lacks). The parent record needs only READ row scope, deliberately: the person who may see a deal but not edit it is exactly who logs the call. Write capability is checked on the ACTIVITY side — the activity must resolve under the caller's UPDATE scope on the activities table. Activity-to-activity links are refused (400), as is the 26th link on one activity (a fixed cap of 25).",
        "tags": [
          "ActivityLinks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttachActivityRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The link (created now, or already present)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachActivityResponse"
                }
              }
            }
          },
          "400": {
            "description": "Activity-to-activity link, or the activity already carries 25 links",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Record not found or not visible to the caller, or the activity does not resolve under the caller's update scope on the activities table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/activities/{activityId}": {
      "delete": {
        "operationId": "tablesTableIdItemsItemIdActivitiesActivityIdDelete",
        "x-permission": "records:update",
        "summary": "Detach an activity from this record",
        "description": "Idempotent 204 — detaching a link that is already gone succeeds. A link is shared state about the record, not attributed speech, so there is no author-only rule. Addressed at the link: the activity must resolve under the caller's UPDATE scope on the activities table (or be gone entirely, so dangling links stay removable), while the parent record is deliberately NOT resolved — the reverse read shows out-of-scope targets as bare-id tombstones precisely so their links remain detachable.",
        "tags": [
          "ActivityLinks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "activityId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The link is gone (whether or not it existed)"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table not found, or the activity exists but does not resolve under the caller's update scope on the activities table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/activity-links": {
      "get": {
        "operationId": "tablesTableIdItemsItemIdActivityLinksGet",
        "x-permission": "records:read",
        "summary": "The records this activity regards",
        "description": "The reverse read, on a record of the activities table: its \"Regarding\" targets with labels. Targets the caller cannot read are masked to the bare-id tombstone (ids only, no label) rather than omitted — a silently shorter list would make detach unreachable for links the caller legitimately holds; 12-hex ids already flow for out-of-scope reference values, labels never do. On a record that is not an activity the list is empty.",
        "tags": [
          "ActivityLinks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The activity's link targets",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivityLinkTargetsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Record not found or not visible to the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/references": {
      "get": {
        "operationId": "tablesTableIdItemsItemIdReferencesGet",
        "x-permission": "records:read",
        "summary": "Count the records that reference this one",
        "description": "Preflight for a delete: which live records point at this one, grouped by the referencing field, so the UI can WARN before binning it without blocking the delete.\nDeleting is a soft mark into the recycle bin (#84), and the bin deliberately keeps inbound references intact so a restore puts the graph back exactly as it was. The cost is that a `restrict`/`set_null` referrer stays live holding a reference to a row that reads as absent everywhere else — the dangling reference this endpoint lets the UI warn about, and that `ReferenceOptionHit.deleted` lets it render as a tombstone. Entries with `cascade: true` are not that case: those records go to the bin in the same batch.\nCounts honour the caller's row scope on each referencing table, so this never reveals the existence of rows the caller cannot read.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inbound reference counts, grouped by referencing field",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordReferencesResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or item not found; or the table is a SQL view (`VIEW_NO_ITEM_ROUTE`), whose rows nothing references and which cannot be deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/expanded": {
      "get": {
        "operationId": "tablesTableIdItemsItemIdExpandedGet",
        "x-permission": "records:read",
        "summary": "Get an item with all reference fields expanded",
        "description": "Returns the item with every reference field replaced by the full referenced object (recursively, up to depth 5). Returns 400 if the reference graph exceeds the depth limit. Circular references are broken automatically.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Item with reference fields expanded to full nested objects",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Reference graph exceeds maximum expansion depth of 5",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or item not found; or the table is a SQL view (`VIEW_NO_ITEM_ROUTE`), whose columns are never references to expand — read its row with `GET /tables/{tableId}/items/{itemId}`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/shares": {
      "get": {
        "operationId": "tablesTableIdItemsItemIdSharesGet",
        "x-permission": "records:read",
        "summary": "List shares on a record",
        "tags": [
          "RecordShares"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Shares on this record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RecordShare"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "tablesTableIdItemsItemIdSharesPost",
        "x-permission": "records:update",
        "summary": "Share a record with a user or group",
        "description": "Grants view or edit access to one record, additive to role scopes. Requires update access to the record. Exactly one of userId or groupId.",
        "tags": [
          "RecordShares"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "userId": {
                    "type": "string"
                  },
                  "groupId": {
                    "type": "string"
                  },
                  "accessLevel": {
                    "type": "string",
                    "enum": [
                      "view",
                      "edit"
                    ],
                    "default": "view"
                  },
                  "reason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Record shared",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordShare"
                }
              }
            }
          },
          "400": {
            "description": "Invalid principal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table or item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Share already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/shares/{shareId}": {
      "delete": {
        "operationId": "tablesTableIdItemsItemIdSharesShareIdDelete",
        "x-permission": "records:update",
        "summary": "Remove a share from a record",
        "tags": [
          "RecordShares"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "shareId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Share removed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Share not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/fields/{fieldId}/attachments": {
      "post": {
        "operationId": "attachmentsUpload",
        "x-permission": "attachments:manage",
        "summary": "Start a presigned upload for an attachment",
        "description": "Returns presigned upload details for uploading a file directly to\nS3/MinIO. Small files get a single-PUT uploadUrl; large files switch to\nmultipart (uploadId/partSize/partUrls — PUT each chunk, collect ETags,\nthen call the multipart-complete endpoint). After the file is uploaded,\ncall the confirm endpoint to save the attachment metadata.\n",
        "tags": [
          "Attachments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "filename",
                  "mimeType",
                  "size"
                ],
                "properties": {
                  "filename": {
                    "type": "string"
                  },
                  "mimeType": {
                    "type": "string"
                  },
                  "size": {
                    "type": "integer",
                    "description": "File size in bytes"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Presigned upload created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PresignedUpload"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not authorized to upload to this item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table, item, or field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/fields/{fieldId}/attachments/multipart-complete": {
      "post": {
        "operationId": "attachmentsMultipartComplete",
        "x-permission": "attachments:manage",
        "summary": "Complete a multipart attachment upload",
        "description": "Call after all parts have been uploaded, passing each part's ETag\nresponse header. Then call the confirm endpoint to save the\nattachment metadata.\n",
        "tags": [
          "Attachments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "s3Key",
                  "uploadId",
                  "parts"
                ],
                "properties": {
                  "s3Key": {
                    "type": "string"
                  },
                  "uploadId": {
                    "type": "string"
                  },
                  "parts": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "required": [
                        "partNumber",
                        "etag"
                      ],
                      "properties": {
                        "partNumber": {
                          "type": "integer",
                          "minimum": 1
                        },
                        "etag": {
                          "type": "string",
                          "description": "ETag response header from uploading the part"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Upload completed"
          },
          "400": {
            "description": "Upload could not be completed (missing or invalid parts)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Invalid S3 key for this context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table, item, or field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/fields/{fieldId}/attachments/multipart-abort": {
      "post": {
        "operationId": "attachmentsMultipartAbort",
        "x-permission": "attachments:manage",
        "summary": "Abort a multipart attachment upload",
        "description": "Frees the storage held by an unfinished multipart upload. Idempotent.",
        "tags": [
          "Attachments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "s3Key",
                  "uploadId"
                ],
                "properties": {
                  "s3Key": {
                    "type": "string"
                  },
                  "uploadId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Upload aborted (or already gone)"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Invalid S3 key for this context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table, item, or field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/fields/{fieldId}/attachments/confirm": {
      "post": {
        "operationId": "attachmentsConfirm",
        "x-permission": "attachments:manage",
        "summary": "Confirm attachment upload and save metadata",
        "description": "Called after successfully uploading a file to the presigned URL.\nSaves the attachment metadata to the item's field data.\n",
        "tags": [
          "Attachments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "s3Key",
                  "filename",
                  "mimeType",
                  "size"
                ],
                "properties": {
                  "s3Key": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mimeType": {
                    "type": "string"
                  },
                  "size": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Attachment confirmed and saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Attachment"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Table, item, or field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/fields/{fieldId}/attachment": {
      "get": {
        "operationId": "attachmentGet",
        "x-permission": "attachments:read",
        "summary": "Get a presigned download URL for a field's attachment",
        "tags": [
          "Attachments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "variant",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "thumb",
                "preview"
              ]
            },
            "description": "Ask for a downscaled rendition of an image attachment instead of the original: `thumb` (128px, for a grid cell) or `preview` (1024px, for an inline preview). Omit for the original file — which is what a download control wants. The rendition is generated on first request and cached beside the original; a non-image attachment, or one too large to downscale, transparently serves the original, so a caller never has to special-case the fallback."
          }
        ],
        "responses": {
          "200": {
            "description": "Presigned download URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "downloadUrl"
                  ],
                  "properties": {
                    "downloadUrl": {
                      "type": "string",
                      "description": "Presigned URL for downloading the file"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The field holds no attachment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "attachmentDelete",
        "x-permission": "attachments:manage",
        "summary": "Delete a field's attachment",
        "tags": [
          "Attachments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Attachment deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The field holds no attachment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/items/{itemId}/fields/{fieldId}/attachments/{s3Key}": {
      "get": {
        "operationId": "attachmentsDownload",
        "deprecated": true,
        "x-permission": "attachments:read",
        "summary": "Get a presigned download URL for an attachment (deprecated)",
        "description": "Deprecated in favour of `GET /tables/{tableId}/items/{itemId}/fields/{fieldId}/attachment`, which names the same file without putting the S3 key in the URL path. The key contains slashes, and a percent-encoded slash in a path segment is decoded back to `/` by API Gateway before it reaches the application — so this operation 404s behind such a gateway however correctly the client encodes it. Retained for existing clients on deployments where it does work; the field's attachment is the same either way.",
        "tags": [
          "Attachments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "s3Key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "URL-encoded S3 key"
          },
          {
            "name": "variant",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "thumb",
                "preview"
              ]
            },
            "description": "Ask for a downscaled rendition of an image attachment instead of the original: `thumb` (128px, for a grid cell) or `preview` (1024px, for an inline preview). Omit for the original file — which is what a download control wants. The rendition is generated on first request and cached beside the original; a non-image attachment, or one too large to downscale, transparently serves the original, so a caller never has to special-case the fallback."
          }
        ],
        "responses": {
          "200": {
            "description": "Presigned download URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "downloadUrl"
                  ],
                  "properties": {
                    "downloadUrl": {
                      "type": "string",
                      "description": "Presigned URL for downloading the file"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Attachment not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "attachmentsDelete",
        "deprecated": true,
        "x-permission": "attachments:manage",
        "summary": "Delete an attachment (deprecated)",
        "description": "Deprecated in favour of `DELETE /tables/{tableId}/items/{itemId}/fields/{fieldId}/attachment` — same encoded-slash problem as the GET above.",
        "tags": [
          "Attachments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "s3Key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "URL-encoded S3 key"
          }
        ],
        "responses": {
          "204": {
            "description": "Attachment deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Attachment not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/fields/{fieldId}/attachments/staged": {
      "post": {
        "operationId": "attachmentsStagedUpload",
        "x-permission": "attachments:manage",
        "summary": "Start a presigned upload for an attachment on a not-yet-created record",
        "description": "Returns presigned upload details for uploading a file directly to\nS3/MinIO under a staging key, before the record it belongs to exists.\nSmall files get a single-PUT uploadUrl; large files switch to multipart\n(uploadId/partSize/partUrls — PUT each chunk, collect ETags, then call\nthe staged multipart-complete endpoint). After uploading, pass the\nattachment metadata (with the staged s3Key) as the field's value when\ncreating the record; the create endpoint verifies the staged object\nand moves it to its canonical per-record key.\n\nA staged upload is private to the user who staged it: the staged key\nis bound to that user, only they can complete, abort, or bind it to a\nrecord, and there is no way to read a staged object until it has been\nattached to a record.\n",
        "tags": [
          "Attachments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "filename",
                  "mimeType",
                  "size"
                ],
                "properties": {
                  "filename": {
                    "type": "string"
                  },
                  "mimeType": {
                    "type": "string"
                  },
                  "size": {
                    "type": "integer",
                    "description": "File size in bytes"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Presigned upload created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PresignedUpload"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not authorized to upload to this field",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table or field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/fields/{fieldId}/attachments/staged/multipart-complete": {
      "post": {
        "operationId": "attachmentsStagedMultipartComplete",
        "x-permission": "attachments:manage",
        "summary": "Complete a staged multipart attachment upload",
        "description": "Call after all parts of a staged upload have been uploaded, passing\neach part's ETag response header. Then pass the attachment metadata as\nthe field's value when creating the record.\n",
        "tags": [
          "Attachments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "s3Key",
                  "uploadId",
                  "parts"
                ],
                "properties": {
                  "s3Key": {
                    "type": "string"
                  },
                  "uploadId": {
                    "type": "string"
                  },
                  "parts": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "required": [
                        "partNumber",
                        "etag"
                      ],
                      "properties": {
                        "partNumber": {
                          "type": "integer",
                          "minimum": 1
                        },
                        "etag": {
                          "type": "string",
                          "description": "ETag response header from uploading the part"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Upload completed"
          },
          "400": {
            "description": "Upload could not be completed (missing or invalid parts)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Invalid S3 key for this context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table or field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/fields/{fieldId}/attachments/staged/multipart-abort": {
      "post": {
        "operationId": "attachmentsStagedMultipartAbort",
        "x-permission": "attachments:manage",
        "summary": "Abort a staged multipart attachment upload",
        "description": "Frees the storage held by an unfinished staged multipart upload. Idempotent.",
        "tags": [
          "Attachments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "s3Key",
                  "uploadId"
                ],
                "properties": {
                  "s3Key": {
                    "type": "string"
                  },
                  "uploadId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Upload aborted (or already gone)"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Invalid S3 key for this context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table or field not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/feedback": {
      "post": {
        "operationId": "feedbackPost",
        "summary": "Submit feedback",
        "description": "Creates an issue of type 'feedback' (the default). Attachments must first\nbe uploaded — from a browser via the presigned URL from\nPOST /feedback/attachments, or from a non-browser client (an AI agent\nover MCP) by posting the bytes to POST /feedback/attachments/content —\nand the returned s3Keys passed here. The submission itself cannot be\nedited or deleted; follow-ups go on the thread via\nPOST /feedback/{feedbackId}/comments.\n",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "message"
                ],
                "properties": {
                  "message": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Short headline for the issue. Optional; the widget omits it and agents are expected to supply one.\n"
                  },
                  "type": {
                    "$ref": "#/components/schemas/IssueType"
                  },
                  "context": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Client context (page, user agent, viewport, ...). An AI agent should put the reproduction detail here — what it was trying to do, the tool it called, the arguments, the error it got back.\n"
                  },
                  "agent": {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueReporterAgent"
                      }
                    ],
                    "description": "Identifies the AI agent filing on the user's behalf. Recorded as self-reported; the server independently records the OAuth client the token was issued to.\n"
                  },
                  "attachments": {
                    "type": "array",
                    "maxItems": 5,
                    "items": {
                      "type": "object",
                      "required": [
                        "s3Key",
                        "filename",
                        "mimeType",
                        "size"
                      ],
                      "properties": {
                        "s3Key": {
                          "type": "string"
                        },
                        "filename": {
                          "type": "string"
                        },
                        "mimeType": {
                          "type": "string"
                        },
                        "size": {
                          "type": "integer",
                          "description": "File size in bytes"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Feedback submitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Issue"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Attachment does not belong to the current user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "get": {
        "operationId": "feedbackGet",
        "summary": "List feedback submitted by the current user",
        "description": "Returns only the current user's submissions, newest first.",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The current user's feedback submissions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Issue"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/feedback/attachments": {
      "post": {
        "operationId": "feedbackAttachmentsPost",
        "summary": "Start an upload for a feedback attachment",
        "description": "Returns presigned upload details. For small files the response contains\nuploadUrl — PUT the whole file to it. For large files the server\nswitches to S3 multipart upload and the response instead contains\nuploadId, partSize and partUrls: PUT each partSize-byte chunk to its\npart URL (collecting the ETag response header from each, parts can be\nretried individually), then call POST /feedback/attachments/complete.\nInclude the returned s3Key in the attachments of POST /feedback once\nuploaded. Maximum file size is 250MB, up to 5 attachments per submission.\n",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "filename",
                  "mimeType",
                  "size"
                ],
                "properties": {
                  "filename": {
                    "type": "string",
                    "minLength": 1
                  },
                  "mimeType": {
                    "type": "string"
                  },
                  "size": {
                    "type": "integer",
                    "description": "File size in bytes"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Presigned upload created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PresignedUpload"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (e.g. file too large)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/feedback/attachments/content": {
      "post": {
        "operationId": "feedbackAttachmentContentPost",
        "summary": "Upload a small feedback attachment's bytes directly",
        "description": "Server-side upload for callers that cannot PUT to a presigned URL — an\nAI agent talking MCP holds the bytes (a screenshot, a log, a stack\ntrace) but has no HTTP client of its own. The bytes travel base64 in\nthe request body, which is why the cap here is far lower than the\nbrowser path's: 2MB per file. Anything larger belongs on\nPOST /feedback/attachments.\n\nReturns the s3Key to pass in the attachments of POST /feedback, exactly\nas the presigned flow does.\n",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "filename",
                  "mimeType",
                  "contentBase64"
                ],
                "properties": {
                  "filename": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "mimeType": {
                    "type": "string",
                    "minLength": 1
                  },
                  "contentBase64": {
                    "type": "string",
                    "minLength": 1,
                    "description": "The file's bytes, base64-encoded (2MB decoded maximum)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bytes stored",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "s3Key",
                    "size"
                  ],
                  "properties": {
                    "s3Key": {
                      "type": "string",
                      "description": "Pass this in the attachments of POST /feedback"
                    },
                    "size": {
                      "type": "integer",
                      "description": "Decoded size in bytes"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (not base64, empty, or over the size cap)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/feedback/attachments/complete": {
      "post": {
        "operationId": "feedbackAttachmentsCompletePost",
        "summary": "Complete a multipart feedback attachment upload",
        "description": "Call after all parts have been uploaded, passing each part's ETag\nresponse header. The s3Key is then ready to reference in POST /feedback.\n",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "s3Key",
                  "uploadId",
                  "parts"
                ],
                "properties": {
                  "s3Key": {
                    "type": "string"
                  },
                  "uploadId": {
                    "type": "string"
                  },
                  "parts": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "required": [
                        "partNumber",
                        "etag"
                      ],
                      "properties": {
                        "partNumber": {
                          "type": "integer",
                          "minimum": 1
                        },
                        "etag": {
                          "type": "string",
                          "description": "ETag response header from uploading the part"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Upload completed"
          },
          "400": {
            "description": "Upload could not be completed (missing or invalid parts)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Attachment does not belong to the current user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/feedback/attachments/abort": {
      "post": {
        "operationId": "feedbackAttachmentsAbortPost",
        "summary": "Abort a multipart feedback attachment upload",
        "description": "Frees the storage held by an unfinished multipart upload. Idempotent.",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "s3Key",
                  "uploadId"
                ],
                "properties": {
                  "s3Key": {
                    "type": "string"
                  },
                  "uploadId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Upload aborted (or already gone)"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Attachment does not belong to the current user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/feedback/unread-count": {
      "get": {
        "operationId": "feedbackUnreadCountGet",
        "summary": "How many feedback replies the current user has not read",
        "description": "One aggregate number across every thread the caller submitted, so the\napp chrome can show a subtle unread indicator without fetching the full\nfeedback listing. Clears as threads are marked read\n(POST /feedback/{feedbackId}/read).\n",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The caller's unread-reply total",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeedbackUnreadCount"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/feedback/{feedbackId}": {
      "get": {
        "operationId": "feedbackIdGet",
        "summary": "Get one of your own submissions, with its full conversation",
        "description": "The single-issue view: the submission plus every visible comment on it,\noldest first. Internal operator notes are never included. Only the\nsubmitter can read their own issue — anyone else gets 404, so the\nexistence of an issue is not discoverable.\n",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "feedbackId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The issue and its thread",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Issue"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Feedback not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/feedback/{feedbackId}/comments": {
      "post": {
        "operationId": "feedbackCommentsPost",
        "summary": "Add a follow-up message to one of your own submissions",
        "description": "Appends a comment to the thread as the submitter. This is how a user\nanswers a question from the platform, or how an AI agent adds detail it\nonly discovered after filing — a fuller stack trace, a narrower repro.\nComments are append-only: there is no edit or delete.\n",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "feedbackId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "message"
                ],
                "properties": {
                  "message": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000
                  },
                  "agent": {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueReporterAgent"
                      }
                    ],
                    "description": "The AI agent writing on the user's behalf, if any"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The issue with the new comment appended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Issue"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (e.g. empty message)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Feedback not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/feedback/{feedbackId}/read": {
      "post": {
        "operationId": "feedbackReadPost",
        "summary": "Mark one of your own submissions as read",
        "description": "Stamps the thread as seen by the submitter, which is what clears its\nunreadCount. Idempotent; safe to call whenever the thread is opened.\n",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "feedbackId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The issue, with unreadCount now 0",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Issue"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Feedback not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/feedback/{feedbackId}/attachments/{attachmentId}/download": {
      "get": {
        "operationId": "feedbackAttachmentDownload",
        "summary": "Get a presigned download URL for one of your feedback attachments",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "feedbackId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "attachmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Presigned download URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "downloadUrl"
                  ],
                  "properties": {
                    "downloadUrl": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Feedback or attachment not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/audit/http-logs": {
      "get": {
        "operationId": "auditHttpLogsGet",
        "x-permission": "audit:read",
        "summary": "Get HTTP audit logs (tracks POST, PUT, PATCH, DELETE requests)",
        "description": "Retrieve HTTP audit logs with optional filtering by method, path, status code, and date range. The log holds raw request bodies, which no row rule or field permission has been applied to, so it is the workspace administrator's view: a caller whose base role is not Admin is refused (403, `ADMIN_ONLY`) even with `audit:read`, and reads the event list (`GET /audit/events`) and record history instead, which redact.",
        "tags": [
          "Audit"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "method",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "POST",
                "PUT",
                "PATCH",
                "DELETE"
              ]
            }
          },
          {
            "name": "path",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "HTTP audit logs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpAuditLogsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/audit/events": {
      "get": {
        "operationId": "auditEventsGet",
        "x-permission": "audit:read",
        "summary": "Get application events (business logic events like ItemCreated, ItemUpdated, etc.)",
        "description": "Retrieve structured application events that track business logic changes for automation and subscriptions. Item events are the caller's own view: an event of a record the caller may not read is left out (in the query, so the page and `total` describe the visible set), and the fields they may not read are masked from `beforeData`, `afterData` and the metadata. On a table governed by row rules the caller's rules are evaluated over the event's stored state, so an old event is visible as the record was when it was written. A rule that reads a related record (`relation`) cannot be evaluated there: such a table's events are absent from the list, and asking for it by `tableId` is refused (403, `AUDIT_TABLE_UNLISTABLE`); record history still answers for one record. A workspace administrator sees everything.",
        "tags": [
          "Audit"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "eventType",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "ItemCreated",
                "ItemUpdated",
                "ItemDeleted",
                "TableCreated",
                "TableUpdated",
                "TableDeleted",
                "FieldCreated",
                "FieldUpdated",
                "FieldDeleted",
                "ConstraintCreated",
                "ConstraintDeleted"
              ]
            }
          },
          {
            "name": "tableId",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "itemId",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Application events",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApplicationEventsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/audit/events/feed": {
      "get": {
        "operationId": "auditEventsFeedGet",
        "x-permission": "audit:read",
        "summary": "The workspace's change feed, oldest first, for keeping a copy in sync",
        "description": "Every record and schema change in the workspace, in the order it was\nlogged, for keeping an outside copy (a data warehouse, a search\nindex) in step without re-reading whole tables. Each entry is an\napplication event with the record's state before and after the\nchange; a deletion is an `ItemDeleted` entry, and a record restored\nfrom the recycle bin returns as `ItemCreated`.\n\n`cursor` is a watermark rather than a page boundary: keep the\n`nextCursor` from each call and send it back on the next one, and you\nreceive each event exactly once. Cursors are opaque, sealed, and only\nvalid in the workspace that issued them. To begin from a date instead, send\n`since` on the first call and keep the cursors from then on. A\ncursor stays valid indefinitely, but\nevents older than the workspace's audit window are no longer served,\nso poll more often than that window. Omitting it starts at the oldest\nevent still held; to start from now instead, store `latestCursor`\nfrom your first call. Load existing records from the table item\nendpoints first, then apply the feed from the `latestCursor` you\nstored before that load.\n\nAn event appears only once the transaction that wrote it, and every\ntransaction older than it, has finished. That is what lets a stored\ncursor never skip an event, and it means a long-running write\nelsewhere can delay new events for its duration.\n\nTwo changes to the same record made at almost the same moment can be\nlogged in either order. Apply a record's state only when its\n`afterData.updatedAt` is not older than the copy you hold, and keep a\ndeleted record's `beforeData.updatedAt` with its deletion so an\nearlier update logged after it cannot bring the record back. Events\nlogged before the feed existed share one position and come in storage\norder rather than strictly by time, which the same rule absorbs.\n\nSame visibility rules as `GET /audit/events`: events for records you\ncannot read are omitted and fields you cannot read are masked, so a\npage can hold fewer entries than its limit. `hasMore`, not a full\npage, is what tells you to poll again straight away. A complete copy\nneeds a caller that can read every record.\n",
        "tags": [
          "Audit"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The `nextCursor` (or `latestCursor`) from your previous call.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "Start at the first event logged at or after this moment, instead of a cursor, to begin a sync from a date or to recover one whose cursor was lost. Feed order is commit order, so a few events logged slightly earlier can come with it; none from this moment on are left out. Not allowed together with `cursor`; keep the `nextCursor` from the response and resume from that.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum entries to return (default 200).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          },
          {
            "name": "tableId",
            "in": "query",
            "required": false,
            "description": "Restrict to one table's events. Cursors are positions in the whole workspace's feed, so one cursor may be used with or without this filter.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Events since the cursor, oldest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApplicationEventFeed"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "The change feed is not available on this deployment (its cursor key is not configured). Nothing a client sends changes this; retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/push/vapid-public-key": {
      "get": {
        "operationId": "pushVapidPublicKeyGet",
        "summary": "Get VAPID public key for push subscription",
        "tags": [
          "Push Notifications"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "VAPID public key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VapidPublicKeyResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/push/subscribe": {
      "post": {
        "operationId": "pushSubscribePost",
        "summary": "Subscribe to push notifications",
        "tags": [
          "Push Notifications"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PushSubscribeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Subscription successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PushSubscribeResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid subscription data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/push/unsubscribe": {
      "delete": {
        "operationId": "pushUnsubscribeDelete",
        "summary": "Unsubscribe from push notifications",
        "tags": [
          "Push Notifications"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "endpoint"
                ],
                "properties": {
                  "endpoint": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unsubscription successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PushSubscribeResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Subscription not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/query": {
      "post": {
        "operationId": "queryPost",
        "x-replica-reads": true,
        "x-permission": "query:execute",
        "x-rate-limit": {
          "measure": "query.executions"
        },
        "summary": "Run a SQL SELECT against the workspace's tables",
        "description": "Runs one SQL `SELECT` statement (Postgres dialect) over the tables and\nSQL views of the caller's workspace: joins, aggregates, window\nfunctions, CTEs — whatever a single read statement can say. The text\nmay be a template with `{{variable}}` placeholders and `[[optional]]`\nblocks, bound from `variables`. The statement is checked to be exactly\none SELECT with no schema-qualified references, runs on a read-only\nconnection as the workspace's own least-privileged database role, and\nis capped at the server's row ceiling.\n\nRaw SQL cannot take a row-level scope, so the caller must hold\nunrestricted record visibility (`GET /me/permissions` reports\n`queryUnrestricted`); a restricted viewer gets a 403 and uses the\nrecord endpoints — or a chart drawn from a table through\n`POST /tables/{tableId}/aggregate` — instead. The response states what\nran: `metadata.resolvedSql` is the substituted statement, `readAt`\nwhen it ran and `tables` which tables its columns came from.\n",
        "tags": [
          "Query"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Query executed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query syntax or parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Access denied to requested table or fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/exports": {
      "post": {
        "operationId": "tablesTableIdExportsPost",
        "x-permission": "records:read",
        "summary": "Start an asynchronous CSV export of a table's records",
        "description": "Queues a background job that reads the table's records through the\nsame path as the records list — the requester's row scope and field\nmasking apply, so any reader of the table can export exactly what they\ncan see — and streams them to a CSV file. Poll the returned job with\n`GET /tables/{tableId}/exports/{jobId}`; when it succeeds the response\ncarries a short-lived `downloadUrl`.\n\nThe file is UTF-8 with a BOM, one header row (`id`, then the field\nnames), RFC 4180 quoting, and the record values as the records list\nreturns them: structured values (an address, a currency amount) as\nJSON. String cells beginning with `=`, `+`, `-`, `@`, or a tab are\nprefixed with a single quote so spreadsheet apps do not run them as\nformulas.\n\nThe job is re-authorised when it runs: if the requester has lost read\naccess by then it fails, and a field masked from them since is left\nout. At most `records.exportMaxRows` records are written; when the\nceiling cuts the export short the job reports `truncated: true`. A\nworkspace runs at most two exports at a time, query and records\nexports together; past that the request is refused with 429.\n\nA table of kind `view` cannot be exported this way (400); its rows\ncome from its query, which `POST /query/exports` exports.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "description": "The table whose records to export.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecordExportRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Export job accepted and queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryExportJob"
                }
              }
            }
          },
          "400": {
            "description": "The filter, sort or columns name a field the caller cannot read (or that does not exist), are malformed, or the table is a view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such table in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "The workspace is at its concurrent-export ceiling",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/exports/{jobId}": {
      "get": {
        "operationId": "tablesTableIdExportsJobIdGet",
        "x-permission": "records:read",
        "summary": "Read a records export job's status and, once succeeded, its download URL",
        "description": "Status of one records export job. While `queued`/`running`, poll\nagain; on `succeeded` the response includes a short-lived presigned\n`downloadUrl` (re-fetch this endpoint for a fresh one) until the\nfile expires at `expiresAt`; on `failed`, `error` carries a\nuser-facing reason.\n\nRequester-only: the file was built under the requesting user's row\nscope and field masking, so only that user can read the job or obtain\nits download URL — any other principal receives the same 404 as for a\nnonexistent job.\n",
        "tags": [
          "TableItems"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "description": "The table the export was requested for.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "description": "The export job's `id`, as `POST /tables/{tableId}/exports` returned it.",
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The export job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryExportJob"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such export job for this table, or it was requested by someone else",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/query/exports": {
      "post": {
        "operationId": "queryExportsPost",
        "x-permission": "query:execute",
        "x-rate-limit": {
          "measure": "query.executions"
        },
        "summary": "Start an asynchronous CSV export of a query's results",
        "description": "Queues a background job that runs the query through the same engine\nas /query — same validation, same unrestricted-visibility requirement\n— and streams the full result set (bounded by the workspace's\n`query.exportMaxRows` entitlement rather than the interactive 10k\ncap) to a byte-accurate CSV artifact. Poll the returned job with\n`GET /query/exports/{jobId}`; when it succeeds the response carries a\nshort-lived `downloadUrl`.\n\nThe artifact is UTF-8 with a BOM (so spreadsheet apps detect the\nencoding): one header row of column names, RFC 4180 quoting, and\nJSON-serialised object/array cells. String cells beginning with `=`,\n`+`, `-`, `@`, or a tab are prefixed with a single quote to\nneutralise spreadsheet formula injection. When the row ceiling cuts\nthe result short the job reports `truncated: true` — truncation is\nvisible, never silent.\n",
        "tags": [
          "Query"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryExportRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Export job accepted and queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryExportJob"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query syntax or parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Access denied — raw SQL requires unrestricted record visibility",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "The workspace is at its concurrent-export ceiling",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/query/exports/{jobId}": {
      "get": {
        "operationId": "queryExportsJobIdGet",
        "x-permission": "query:execute",
        "summary": "Read an export job's status and, once succeeded, its download URL",
        "description": "Status of one export job. While `queued`/`running`, poll again; on\n`succeeded` the response includes a short-lived presigned\n`downloadUrl` (re-fetch this endpoint for a fresh one) until the\nartifact expires at `expiresAt`; on `failed`, `error` carries a\nuser-facing reason.\n\nRequester-only: the artifact was built under the submitting user's\nunrestricted record visibility, so only that user can read the job or\nobtain its download URL — any other principal receives the same 404\nas for a nonexistent job.\n",
        "tags": [
          "Query"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The export job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryExportJob"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such export job in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/query/deliveries": {
      "get": {
        "operationId": "queryDeliveriesGet",
        "x-permission": "query:execute",
        "summary": "List this workspace's scheduled report deliveries",
        "description": "Optionally narrowed to one saved query, which is how the query page shows \"this report is scheduled\".\n",
        "tags": [
          "Query"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "savedQueryId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only schedules delivering this saved query."
          }
        ],
        "responses": {
          "200": {
            "description": "The workspace's delivery schedules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QueryDeliverySchedule"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "queryDeliveriesPost",
        "x-permission": "query:execute",
        "summary": "Schedule a saved query for delivery",
        "description": "Each firing runs the query as you and emails the recipients a link to\nthe result. Because the query engine cannot apply row filters, the\ncaller must hold unrestricted record visibility — the same gate as\nPOST /query — and so must every recipient.\n",
        "tags": [
          "Query"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateQueryDeliveryScheduleRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created schedule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryDeliverySchedule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid cron expression, unknown saved query, or ineligible recipients",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Your record visibility is restricted, so you cannot run queries",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "This workspace already has the maximum number of schedules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/query/deliveries/{scheduleId}": {
      "patch": {
        "operationId": "queryDeliveriesScheduleIdPatch",
        "x-permission": "query:execute",
        "summary": "Change a delivery schedule",
        "tags": [
          "Query"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scheduleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateQueryDeliveryScheduleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated schedule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryDeliverySchedule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid cron expression or ineligible recipients",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such schedule in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "queryDeliveriesScheduleIdDelete",
        "x-permission": "query:execute",
        "summary": "Delete a delivery schedule",
        "tags": [
          "Query"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scheduleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such schedule in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/query/deliveries/{scheduleId}/run": {
      "post": {
        "operationId": "queryDeliveriesScheduleIdRunPost",
        "x-permission": "query:execute",
        "summary": "Run a delivery schedule now",
        "description": "Starts this report immediately, in addition to its cadence — the horizon is untouched, so the next scheduled send still happens. The export runs asynchronously; the recipients are emailed when it lands. This is also how a schedule is exercised in an environment where the background scan is switched off.\n",
        "tags": [
          "Query"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scheduleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "The schedule, with the export it just started",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryDeliverySchedule"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Your record visibility is restricted, so you cannot run queries",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such schedule in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/query/deliveries/{scheduleId}/download": {
      "get": {
        "operationId": "queryDeliveriesScheduleIdDownloadGet",
        "x-permission": "query:execute",
        "summary": "Download the most recently delivered result of a schedule",
        "description": "The link recipients follow from their email. Unlike the export job's\nown requester-scoped read, this is scoped to the schedule's audience:\nits creator and its recipients, each re-checked for active membership\nand for the unrestricted record visibility the export was built under.\nAnyone else receives a 404.\n",
        "tags": [
          "Query"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scheduleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A short-lived download for the delivered result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryDeliveryDownload"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such schedule, nothing delivered yet, or the artifact has expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/search": {
      "get": {
        "operationId": "searchGet",
        "x-permission": "records:read",
        "x-rate-limit": {
          "measure": "search.executions"
        },
        "summary": "Search records across every readable table in the workspace",
        "description": "One box, workspace-wide: full-text search over every table the caller\nmay read, honouring the caller's per-table row filters and field\nmasking — a record can only be found, ranked, and quoted by fields the\ncaller is allowed to see.\n\nResults are grouped by table because cross-table relevance scores are\nnot comparable; a flat ranked list would be presenting a number that\ndoesn't mean anything. Hits are ranked within their group and groups\nare ordered by their best hit.\n\nThe search is budgeted (`search.tablesPerQuery`): if the workspace has\nmore searchable tables than the budget, the search is cut short and\n`truncated` reports how many tables were searched and how many were\nskipped — truncation is visible, never silent. When `tables` is\nsupplied, its order is the priority order under that budget, so a\nclient can put the caller's most relevant tables first.\n\nThe final search term matches by prefix, so the box works as-you-type\n(\"acme cor\" finds \"Acme Corporation\"). Terms are accent-folded\n(\"muller\" finds \"Müller\").\n\nAlongside the record groups, `assets` lists workspace assets —\ntables, dashboards, charts, and saved queries — whose titles match\nthe query, so \"pipeline\" finds the Pipeline dashboard as well as any\nrecords mentioning it. Each asset kind is included only when the\ncaller holds its read action; the `tables` and `limit` parameters\napply to the record search only.\n",
        "tags": [
          "Search"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "description": "The search text. Parsed server-side into terms; operator characters are term boundaries, never syntax.\n"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            },
            "description": "Maximum hits returned per table."
          },
          {
            "name": "tables",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9]{1,32}(,[a-zA-Z0-9]{1,32})*$",
              "maxLength": 1024
            },
            "description": "Comma-separated table ids to restrict the search to. Unknown, unreadable, or non-searchable ids are ignored rather than reported. Order is meaningful: it is the priority order when the table budget truncates the search.\n"
          }
        ],
        "responses": {
          "200": {
            "description": "Search results grouped by table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing or malformed query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/schema-plans/validate": {
      "post": {
        "operationId": "schemaPlansValidatePost",
        "x-permission": "tables:read",
        "summary": "Dry-run a schema plan against the workspace",
        "description": "Validates a version-1 schema plan (createTables + addFields) against the\nworkspace's current schema without changing anything. Returns errors and\nwarnings — each with a stable code, the path of the offending element,\nand a fix suggestion — plus a human-readable summary for user\nconfirmation. Open to all workspace roles.\n",
        "tags": [
          "SchemaPlans"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SchemaPlanRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation completed (check the valid flag)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPlanValidationResult"
                }
              }
            }
          },
          "400": {
            "description": "The request named neither or both of plan and planId, or its patch could not be applied — as a teaching issue in the result document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPlanValidationResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "planId unknown or expired (`PLAN_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/parts": {
      "get": {
        "operationId": "libraryPartsGet",
        "x-permission": "tables:read",
        "summary": "Search and list schema parts",
        "description": "Lists the schema parts the caller may find: public parts, and their own\norganization's organization-scoped parts. Unlisted and withdrawn parts never\nappear (an unlisted part is read by id). Deprecated parts are hidden unless\n`includeDeprecated` is set. Open to every workspace role and principal.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Words to search the parts' names, summaries and tags for. Omit to list.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Only parts filed under this process category.",
            "schema": {
              "type": "string",
              "enum": [
                "sales",
                "operations",
                "people",
                "finance",
                "projects",
                "personal",
                "other"
              ]
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "description": "Only parts carrying this tag.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]{1,32}$"
            }
          },
          {
            "name": "publisher",
            "in": "query",
            "required": false,
            "description": "Only parts from this publisher: `platform` for curated platform parts, or an organization id.",
            "schema": {
              "type": "string",
              "pattern": "^(platform|[0-9a-f]{12})$"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "`relevance` (the default; search rank when `q` is given, else newest), `top` (vote score), `trending` (recent installs), `newest`, or `installed` (active installs). Curated parts come first in every sort.",
            "schema": {
              "type": "string",
              "enum": [
                "relevance",
                "top",
                "trending",
                "newest",
                "installed"
              ],
              "default": "relevance"
            }
          },
          {
            "name": "includeDeprecated",
            "in": "query",
            "required": false,
            "description": "Include deprecated parts, which the default listing hides.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from a previous response's `nextCursor`. Keyset pagination, so a page boundary stays stable while parts are being published.",
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Parts per page.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of parts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartList"
                }
              }
            }
          },
          "400": {
            "description": "The request did not match this specification, or `cursor` is not a cursor this listing issued (code `INVALID_CURSOR`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/parts/{partId}": {
      "get": {
        "operationId": "libraryPartsPartIdGet",
        "x-permission": "tables:read",
        "summary": "Read a schema part",
        "description": "Returns a part with its readme, every version's entry and its fork lineage.\nReachable by id when the part is public or unlisted, or organization-scoped\nand the caller's workspace belongs to the publisher; otherwise 404\n`PART_NOT_FOUND`.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The part",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPart"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No part with this id is visible to the caller (code `PART_NOT_FOUND`). A part outside the caller's visibility, or withdrawn (unless the caller's organization publishes it), does not exist for them: never 403.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/parts/{partId}/versions/{number}": {
      "get": {
        "operationId": "libraryPartsPartIdVersionsNumberGet",
        "x-permission": "tables:read",
        "summary": "Read one version of a schema part",
        "description": "Returns one immutable version: its document (the whole part, for download),\nreadme, change note, what was derived from it at publish and its standing on\nthe current platform.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "description": "The version number, from 1.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartVersion"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such part or version is visible to the caller (code `PART_NOT_FOUND`). A part outside the caller's visibility, or withdrawn (unless the caller's organization publishes it), does not exist for them: never 403.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/parts/{partId}/versions/{a}/diff/{b}": {
      "get": {
        "operationId": "libraryPartsPartIdVersionsADiffBGet",
        "x-permission": "tables:read",
        "summary": "Diff two versions of a schema part",
        "description": "What changed from version `a` to version `b` of one part: the plan's objects\nby name and the companions by key, so an installer sees what changed since the\nversion they have.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "a",
            "in": "path",
            "required": true,
            "description": "The older version number.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "b",
            "in": "path",
            "required": true,
            "description": "The newer version number.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The diff from version a to version b",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartDiff"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such part or version is visible to the caller (code `PART_NOT_FOUND`). A part outside the caller's visibility, or withdrawn (unless the caller's organization publishes it), does not exist for them: never 403.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/parts/{partId}/vote": {
      "put": {
        "operationId": "libraryPartsPartIdVotePut",
        "x-permission": "tables:read",
        "summary": "Vote on a schema part",
        "description": "Casts or changes the caller's vote on a part: up (`1`) or down (`-1`), one per\nperson per part. Votes are anonymous in every read; the part shows the counts and\nranks by them. Members of the publishing organization cannot vote on its parts\n(409 `PART_VOTE_OWN`). A person's act: API tokens, OAuth clients, assumed sessions\nand hosted-site sessions are refused (403, code `PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SchemaPartVoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The part's counters and the caller's standing after the vote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartCommunity"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No part with this id is visible to the caller (code `PART_NOT_FOUND`): a part outside the caller's visibility does not exist for them, never 403.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The caller is a member of the organization that publishes the part (code `PART_VOTE_OWN`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "libraryPartsPartIdVoteDelete",
        "x-permission": "tables:read",
        "summary": "Withdraw a vote on a schema part",
        "description": "Withdraws the caller's vote on a part. Withdrawing a vote the caller has not cast\nchanges nothing and answers the same. A person's act: API tokens, OAuth clients,\nassumed sessions and hosted-site sessions are refused (403, code `PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The part's counters and the caller's standing after the withdrawal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartCommunity"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No part with this id is visible to the caller (code `PART_NOT_FOUND`): a part outside the caller's visibility does not exist for them, never 403.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/parts/{partId}/favourite": {
      "put": {
        "operationId": "libraryPartsPartIdFavouritePut",
        "x-permission": "tables:read",
        "summary": "Favourite a schema part",
        "description": "Adds the part to the caller's favourites. A favourite is also a subscription: each\nnew version of the part notifies the caller in the workspace they favourited it\nfrom. Favouriting twice changes nothing. A person's act: API tokens, OAuth\nclients, assumed sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The part's counters and the caller's standing after the favourite",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartCommunity"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No part with this id is visible to the caller (code `PART_NOT_FOUND`): a part outside the caller's visibility does not exist for them, never 403.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "libraryPartsPartIdFavouriteDelete",
        "x-permission": "tables:read",
        "summary": "Remove a schema part from favourites",
        "description": "Removes the part from the caller's favourites, and so stops its new-version\nnotices. Removing a part that is not a favourite changes nothing. A person's act:\nAPI tokens, OAuth clients, assumed sessions and hosted-site sessions are refused\n(403, code `PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The part's counters and the caller's standing after the removal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartCommunity"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No part with this id is visible to the caller (code `PART_NOT_FOUND`): a part outside the caller's visibility does not exist for them, never 403.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/parts/{partId}/comments": {
      "get": {
        "operationId": "libraryPartsPartIdCommentsGet",
        "x-permission": "tables:read",
        "summary": "Read a schema part's comments",
        "description": "Returns a page of the part's comment thread: top-level comments newest first, each\nwith all of its replies oldest first. A hidden comment keeps its place with its\ntext withheld (`hidden: true`, `body` empty), so the replies under it still read\nin context. Authors are shown by display name only.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The `nextCursor` of the previous page; omit for the first page.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many top-level comments to return, at most 50 (default 20).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of the thread",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartCommentPage"
                }
              }
            }
          },
          "400": {
            "description": "The cursor is not one this endpoint issued (code `INVALID_CURSOR`), or a parameter is malformed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No part with this id is visible to the caller (code `PART_NOT_FOUND`): a part outside the caller's visibility does not exist for them, never 403.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "libraryPartsPartIdCommentsPost",
        "x-permission": "tables:read",
        "summary": "Comment on a schema part",
        "description": "Adds a plain-text comment to the part's thread, or a reply to a top-level comment\n(replies go one level deep). With `asPublisher`, a library manager of the\npublishing organization replies as the publisher, and the comment is marked so.\nThe publisher's library managers are notified of each new comment that is not\ntheir own organization's. A person may post 30 comments an hour (429, code\n`PART_COMMUNITY_RATE`, with `Retry-After`). A person's act: API tokens, OAuth\nclients, assumed sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SchemaPartCommentRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The comment as posted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartComment"
                }
              }
            }
          },
          "400": {
            "description": "The body is empty or too long, or `parentId` names no top-level comment on this part (code `COMMENT_PARENT_INVALID`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not the person's own session, or `asPublisher` from someone who does not manage the publishing organization's library (code `PERMISSION_DENIED`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No part with this id is visible to the caller (code `PART_NOT_FOUND`): a part outside the caller's visibility does not exist for them, never 403.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests, or the person has posted 30 comments in the last hour (code `PART_COMMUNITY_RATE`; `Retry-After` says when the next one is accepted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/parts/{partId}/comments/{commentId}": {
      "patch": {
        "operationId": "libraryPartsPartIdCommentsCommentIdPatch",
        "x-permission": "tables:read",
        "summary": "Edit a schema part comment",
        "description": "Replaces the text of the caller's own comment, within 15 minutes of posting it\n(409 `COMMENT_EDIT_WINDOW_CLOSED` after). A hidden comment cannot be edited. A\nperson's act: API tokens, OAuth clients, assumed sessions and hosted-site sessions\nare refused (403, code `PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "commentId",
            "in": "path",
            "required": true,
            "description": "The comment's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SchemaPartCommentUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The comment as edited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartComment"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The part does not exist for the caller (code `PART_NOT_FOUND`), or it has no comment by the caller with this id (code `COMMENT_NOT_FOUND`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The edit window has closed, or the comment is hidden (code `COMMENT_EDIT_WINDOW_CLOSED`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "libraryPartsPartIdCommentsCommentIdDelete",
        "x-permission": "tables:read",
        "summary": "Delete a schema part comment",
        "description": "Deletes the caller's own comment. Deleting a top-level comment deletes its replies\nwith it: a thread goes with the comment that started it. A person's act: API\ntokens, OAuth clients, assumed sessions and hosted-site sessions are refused (403,\ncode `PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "commentId",
            "in": "path",
            "required": true,
            "description": "The comment's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The comment, and any replies to it, are deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The part does not exist for the caller (code `PART_NOT_FOUND`), or it has no comment by the caller with this id (code `COMMENT_NOT_FOUND`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/parts/{partId}/reports": {
      "post": {
        "operationId": "libraryPartsPartIdReportsPost",
        "x-permission": "tables:read",
        "summary": "Report a schema part or one of its comments",
        "description": "Reports the part, or one comment on it, to the platform's operators with a reason\nand detail. A person's open report of the same part (and comment) is not filed\ntwice: the existing report answers, with 200. A person may file 20 reports a day\n(429, code `PART_COMMUNITY_RATE`, with `Retry-After`). A person's act: API tokens,\nOAuth clients, assumed sessions and hosted-site sessions are refused (403, code\n`PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SchemaPartReportRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The caller's open report of the same thing, already filed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartReport"
                }
              }
            }
          },
          "201": {
            "description": "The report as filed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartReport"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The part does not exist for the caller (code `PART_NOT_FOUND`), or `commentId` names no comment on it (code `COMMENT_NOT_FOUND`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests, or the person has filed 20 reports in the last day (code `PART_COMMUNITY_RATE`; `Retry-After` says when the next one is accepted).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/kits": {
      "get": {
        "operationId": "libraryKitsGet",
        "x-permission": "tables:read",
        "summary": "List kits",
        "description": "Public kits, and the caller organization's own organization-scoped ones, curated first then newest. Unlisted and withdrawn kits never appear.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The kits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LibraryKitSummary"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/kits/{kitId}": {
      "get": {
        "operationId": "libraryKitsKitIdGet",
        "x-permission": "tables:read",
        "summary": "Read a kit",
        "description": "Returns a kit with its latest version. Reachable by id when the kit is public or unlisted, or organization-scoped and the caller's workspace belongs to the publisher; a withdrawn kit only by its publisher. Otherwise 404 `KIT_NOT_FOUND`.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "kitId",
            "in": "path",
            "required": true,
            "description": "The kit's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The kit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryKit"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No kit with this id is visible to the caller (code `KIT_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/kits/{kitId}/versions/{number}": {
      "get": {
        "operationId": "libraryKitsKitIdVersionsNumberGet",
        "x-permission": "tables:read",
        "summary": "Read a kit version",
        "description": "Returns one version of a kit visible to the caller.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "kitId",
            "in": "path",
            "required": true,
            "description": "The kit's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "description": "The version's number.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryKitVersion"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No kit with this id is visible to the caller, or it has no such version (codes `KIT_NOT_FOUND`, `KIT_VERSION_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/kits/{kitId}/versions/{number}/install/preview": {
      "post": {
        "operationId": "libraryKitsKitIdVersionsNumberInstallPreviewPost",
        "x-permission": "schema:apply",
        "summary": "Preview installing a kit version",
        "description": "Runs a kit install against this workspace without changing anything: every part's install preview\n  in order, each seeing the tables the parts before it would create (so a slot the kit binds is not\n  reported unbound); one roles review for the whole kit; and, when `extension.deploy` is true, what\n  deploying the extension source would do to the workspace's site. Requires the permission to apply a\n  schema plan, and to manage the hosted site for the extension.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "kitId",
            "in": "path",
            "required": true,
            "description": "The kit's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "description": "The kit version's number.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KitInstallRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The preview",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KitInstallPreview"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such kit or version is visible to the caller (codes `KIT_NOT_FOUND`, `KIT_VERSION_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A part of the kit cannot be installed here: its version no longer validates, it was withdrawn, or the workspace's schema era is behind it (codes `PART_VERSION_STALE`, `PART_NOT_FOUND`, `PART_WORKSPACE_ERA_BEHIND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/kits/{kitId}/versions/{number}/install": {
      "post": {
        "operationId": "libraryKitsKitIdVersionsNumberInstallPost",
        "x-permission": "schema:apply",
        "summary": "Install a kit version",
        "description": "Queues a kit install into this workspace, run as the caller. Its parts install in order, each as\n  an ordinary part install (`GET /library/installs/{installId}`) bound as the preview showed; a part\n  that fails stops the kit, and the parts already installed stay. Then, when asked, the extension\n  source is deployed to the workspace's site (created if it has none; a site that already serves a\n  deployment is never replaced) and its extensions placed on their tables' record pages. Read\n  progress with `GET /library/kit-installs/{installId}`. A person's act: API tokens, OAuth clients\n  and assumed sessions are refused (403, code `PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "kitId",
            "in": "path",
            "required": true,
            "description": "The kit's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "description": "The kit version's number.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KitInstallRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The queued kit install",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KitInstall"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions, or not a person's own session (code `PERMISSION_DENIED`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such kit or version is visible to the caller (codes `KIT_NOT_FOUND`, `KIT_VERSION_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The install cannot be queued: the preview has errors (code `KIT_INSTALL_PREVIEW_FAILED`, with them in `issues`); a part creates roles and `acknowledgedRoles` is missing or not this request's (code `PART_ROLES_NOT_REVIEWED`); `extension.deploy` without the source's digest in `acknowledgedExtension` (code `KIT_EXTENSION_NOT_REVIEWED`); or another install into this workspace is still queued or running (code `PART_INSTALL_IN_FLIGHT`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/kit-installs/{installId}": {
      "get": {
        "operationId": "libraryKitInstallsInstallIdGet",
        "x-permission": "tables:read",
        "summary": "Read a kit install",
        "description": "A kit install into this workspace and how far it has got: each part's install, the deployment it made and the blocks it placed.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "installId",
            "in": "path",
            "required": true,
            "description": "The kit install's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The kit install",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KitInstall"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No kit install with this id in this workspace (code `KIT_INSTALL_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/suggest": {
      "post": {
        "operationId": "librarySuggestPost",
        "x-permission": "tables:read",
        "summary": "Suggest a summary and tags for a part document",
        "description": "Reads a part document and suggests the listing's summary and tags for the\npublisher to edit before publishing. Nothing is stored. Runs the AI model under\nthe caller's workspace's AI budget, metered to it; when AI features are off on\nthis deployment, or the organization's monthly AI budget is spent, it answers\n409 `AI_UNAVAILABLE`. A person's act: API tokens, OAuth clients, assumed sessions\nand hosted-site sessions are refused (403, code `PERMISSION_DENIED`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SchemaPartSuggestionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The suggested summary and tags",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartSuggestion"
                }
              }
            }
          },
          "400": {
            "description": "The document does not validate as a part document; see `issues` (a SchemaPartRefusal).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "AI suggestions are not available: AI features are off, the organization's monthly AI budget is spent, or the model gave no usable answer (code `AI_UNAVAILABLE`). Publishing does not need them.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/publishers/{organizationId}": {
      "get": {
        "operationId": "libraryPublishersOrganizationIdGet",
        "x-permission": "tables:read",
        "summary": "List a publisher's schema parts",
        "description": "The publisher page: the parts one organization publishes that the caller may\nfind (public ones, plus organization-scoped ones when the caller's workspace\nbelongs to that organization), curated first, then newest. 404 when there is\nnone, so the page says nothing about an organization that publishes nothing the\ncaller may find.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "description": "The publishing organization.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from a previous response's `nextCursor`. Keyset pagination, so a page boundary stays stable while parts are being published.",
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Parts per page.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of the publisher's parts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartList"
                }
              }
            }
          },
          "400": {
            "description": "The request did not match this specification, or `cursor` is not a cursor this listing issued (code `INVALID_CURSOR`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The organization publishes no part the caller may find (code `PUBLISHER_NOT_FOUND`): one with nothing public, and none of its own organization-scoped parts for a caller outside it, answers exactly as an id no organization has, so the page never reveals whether an organization exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/compose": {
      "post": {
        "operationId": "libraryComposePost",
        "x-permission": "tables:read",
        "summary": "Compose a part document from workspace tables",
        "description": "Builds a part document from this workspace's tables: the schema plan of the\nnamed tables plus every companion that belongs to them (saved views, record\nlayouts, approval rules, summaries, flows whose every table is selected,\ndashboards that read only those tables). People become people slots,\n`{{secrets.X}}` names become secret slots and references to unselected tables\nbecome external tables. Includes only what the caller may read; the rest is\nlisted in `leftOut` with the reason. Nothing is published: edit the document,\nthen post it to the organization's library.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ComposeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The composed document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComposeResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/parts/{partId}/versions/{number}/install/preview": {
      "post": {
        "operationId": "libraryPartsPartIdVersionsNumberInstallPreviewPost",
        "x-permission": "schema:apply",
        "summary": "Preview installing a schema part version",
        "description": "Runs the install request against this workspace without changing anything:\nthe resolved plan's issues grouped into unbound slots, collisions and the\nrest; what would be created, with final names; the companion kinds the caller\nlacks the permission to create; the capability panel; and the version's\ncompatibility. Only a preview with no error issues can be installed. Requires\nthe permission to apply a schema plan.\n\nWith a `newWorkspace` target the preview validates against an empty\nworkspace, so external-table slots cannot be bound there: each appears in\n`issues.unboundSlots` as an error telling the installer to install the part\nthat provides the table first (or to install into a workspace that has it).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "description": "The version number, from 1.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstallRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The preview",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstallPreview"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such part or version is visible to the caller (code `PART_NOT_FOUND`). A part outside the caller's visibility, or withdrawn (unless the caller's organization publishes it), does not exist for them: never 403.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The version cannot be installed here: it no longer validates on the current platform (code `PART_VERSION_STALE`, with the validation issues in `issues`), or this workspace is on an older schema era than the version needs and will be migrated on its next deploy (code `PART_WORKSPACE_ERA_BEHIND`, `issues` empty)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/parts/{partId}/versions/{number}/install": {
      "post": {
        "operationId": "libraryPartsPartIdVersionsNumberInstallPost",
        "x-permission": "schema:apply",
        "summary": "Install a schema part version",
        "description": "Queues an install of the version with the same request the preview took and\nanswers 202 with the install job; poll `GET /library/installs/{installId}`.\nThe preview is re-run first and the install refused if it now has an error\nissue. The job installs as the caller, under the caller's own grant, so each\nobject it creates is authorised as theirs, and flows arrive disabled: a\nperson's session installs with their workspace role; an API token installs\nwith that token's roles, and an OAuth client with its scopes, never the\nperson's full rights, so a companion the grant cannot create is an issue on\nthe succeeded install rather than created. An install an API token asked for\nfails if the token is revoked before the job runs. A `newWorkspace` target\ncreates that workspace first and needs a person's session and the\norganization permission to manage workspaces (403); the install is created\nin, and polled from, the new workspace: the response's `workspaceId` names\nit, the caller is its first admin, and they obtain a token for it the usual\nway to poll `GET /library/installs/{installId}` there. Sample data installs\ninto sandbox workspaces only (400, code `PART_SAMPLE_SANDBOX_ONLY`). The part\nis re-read when the job runs, so a part withdrawn or narrowed in between\nfails the job rather than installing. A person's session, an API token or an\nOAuth client may ask; an assumed (impersonated) session, a hosted-site\nsession and the install job's own token are refused (403, code\n`PART_INSTALL_NEEDS_PERSON`).\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "partId",
            "in": "path",
            "required": true,
            "description": "The part's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "description": "The version number, from 1.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstallRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The install job, queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartInstall"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the permission this needs; the request does not come from a person's session, an API token or an OAuth client (code `PART_INSTALL_NEEDS_PERSON`: assumed sessions, hosted-site sessions and the install job's own token cannot install); or a `newWorkspace` target needs a person's session and the organization permission to manage workspaces",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such part or version is visible to the caller (code `PART_NOT_FOUND`). A part outside the caller's visibility, or withdrawn (unless the caller's organization publishes it), does not exist for them: never 403.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The install was refused: the preview now has an error issue (code `PART_INSTALL_PREVIEW_FAILED`, the preview's error issues in `issues`), the version no longer validates (code `PART_VERSION_STALE`, its validation issues in `issues`), another install into this workspace is still queued or running (code `PART_INSTALL_IN_FLIGHT`), this workspace is on an older schema era than the version needs (code `PART_WORKSPACE_ERA_BEHIND`), or the version creates roles and `acknowledgedRoles` is missing or does not match the preview's `rolesReviewToken` for this request (code `PART_ROLES_NOT_REVIEWED`); `issues` is empty for the last three",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/installs": {
      "get": {
        "operationId": "libraryInstallsGet",
        "x-permission": "schema:apply",
        "summary": "List this workspace's schema part installs",
        "description": "Every install requested in this workspace, newest first: which part and\nversion, its status, and once it succeeded what it created.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The installs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SchemaPartInstall"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/installs/{installId}": {
      "get": {
        "operationId": "libraryInstallsInstallIdGet",
        "x-permission": "schema:apply",
        "summary": "Read a schema part install",
        "description": "One install: poll it after requesting an install until `status` is\n`succeeded` or `failed`.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "installId",
            "in": "path",
            "required": true,
            "description": "The install's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The install",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartInstall"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such install in this workspace (code `INSTALL_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/installs/{installId}/update": {
      "post": {
        "operationId": "libraryInstallsInstallIdUpdatePost",
        "x-permission": "schema:apply",
        "summary": "Update a schema part install to the latest installable version",
        "description": "Queues an update of a succeeded install to the part's latest installable\nversion (the install's `updateAvailable`) and answers 202 with the new\ninstall job; poll `GET /library/installs/{installId}` with its id. The\nupdate applies the new version's schema plan only, in `reconcile` mode\nwith the install's own table names and bindings: what is missing is\nadded, what exists unchanged is kept, and an existing table or field the\nversion changes is a conflict, never forced. Companions are not applied,\nnor table settings, nor lifecycle changes on tables that already exist;\nthe succeeded update lists them in `result.companionChanges` for the\ninstaller to apply by hand.\nThe request first runs the update's own preview, exactly as\n`POST /library/installs/{installId}/update/preview` answers it, and\nrefuses the update with nothing queued when it has an error issue (409,\ncode `PART_INSTALL_PREVIEW_FAILED`, with those issues): a reconcile\nconflict (the issue names the table), a slot new in the version that\nthe install's request does not bind (an update cannot bind one; install\nthe version afresh instead), or a table the install created that the\nversion no longer has, renamed or dropped (issue code\n`PART_UPDATE_TABLE_REMOVED`): an update never renames or drops a table.\nThe same checks fail the job, with nothing applied, when the workspace\nchanges between the request and the job's run.\nThe update runs under the caller's grant exactly as an install does: a\nperson's session, an API token or an OAuth client may ask; an assumed or\nhosted-site session and the install job's own token are refused (403,\ncode `PART_INSTALL_NEEDS_PERSON`). Preview it first with\n`POST /library/installs/{installId}/update/preview` and send its\n`targetVersion` as `expectedVersion`.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "installId",
            "in": "path",
            "required": true,
            "description": "The id of the succeeded install to update.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateInstallRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The update's install job, queued; its `updatedFrom` names the install it updates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartInstall"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Refused: the caller does not hold the permission this needs, or the request does not come from a person's session, an API token or an OAuth client (code `PART_INSTALL_NEEDS_PERSON`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No succeeded install with this id in this workspace (code `INSTALL_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The update was refused: the install is already at the latest installable version, has been superseded by a succeeded update, or its part is no longer installable here (code `INSTALL_UP_TO_DATE`); another install into this workspace is still queued or running (code `PART_INSTALL_IN_FLIGHT`); the install's stored request is not one this platform reads, so install the part afresh (code `PART_INSTALL_REQUEST_INVALID`); `expectedVersion` was sent and the part's latest installable version is no longer it, so preview again (code `INSTALL_UPDATE_VERSION_MOVED`); the update's preview has error issues, which `issues` lists (code `PART_INSTALL_PREVIEW_FAILED`); the target version no longer validates on the current platform (code `PART_VERSION_STALE`, with the issues); or this workspace is on an older schema era than the version needs (code `PART_WORKSPACE_ERA_BEHIND`). For the other codes `issues` is empty",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/library/installs/{installId}/update/preview": {
      "post": {
        "operationId": "libraryInstallsInstallIdUpdatePreviewPost",
        "x-permission": "schema:apply",
        "summary": "Preview updating a schema part install",
        "description": "Previews `POST /library/installs/{installId}/update` without changing\nanything: the part's latest installable version, run through the install\npreview with the install's own stored request (its table names and\nbindings) into this workspace, in `reconcile` mode with every companion,\nthe table settings, the sample data and the lifecycle changes on tables\nthat already exist left out, exactly as the update runs. The answer\nnames the version previewed (`targetVersion`) and carries the preview:\nreconcile conflicts on tables or fields the version changes, slots that\nno longer bind (a slot new in the version, or a bound table deleted\nsince), what would be added, and the existing tables it would change,\nplus in `issues.other` each table the install created that the version\nrenamed or dropped (issue code `PART_UPDATE_TABLE_REMOVED`). The update\nitself runs this preview and refuses on any error issue. An optional\nbody binds the slots the new version adds (`bindings`), merged over\nthe stored request; send the same bindings with the update.\n",
        "tags": [
          "Library"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "installId",
            "in": "path",
            "required": true,
            "description": "The id of the succeeded install to preview an update of.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstallUpdatePreviewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The update preview",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstallUpdatePreview"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No succeeded install with this id in this workspace (code `INSTALL_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "There is nothing to update to: the install is already at the latest installable version, has been superseded by a succeeded update, or its part is no longer installable here (code `INSTALL_UP_TO_DATE`); the install's stored request is not one this platform reads (code `PART_INSTALL_REQUEST_INVALID`); the target version no longer validates on the current platform (code `PART_VERSION_STALE`, with the issues); or this workspace is on an older schema era than the version needs (code `PART_WORKSPACE_ERA_BEHIND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPartRefusal"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/schema-plans/export": {
      "get": {
        "operationId": "schemaPlansExportGet",
        "x-permission": "tables:read",
        "summary": "Export the workspace's schema as a schema-plan document",
        "description": "Returns the workspace's current schema as a version-1 schema-plan\ndocument — the same format `/schema-plans/apply` consumes, so the\nresult can be committed to git, diffed against another workspace, or\napplied to an empty one to reproduce this schema. Output ordering is\ndeterministic (tables, constraints, automations and views by name;\nfields in the table's own display order), so two exports of the same\nschema are identical and a diff shows only real change.\n\nCovers tables, fields (including formula / lookup / rollup fields),\ntable constraints, declarative automation rules, SQL views and stage\n(lifecycle) designations. Anything the plan format cannot express\ncomes back in `warnings` naming the object and the setting rather than\nbeing silently omitted — see docs/SCHEMA_AS_CODE.md for the full\nround-trip contract and its documented gaps. Read-only; open to all\nworkspace roles.\n",
        "tags": [
          "SchemaPlans"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tables",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_]{1,63}(,[a-zA-Z0-9_]{1,63})*$",
              "maxLength": 2048
            },
            "description": "Comma-separated table/view names to scope the export to. Omit for the whole workspace. A name that matches nothing is reported as a warning rather than ignored.\n"
          }
        ],
        "responses": {
          "200": {
            "description": "The workspace schema as a schema-plan document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaExportResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/schema-plans/apply": {
      "post": {
        "operationId": "schemaPlansApplyPost",
        "x-permission": "schema:apply",
        "summary": "Atomically apply a schema plan (workspace admin/owner only)",
        "description": "Revalidates the plan against the current schema, then creates all tables\nand fields in a single database transaction — everything is created or\nnothing is. Additive only: plans can never delete, rename, or retype\nexisting schema. Requires the workspace admin or owner role.\n",
        "tags": [
          "SchemaPlans"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SchemaPlanRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Plan applied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPlanApplyResult"
                }
              }
            }
          },
          "400": {
            "description": "Plan invalid or apply failed — nothing was changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaPlanApplyResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "planId unknown or expired (`PLAN_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/dashboards/{dashboardId}/run": {
      "post": {
        "operationId": "dashboardsDashboardIdRunPost",
        "x-replica-reads": true,
        "x-permission": "dashboards:read",
        "x-rate-limit": {
          "measure": "query.executions"
        },
        "summary": "Run every chart and table tile of a dashboard in one request",
        "description": "Answers a whole dashboard at once (REVIEWABLE_CHARTS_DESIGN.md step 6): the chart and table tiles' rows, each under its own authorization, so a page shows ten tiles with one request and one Lambda invocation instead of ten. `dashboards:read` admits the caller to the dashboard; each tile is then authorized as its own endpoint would authorize it, and a refused tile answers with a per-tile 403 body while the rest of the dashboard answers: a SQL tile needs `query:execute` and unrestricted record visibility, like `POST /query`; a chart drawn from a table's records needs `records:read` and runs through the same row-scoped, field-masked aggregate as `POST /tables/{tableId}/aggregate`. The dashboard's variable values travel in the body and are resolved per tile by the one shared precedence rule. Metered as one query execution per distinct SQL statement the run executes (identical SQL across tiles counts once), the same allowance `POST /query` draws on; a statement the allowance no longer covers answers 429 in its tile. Saved-view tiles are not included.",
        "tags": [
          "Dashboards"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "dashboardId",
            "in": "path",
            "required": true,
            "description": "The dashboard's id, or its API name (`apiName`), which stays the same when the dashboard is renamed and in a copy of the workspace.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DashboardRunRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Every chart and table tile's result or refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardRunResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/dashboard-plans/validate": {
      "post": {
        "operationId": "dashboardPlansValidatePost",
        "x-permission": "dashboards:read",
        "summary": "Dry-run a dashboard plan against the workspace",
        "description": "Validates a version-1 dashboard plan (new saved queries, charts, and\ndashboards expressed as one document, with by-ref links between them\nand by-id reuse of existing queries/charts) without creating anything.\nNew SQL is parsed and planned read-only (EXPLAIN) against the\nworkspace. Returns errors and warnings — each with a stable code, the\npath of the offending element, and a fix suggestion — plus a\nhuman-readable summary for user confirmation. Open to all workspace\nroles.\n",
        "tags": [
          "DashboardPlans"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DashboardPlanRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation completed (check the valid flag)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardPlanValidationResult"
                }
              }
            }
          },
          "400": {
            "description": "The request named neither or both of plan and planId, or its patch could not be applied — as a teaching issue in the result document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardPlanValidationResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "planId unknown or expired (`PLAN_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/dashboard-plans/apply": {
      "post": {
        "operationId": "dashboardPlansApplyPost",
        "x-permission": "dashboards:manage",
        "summary": "Atomically apply a dashboard plan",
        "description": "Revalidates the plan against the current workspace, then creates all\nof its saved queries, charts, and dashboards in a single database\ntransaction — everything is created or nothing is. The created objects\nare ordinary saved queries, charts, and dashboards, indistinguishable\nfrom ones created via their own endpoints. Additive only: plans never\nmodify or delete existing objects. Requires the dashboards:manage\naction (baseline roles grant it together with savedQueries:manage and\ncharts:manage, which the created objects also belong to).\n",
        "tags": [
          "DashboardPlans"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DashboardPlanRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Plan applied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardPlanApplyResult"
                }
              }
            }
          },
          "400": {
            "description": "Plan invalid or apply failed — nothing was changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardPlanApplyResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions (admin or owner required)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "planId unknown or expired (`PLAN_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/imports/uploads": {
      "post": {
        "operationId": "importsUploadsPost",
        "x-permission": "records:create",
        "summary": "Presign a CSV upload for import",
        "description": "Returns a presigned S3 upload for a CSV file: a single-PUT URL for\nfiles under the multipart threshold, or a multipart upload (uploadId +\nper-part URLs, completed via /imports/uploads/complete) above it. The\nreturned s3Key is scoped to the caller's workspace and is the handle\nevery subsequent import call takes.\n",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportUploadRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Presigned upload created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportUploadResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid filename or size (over the import size limit)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/imports/uploads/complete": {
      "post": {
        "operationId": "importsUploadsCompletePost",
        "x-permission": "records:create",
        "summary": "Complete a multipart CSV upload",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportUploadCompleteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upload completed"
          },
          "400": {
            "description": "Unknown upload or invalid part list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/imports/analyze": {
      "post": {
        "operationId": "importsAnalyzePost",
        "x-permission": "records:create",
        "summary": "Analyze uploaded CSVs — inferred schema, validation, relationships",
        "description": "Reads a bounded sample of each uploaded file (the response's sampled\nflag says when) and returns per-column schema inference with\nconfidence-ranked type candidates, consistency warnings, and\nunique/required suggestions. With multiple files it also detects\ncross-file relationships (value containment + naming heuristics) and\nreturns a ready-to-edit schema plan proposal. Everything returned is a\nsuggestion for the import wizard; nothing is created.\n\nWhere the AI rule proposer is available (and the request does not say\n`ai: false`), columns left as text may also carry a `ruleProposal`\nmarked `source: ai`. It is proposed after the analysis is complete and\nchanges nothing else in it; the model sees each such column's header,\na bounded sample of its distinct values and the candidate fields —\nnever the file, and never another table's rows.\n\nWith `adapter: salesforce` and the objects' describe documents in\n`adapterMetadata`, a column the metadata names is typed from it rather\nthan from its values (`sourceType` says so), a lookup to an object\nuploaded alongside is returned as a `declared` relationship, and\ncolumns naming users are suggested for skipping; a describe that does\nnot parse is refused (400).\n",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportAnalyzeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Analysis of the uploaded files",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportAnalysis"
                }
              }
            }
          },
          "400": {
            "description": "Unreadable file, file over the import limits, or adapter metadata that does not parse",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "One of the s3Keys does not belong to this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/imports/preview": {
      "post": {
        "operationId": "importsPreviewPost",
        "x-permission": "records:create",
        "summary": "Preview what a mapping's import rules do to real rows",
        "description": "Applies a mapping — import rules included — to the analyze-time bounded\nsample of an uploaded file, and returns the transformed rows plus a\nfailure count per rule. The point is to see a rule chain's verdict on\nreal data before an import writes anything: which cells the `extract`\npattern could not read, which values the `mapValues` vocabulary does\nnot know, what the address actually split into.\n\nReads only. Nothing is created, no job is enqueued, and the file is\nread within the same bounded sample the analyze step uses, so a\n1GB upload costs a preview no more than a small one.\n\nWith `tableId`, cells are coerced by the target table's real field types\nand reported exactly as the import would report them — the faithful\npreview, for a mapping onto an existing table. Without it, the rules run\nand their text is returned uncoerced, which is what a mapping onto a\ntable the import has yet to create can honestly show.\n\nA chain that cannot compile at all (a pattern that can backtrack, a\n`remainder` following nothing) is a 400 naming the column and the rule —\nthe same refusal the job would fail with, arriving before the job.\n",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportPreviewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The sample rows as the mapping's rules transform them",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportPreviewResponse"
                }
              }
            }
          },
          "400": {
            "description": "A rule chain that cannot compile, or an unreadable file",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The s3Key does not belong to this workspace, or tableId does not exist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/imports/matches": {
      "post": {
        "operationId": "importsMatchesPost",
        "x-permission": "records:create",
        "summary": "Preview which existing records an import's key matches",
        "description": "Runs a file's column mapping over the analyze-time bounded sample and\nmatches each row's key against the target table, the way the job\nwill: exactly, after normalisation, or by similarity with a\nthreshold. Returns the rows that found a record — those the job would\nupdate or skip, and those it would hold as possible matches for a\ndecision — with the candidate records, so a reviewer can confirm,\nchoose another, or insert as new before the job runs. Their answers\ntravel on the job as `matchDecisions`.\n\nReads only, under the caller's own row scope. The sample is bounded\nlike the analysis and the rule preview; the job reads every row, and\nreports any further possible matches in its result.\n",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportMatchPreviewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The sampled rows that found a record, with the verdict the job would reach for each",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportMatchPreviewResponse"
                }
              }
            }
          },
          "400": {
            "description": "A key field that is not mapped or cannot be matched on, a mapping that cannot compile, an unreadable file, or a table past the similarity cap",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The s3Key does not belong to this workspace, or tableId does not exist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/imports/jobs": {
      "post": {
        "operationId": "importsJobsPost",
        "x-permission": "schema:apply",
        "summary": "Start a table-creating import job, with backdated stage history when supplied (admin/owner only)",
        "description": "Enqueues an async import that first applies a schema plan (creating\none or more tables, including any cross-table reference fields) and\nthen loads the given CSV files into them, resolving cross-file\nreferences in a second pass and, when the request carries an\n`activityLinks` file, attaching activities to the records it names in\na third; an `attachments` manifest files uploaded bodies into\nattachment fields, and a `stageHistory` file writes past stage moves\nas history, last.\n\n**Stage history starts at the import unless `stageHistory` supplies\nit.** A record loaded into a table whose stage field is designated\ngets one `null → current value` transition dated at the import, so\nevery aging and time-in-stage figure counts from then. To carry the\nhistory the records had in the system they came from, give the job a\n`stageHistory` file (one row per past move, keyed by a field such as\nthe source id): the job then writes no import-time baseline for the\ntables it loads and seeds each record's chain from the file, the way\n`POST /tables/{tableId}/stage-transitions/seed` does with `source`\n`import`; a stage-config snapshot (`snapshotDating`) afterwards dates\nonly the records the file said nothing about. A table imported\nwithout `stageHistory` is backdated later with that seed operation\nand `replace: true` (sandbox workspaces).\n\nThe plan is structurally validated\nsynchronously — plan errors come back immediately as a 400 with\nteaching issues; everything else happens in the background job.\nPoll GET /imports/jobs/{jobId} for progress. Imports into existing\ntables (no schema changes) use POST /tables/{tableId}/import instead,\nwhich members may call.\n",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportJobRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Import job enqueued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportJob"
                }
              }
            }
          },
          "400": {
            "description": "Invalid plan, files, or options — nothing was enqueued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportJobRejection"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient permissions (admin or owner required)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A target table is mirrored (code `MIRRORED_TABLE_READ_ONLY`): only its sync writes its records.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "get": {
        "operationId": "importsJobsGet",
        "x-permission": "tables:read",
        "summary": "List import jobs for the workspace (newest first)",
        "description": "Newest first. `ids` narrows the list to named jobs, so one call\nconfirms a batch of imports — each job's status, result and error\ncounts — instead of one read per job.\n",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "ids",
            "in": "query",
            "required": false,
            "description": "Comma-separated job ids to return, at most 100. Every named job the caller can see is returned (limit and offset do not apply); unknown ids, and jobs of other workspaces, are simply absent.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Import jobs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ImportJob"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/imports/jobs/{jobId}": {
      "get": {
        "operationId": "importsJobsJobIdGet",
        "x-permission": "tables:read",
        "summary": "Get an import job's status, progress, and result",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The import job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportJob"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such job in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/imports/jobs/{jobId}/cancel": {
      "post": {
        "operationId": "importsJobsJobIdCancelPost",
        "x-permission": "records:create",
        "summary": "Request cancellation of an import job",
        "description": "Queued jobs cancel immediately; running jobs cancel cooperatively at\nthe next batch boundary. Tables and rows already created stay (the\nresult reports exactly what was imported). Only the job's creator or\na workspace admin may cancel.\n",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Cancellation requested (job returned with current state)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportJob"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not the job creator or a workspace admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such job in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/imports/jobs/{jobId}/revert": {
      "post": {
        "operationId": "importsJobsJobIdRevertPost",
        "x-permission": "records:delete",
        "summary": "Revert an import — move the records it created to the recycle bin",
        "description": "Enqueues a `revert` job that moves every record the import created to\nthe recycle bin, as one bin batch keyed by the revert job's id: restore\nany one of them from a table's bin and they all come back. Records the\nimport updated keep the values it wrote (the result counts them as\n`updatesKept`). Rows the reverting member could not\ndelete are left live and counted as `skipped`. Allowed within the\nworkspace's revert window after the import finished, for a succeeded\nor cancelled import that created records, by the job's creator or a\nworkspace admin holding `records:delete`. Poll the returned job as\nany other import job.\n",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Revert job enqueued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportJob"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not the job creator or a workspace admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such job in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The import cannot be reverted. `code` says why: `NOT_REVERTABLE` (a dry run, a pull, a failed import, or nothing created), `REVERT_WINDOW_CLOSED`, `REVERT_IN_PROGRESS`, `ALREADY_REVERTED`, or `NOTHING_TO_REVERT` (no record of what the job wrote).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/imports/sources/http": {
      "post": {
        "operationId": "importsSourcesHttpPost",
        "x-permission": "secrets:manage",
        "summary": "Pull records from an HTTP source into a staged import document (admin only)",
        "description": "Enqueues an async `fetch_http` job that pages through a JSON API,\nauthenticated with a workspace secret or (`auth.kind: none`) not at\nall, and stages what it fetched as one JSON document. The job is resumable across pages and reports the\nrecords fetched as it runs; when it succeeds, `result.fetched` names\nthe staged document, which `POST /imports/analyze`, `POST\n/imports/preview` and `POST /imports/jobs` then take exactly like an\nupload — the mapping, rules, duplicate handling and row report are the\nordinary import's. Gated by `secrets:manage` because the job sends a\nworkspace secret to a URL the caller chose; a keyless source is gated\nthe same way. The URL is checked against the outbound policy before\nanything is enqueued, keyless or not, and a named secret must exist.\n",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportHttpSourceRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Fetch job enqueued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportJob"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/tables/{tableId}/import": {
      "post": {
        "operationId": "tablesTableIdImportPost",
        "x-permission": "records:create",
        "summary": "Start an import of one CSV into an existing table",
        "description": "Enqueues an async import of a single CSV into an existing table.\nColumns map to fields by `mapping`, by name when `mapping` is omitted\n(a header equal to a field's name or display name, case-insensitive),\nor both with `autoMap`; the 202 reports the resolved mapping, the\ncolumns skipped and any required field left unmapped, so a dry run\nshows what auto-mapping chose before anything is written. Unmapped\ncolumns are skipped. A reference column may hold the target's\nreference-key value (its unique label, or the field `matchBy`\nnames) instead of a record id — each cell resolves to the matching\nrecord, and one that matches nothing is a row error (the import\nresolves keys on its own; `POST /tables/{tableId}/items/bulk` takes\nids unless its `resolve` map asks for the same lookup). A record\nloaded into a table with a designated stage field starts its stage\nhistory at the import (one `null → current` transition dated now);\nto carry past moves over, run the import as a job on `POST\n/imports/jobs` with a `stageHistory` file, or seed them afterwards\nwith `POST /tables/{tableId}/stage-transitions/seed`. Values are\ncoerced and validated against the table's field rules\n(a currency cell is an amount with an optional symbol or ISO code —\n`120`, `€120`, `120 EUR` — defaulting to the field's currency; a\nmultipicklist cell separates values with `;`); invalid rows are\nskipped and reported per-row (or fail the job, depending on\noptions). Rows that duplicate existing records can be appended\nanyway, skipped, or turned into updates via duplicateHandling +\nmatchFieldName; update mode additionally requires the records:update\naction and honours the caller's row/field permissions, and — since a\nmatched row is a partial update — does not require unmapped required\nfields: only a row that matches nothing (and would insert) is refused\nover them, per row. Use dryRun for a full-file validation report with zero\nwrites — it also previews insert/update/duplicate counts. Poll\nGET /imports/jobs/{jobId} for progress — or pass `wait` to hold the\nresponse until the job has finished (small files finish in well under\na second) and receive the finished job, result included, as a 200.\n",
        "tags": [
          "Imports"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tableId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "With `wait`, the job finished within the cap: status succeeded,\nfailed or cancelled, with its result (or error) — the same\ndocument GET /imports/jobs/{jobId} would return.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportJob"
                }
              }
            }
          },
          "202": {
            "description": "Import job enqueued (or, with `wait`, still running at the cap — poll it)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportJob"
                }
              }
            }
          },
          "400": {
            "description": "Invalid mapping, file, or options",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such table in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The target table is mirrored (code `MIRRORED_TABLE_READ_ONLY`): only its sync writes its records.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TableImportRequest"
              }
            }
          }
        }
      }
    },
    "/queries": {
      "get": {
        "operationId": "queriesGet",
        "x-permission": "savedQueries:read",
        "summary": "List saved queries for the workspace",
        "tags": [
          "Queries"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of saved queries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SavedQuery"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "queriesPost",
        "x-permission": "savedQueries:manage",
        "summary": "Create a saved query",
        "tags": [
          "Queries"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSavedQueryRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Query created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedQuery"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "The `apiName` in the request is one another saved query already has.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/queries/{queryId}": {
      "get": {
        "operationId": "queriesQueryIdGet",
        "x-permission": "savedQueries:read",
        "summary": "Get a saved query",
        "tags": [
          "Queries"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "queryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Saved query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedQuery"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "queriesQueryIdPut",
        "x-permission": "savedQueries:manage",
        "summary": "Update a saved query",
        "tags": [
          "Queries"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "queryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSavedQueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedQuery"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "queriesQueryIdDelete",
        "x-permission": "savedQueries:manage",
        "summary": "Delete a saved query",
        "tags": [
          "Queries"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "queryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/queries/{queryId}/run": {
      "post": {
        "operationId": "queriesQueryIdRunPost",
        "x-replica-reads": true,
        "x-permission": "query:execute",
        "summary": "Run a saved query and return its rows",
        "description": "Runs the query as it is saved right now, so an integration names the\nreport it wants instead of carrying its SQL around, and an edit to the\nquery changes what the integration receives.\n\nThe gate is the one on POST /query, not the one on reading the saved\nquery document: this executes SQL, which cannot take row-level scope\nfilters, so the caller must hold unrestricted record visibility. It\ndraws on the same query quota as an interactive run.\n",
        "tags": [
          "Queries"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "queryId",
            "in": "path",
            "required": true,
            "description": "The saved query's id, or its API name (`apiName`), which stays the same when the saved query is renamed and in a copy of the workspace.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunSavedQueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The query's rows",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryResponse"
                }
              }
            }
          },
          "400": {
            "description": "The saved query no longer runs (see the error code)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Your record visibility is restricted, so you cannot run queries",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such saved query in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/charts": {
      "get": {
        "operationId": "chartsGet",
        "x-permission": "charts:read",
        "summary": "List saved charts for the workspace",
        "tags": [
          "Charts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of saved charts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SavedChart"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "chartsPost",
        "x-permission": "charts:manage",
        "summary": "Create a saved chart",
        "tags": [
          "Charts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSavedChartRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Chart created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedChart"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/charts/{chartId}": {
      "get": {
        "operationId": "chartsChartIdGet",
        "x-permission": "charts:read",
        "summary": "Get a saved chart",
        "tags": [
          "Charts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "chartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Saved chart",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedChart"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "chartsChartIdPut",
        "x-permission": "charts:manage",
        "summary": "Update a saved chart",
        "tags": [
          "Charts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "chartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSavedChartRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated chart",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedChart"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "chartsChartIdDelete",
        "x-permission": "charts:manage",
        "summary": "Delete a saved chart",
        "tags": [
          "Charts"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "chartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/charts/{chartId}/comments": {
      "get": {
        "operationId": "chartsChartIdCommentsGet",
        "x-permission": "comments:read",
        "summary": "List the discussion on one chart",
        "description": "User-authored comments on a chart — \"this bridge double counts churn\" beside the chart it is about — in thread order: each root followed by its replies, oldest thread first. The same comment shape, threading, mentions and resolution as a record's discussion (`GET /tables/{tableId}/items/{itemId}/comments`); a thread's root may be anchored to the dashboard tile the chart was read on.\nVisibility follows the chart's: the caller must hold `charts:read`, and a caller without it gets the same 404 as for a chart that does not exist. Charts carry no row scope, so no further filter applies.",
        "tags": [
          "ChartComments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "chartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum comments to return (default 50).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "How many comments, in thread order, to skip.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The chart's comments, in thread order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordCommentPage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Chart or comment not found, or the caller lacks `charts:read`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "chartsChartIdCommentsPost",
        "x-permission": "comments:create",
        "summary": "Post a comment on a chart",
        "description": "Starts a thread on the chart, or replies in one (`parentId`). A root may carry a `tile` anchor naming the dashboard tile the chart was being read on; a `field` anchor is refused here (400). Requires `charts:read` on top of `comments:create`, since commenting on a chart one cannot see makes no sense; a caller without it gets 404.\nMentions are parsed from the body by the server, as on a record. A mention of someone who lacks `charts:read` is stored but not notified and reported back as `chart_not_visible`.",
        "tags": [
          "ChartComments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "chartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRecordCommentRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The comment as stored, plus any mentions that could not be notified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateRecordCommentResponse"
                }
              }
            }
          },
          "400": {
            "description": "Empty or oversized body, too many mentions, a `field` anchor, or a `parentId` that is not a comment on this chart",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Chart or comment not found, or the caller lacks `charts:read`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/charts/{chartId}/comments/{commentId}": {
      "patch": {
        "operationId": "chartsChartIdCommentsCommentIdPatch",
        "x-permission": "comments:create",
        "summary": "Edit your own comment on a chart",
        "description": "AUTHOR ONLY, exactly as on a record: `comments:moderate` permits tombstoning, never rewriting. Sets `editedAt`. Requires `charts:read` (404 otherwise).",
        "tags": [
          "ChartComments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "chartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "commentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRecordCommentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The edited comment, plus any newly added mentions that could not be notified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateRecordCommentResponse"
                }
              }
            }
          },
          "400": {
            "description": "Empty or oversized body, or too many mentions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not the author",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Chart or comment not found, or the caller lacks `charts:read`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "chartsChartIdCommentsCommentIdDelete",
        "x-permission": "comments:create",
        "summary": "Delete a comment on a chart",
        "description": "Permitted for the author, or for a caller holding `comments:moderate`. Tombstones rather than removes, as on a record: the row survives so the thread's shape survives, and the body is emptied under a database CHECK. Requires `charts:read` (404 otherwise).",
        "tags": [
          "ChartComments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "chartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "commentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The tombstoned comment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordComment"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not the author, and not holding comments:moderate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Chart or comment not found, or the caller lacks `charts:read`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/charts/{chartId}/comments/{commentId}/resolution": {
      "put": {
        "operationId": "chartsChartIdCommentsCommentIdResolutionPut",
        "x-permission": "comments:create",
        "summary": "Resolve or reopen a thread",
        "description": "Settles a discussion thread, or takes it up again. Addressed at the thread's ROOT comment (a reply answers 400); any caller holding `comments:create` who may see the subject can resolve or reopen a thread, not only its author — a reviewer closes the question they asked, or the one they answered. Idempotent: resolving a resolved thread is a no-op 200. A resolved thread folds by default in the discussion, and on a record the change is also an entry in the record's history (`CommentResolved` / `CommentReopened`).",
        "tags": [
          "ChartComments"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "chartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          },
          {
            "name": "commentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommentResolutionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The root comment, with its resolution as it now stands",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordComment"
                }
              }
            }
          },
          "400": {
            "description": "The comment is a reply, not a thread's root, or the body is malformed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Chart or comment not found, or the caller lacks `charts:read`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/dashboards": {
      "get": {
        "operationId": "dashboardsGet",
        "x-permission": "dashboards:read",
        "summary": "List dashboards for the workspace",
        "tags": [
          "Dashboards"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of dashboards",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Dashboard"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "dashboardsPost",
        "x-permission": "dashboards:manage",
        "summary": "Create a dashboard",
        "tags": [
          "Dashboards"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDashboardRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Dashboard created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Dashboard"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "The `apiName` in the request is one another dashboard already has.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/dashboards/{dashboardId}": {
      "get": {
        "operationId": "dashboardsDashboardIdGet",
        "x-permission": "dashboards:read",
        "summary": "Get a dashboard",
        "tags": [
          "Dashboards"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "dashboardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Dashboard",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Dashboard"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "dashboardsDashboardIdPut",
        "x-permission": "dashboards:manage",
        "summary": "Update a dashboard",
        "tags": [
          "Dashboards"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "dashboardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDashboardRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated dashboard",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Dashboard"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "dashboardsDashboardIdDelete",
        "x-permission": "dashboards:manage",
        "summary": "Delete a dashboard",
        "tags": [
          "Dashboards"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "dashboardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/store/workspace": {
      "get": {
        "operationId": "workspaceStoreGet",
        "x-permission": "store:read",
        "summary": "List workspace store items",
        "description": "Get all items from the workspace store, optionally filtered by type",
        "tags": [
          "Store"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Filter by item type"
          }
        ],
        "responses": {
          "200": {
            "description": "List of workspace store items",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkspaceStoreItem"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "workspaceStorePost",
        "x-permission": "store:manage",
        "summary": "Create a workspace store item",
        "description": "Create a new item in the workspace store",
        "tags": [
          "Store"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorkspaceStoreItem"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Item created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceStoreItem"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/store/workspace/{itemId}": {
      "get": {
        "operationId": "workspaceStoreItemGet",
        "x-permission": "store:read",
        "summary": "Get a workspace store item",
        "tags": [
          "Store"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The workspace store item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceStoreItem"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "workspaceStoreItemPut",
        "x-permission": "store:manage",
        "summary": "Update a workspace store item",
        "tags": [
          "Store"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWorkspaceStoreItem"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Item updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceStoreItem"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Item is locked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "workspaceStoreItemDelete",
        "x-permission": "store:manage",
        "summary": "Delete a workspace store item",
        "tags": [
          "Store"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Item deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Item is locked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/store/user": {
      "get": {
        "operationId": "userStoreGet",
        "summary": "List user store items",
        "description": "Get all items from the current user's store, optionally filtered by type",
        "tags": [
          "Store"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Filter by item type"
          }
        ],
        "responses": {
          "200": {
            "description": "List of user store items",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/UserStoreItem"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "userStorePost",
        "summary": "Create a user store item",
        "description": "Create a new item in the current user's store",
        "tags": [
          "Store"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateUserStoreItem"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Item created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserStoreItem"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/store/user/{itemId}": {
      "get": {
        "operationId": "userStoreItemGet",
        "summary": "Get a user store item",
        "tags": [
          "Store"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The user store item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserStoreItem"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "userStoreItemPut",
        "summary": "Update a user store item",
        "tags": [
          "Store"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateUserStoreItem"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Item updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserStoreItem"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Item is locked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "userStoreItemDelete",
        "summary": "Delete a user store item",
        "tags": [
          "Store"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Item deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Item is locked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Item not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-tokens": {
      "get": {
        "operationId": "apiTokensGet",
        "x-permission": "tokens:manage",
        "summary": "List API tokens",
        "tags": [
          "API Tokens"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of API tokens (metadata only, no token values)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ApiToken"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "apiTokensPost",
        "x-permission": "tokens:manage",
        "summary": "Create an API token",
        "tags": [
          "API Tokens"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateApiTokenRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Token created — includes one-time token value",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiTokenCreated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/agents": {
      "get": {
        "operationId": "agentsGet",
        "x-permission": "agents:manage",
        "summary": "List agents",
        "description": "The caller's own agents; every agent in the workspace for a caller who holds `permissions:manage`.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The agents, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Agent"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "agentsPost",
        "x-permission": "agents:manage",
        "summary": "Create an agent",
        "description": "Creates an agent owned by the caller, with no roles. Attach roles with `POST /agents/{agentId}/roles`, then choose the agent on the consent screen when connecting an AI client.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAgentRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The agent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/agents/{agentId}": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The agent's id."
        }
      ],
      "get": {
        "operationId": "agentsAgentIdGet",
        "x-permission": "agents:manage",
        "summary": "Get an agent",
        "description": "An agent the caller owns, or any agent for a caller who holds `permissions:manage`.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The agent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "agentsAgentIdPatch",
        "x-permission": "agents:manage",
        "summary": "Change an agent",
        "description": "Rename, re-describe, disable or enable an agent the caller owns (or any, with `permissions:manage`). Disabling takes effect on the agent's next request.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAgentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The agent as it now is",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "agentsAgentIdDelete",
        "x-permission": "agents:manage",
        "summary": "Delete an agent",
        "description": "Deletes an agent the caller owns (or any, with `permissions:manage`) and the roles attached to it. Every token the agent held stops authenticating at once; what it wrote stays, attributed to the owner with the agent's name.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/agents/{agentId}/roles": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The agent's id."
        }
      ],
      "post": {
        "operationId": "agentsAgentIdRolesPost",
        "x-permission": "agents:manage",
        "summary": "Attach a role to an agent",
        "description": "The owner may attach a role they hold themselves; a caller with `permissions:manage` may attach any role whose grants are within their own (403 `PERMISSION_DENIED` otherwise, as for every role assignment). The agent's permissions change on its next request.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttachAgentRoleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The agent with the role attached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The agent already holds the role",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/agents/{agentId}/roles/{roleId}": {
      "parameters": [
        {
          "name": "agentId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The agent's id."
        },
        {
          "name": "roleId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The role to detach."
        }
      ],
      "delete": {
        "operationId": "agentsAgentIdRolesRoleIdDelete",
        "x-permission": "agents:manage",
        "summary": "Detach a role from an agent",
        "description": "Removes the role from an agent the caller owns (or any, with `permissions:manage`). The agent's permissions change on its next request.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The agent with the role detached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integration-accounts": {
      "get": {
        "operationId": "integrationAccountsGet",
        "x-permission": "integrationAccounts:manage",
        "summary": "List integrations",
        "description": "The workspace's integrations, newest first. A deleted integration is not listed; what it wrote keeps its name.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The integrations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/IntegrationAccount"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "integrationAccountsPost",
        "x-permission": "integrationAccounts:manage",
        "summary": "Create an integration",
        "description": "Creates an integration with no roles and no tokens. Attach roles, then issue a token for the machine to use. A request made with an integration's own token cannot manage integrations.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateIntegrationAccountRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The integration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationAccount"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The workspace already holds an install of this partner",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integration-accounts/{integrationId}": {
      "parameters": [
        {
          "name": "integrationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The integration's id."
        }
      ],
      "get": {
        "operationId": "integrationAccountsIntegrationIdGet",
        "x-permission": "integrationAccounts:manage",
        "summary": "Get an integration",
        "description": "One integration, with its roles and how many tokens it holds.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The integration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationAccount"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "integrationAccountsIntegrationIdPatch",
        "x-permission": "integrationAccounts:manage",
        "summary": "Change an integration",
        "description": "Rename, re-describe, disable or enable an integration. Disabling stops every token it holds on their next request.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateIntegrationAccountRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The integration as it now is",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationAccount"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "integrationAccountsIntegrationIdDelete",
        "x-permission": "integrationAccounts:manage",
        "summary": "Delete an integration",
        "description": "Deletes the integration's tokens and roles and removes it from the list. What it wrote stays, still naming it, in record history and the audit log.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integration-accounts/{integrationId}/roles": {
      "parameters": [
        {
          "name": "integrationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The integration's id."
        }
      ],
      "post": {
        "operationId": "integrationAccountsIntegrationIdRolesPost",
        "x-permission": "integrationAccounts:manage",
        "summary": "Attach a role to an integration",
        "description": "A caller may attach a role they hold themselves; a caller with `permissions:manage` may attach any role whose grants are within their own (403 `PERMISSION_DENIED` otherwise). The integration's permissions change on its next request.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttachIntegrationRoleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The integration with the role attached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationAccount"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The integration already holds the role",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integration-accounts/{integrationId}/roles/{roleId}": {
      "parameters": [
        {
          "name": "integrationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The integration's id."
        },
        {
          "name": "roleId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The role to detach."
        }
      ],
      "delete": {
        "operationId": "integrationAccountsIntegrationIdRolesRoleIdDelete",
        "x-permission": "integrationAccounts:manage",
        "summary": "Detach a role from an integration",
        "description": "Removes the role. The integration's permissions change on its next request.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The integration with the role detached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationAccount"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integration-accounts/{integrationId}/tokens": {
      "parameters": [
        {
          "name": "integrationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The integration's id."
        }
      ],
      "get": {
        "operationId": "integrationAccountsIntegrationIdTokensGet",
        "x-permission": "integrationAccounts:manage",
        "summary": "List an integration's tokens",
        "description": "The tokens the integration holds, without their values.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The tokens",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ApiToken"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "integrationAccountsIntegrationIdTokensPost",
        "x-permission": "integrationAccounts:manage",
        "summary": "Issue a token to an integration",
        "description": "Issues a token that acts as the integration and holds exactly its roles. The value is in this answer only, never again.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateIntegrationTokenRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The token, with its value",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiTokenCreated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The integration is a partner's install, whose tokens the partner mints",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integration-accounts/{integrationId}/tokens/{tokenId}/rotate": {
      "parameters": [
        {
          "name": "integrationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The integration's id."
        },
        {
          "name": "tokenId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The token's id."
        }
      ],
      "post": {
        "operationId": "integrationAccountsIntegrationIdTokensTokenIdRotatePost",
        "x-permission": "integrationAccounts:manage",
        "summary": "Rotate an integration's token",
        "description": "Issues a new token with the same name and expiry and revokes the old one, in one write. The new value is in this answer only.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "The new token, with its value",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiTokenCreated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/integration-accounts/{integrationId}/tokens/{tokenId}": {
      "parameters": [
        {
          "name": "integrationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The integration's id."
        },
        {
          "name": "tokenId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "The token's id."
        }
      ],
      "delete": {
        "operationId": "integrationAccountsIntegrationIdTokensTokenIdDelete",
        "x-permission": "integrationAccounts:manage",
        "summary": "Revoke an integration's token",
        "description": "The token stops working on its next request.",
        "tags": [
          "Integrations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "Revoked"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/hosted-site": {
      "get": {
        "operationId": "hostedSiteGet",
        "x-permission": "hostedSites:manage",
        "summary": "Get the workspace's hosted site, the custom app frontend it deploys for signed-in users",
        "description": "The site's id, origin and active deployment. A hosted site is a custom frontend (a static single-page app) the workspace's admins build and deploy; it is served at its own address to signed-in members of the workspace only, and its pages call this API as the member using it. Authoring guide for site authors: the MCP tool `get_hosted_site_authoring_guide` (sign-in, the `/_api` proxy, sessions, what a site may call, deploying), also published as the Custom apps guide on tessule.com.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The workspace's hosted site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HostedSite"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "This workspace has no hosted site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Hosted sites are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "hostedSitePost",
        "x-permission": "hostedSites:manage",
        "summary": "Create the workspace's hosted site, a custom app frontend for signed-in users",
        "description": "Assigns the workspace a site id and its own origin. The site serves nothing until a deployment is activated. A workspace has at most one site. Use it for a live, signed-in, API-backed custom frontend; a published page is for static HTML that never calls the API. Authoring guide for site authors: the MCP tool `get_hosted_site_authoring_guide` (sign-in, the `/_api` proxy, sessions, what a site may call, deploying), also published as the Custom apps guide on tessule.com.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Site created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HostedSite"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "This workspace already has a hosted site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Hosted sites are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "hostedSiteDelete",
        "x-permission": "hostedSites:manage",
        "summary": "Delete the workspace's hosted site (custom app)",
        "description": "Takes the site offline at the edge at once, then removes its deployments and files. The hostname is not reused. Authoring guide for site authors: the MCP tool `get_hosted_site_authoring_guide` (sign-in, the `/_api` proxy, sessions, what a site may call, deploying), also published as the Custom apps guide on tessule.com.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "Site deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "This workspace has no hosted site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Hosted sites are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/hosted-site/deployments": {
      "get": {
        "operationId": "hostedSiteDeploymentsGet",
        "x-permission": "hostedSites:manage",
        "summary": "List the hosted site's deployments (custom app builds), newest first",
        "description": "Every deployment of the site with its status, size and uploader; the one with status `active` is what the site serves. Authoring guide for site authors: the MCP tool `get_hosted_site_authoring_guide` (sign-in, the `/_api` proxy, sessions, what a site may call, deploying), also published as the Custom apps guide on tessule.com.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The site's deployments",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/HostedSiteDeployment"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "This workspace has no hosted site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Hosted sites are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "hostedSiteDeploymentsPost",
        "x-permission": "hostedSites:manage",
        "summary": "Deploy a custom app build by starting a hosted-site deployment",
        "description": "Declares the deployment's files and returns a presigned upload URL for each one the site does not already hold: a file declared with a `sha256` the site holds from an earlier deployment is reused, and needs no upload. Upload every listed file, then activate the deployment. Nothing is served until activation. Each file's cache policy follows the manifest's `cache` rules and the defaults. `POST /hosted-site/deployments/archive` deploys a whole build in one request instead. Authoring guide for site authors: the MCP tool `get_hosted_site_authoring_guide` (sign-in, the `/_api` proxy, sessions, what a site may call, deploying), also published as the Custom apps guide on tessule.com.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateHostedSiteDeploymentRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Deployment started",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HostedSiteDeploymentCreated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid manifest or cache rules (code `INVALID_MANIFEST`), over the workspace's file-count or size limit, or too many unfinished deployments",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "This workspace has no hosted site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Hosted sites are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/hosted-site/extensions": {
      "get": {
        "operationId": "hostedSiteExtensionsGet",
        "x-permission": "customization:read",
        "summary": "List the app extensions the hosted site offers",
        "description": "The extensions declared by the hosted site's active deployment, with the deployment's id. A layout editor lists them to place one on a record page; a record page resolves its extension blocks against them. Empty when the workspace has no site or the site declares none. Authoring guide for site authors: the MCP tool `get_hosted_site_authoring_guide` (sign-in, the `/_api` proxy, sessions, what a site may call, deploying), also published as the Custom apps guide on tessule.com.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The active deployment's extension catalog",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HostedSiteExtensionCatalog"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/hosted-site/extensions/{extensionId}/frame-sessions": {
      "post": {
        "operationId": "hostedSiteExtensionFrameSessionsPost",
        "x-permission": "customization:read",
        "summary": "Open a frame session for one app extension",
        "description": "Issues the address and token the app needs to show one extension in an iframe as the signed-in viewer. Refused with 403 `EXTENSION_CONSENT_REQUIRED` until the viewer has agreed to the extension's exact declared scopes; the body names them so the app can ask, then `POST /hosted-site/extensions/{extensionId}/consents` and retry. Authoring guide for site authors: the MCP tool `get_hosted_site_authoring_guide` (sign-in, the `/_api` proxy, sessions, what a site may call, deploying), also published as the Custom apps guide on tessule.com.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "extensionId",
            "in": "path",
            "required": true,
            "description": "Id of the extension, as listed by `GET /hosted-site/extensions`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Optional. Names the file of the extension the frame opens at; without a body the frame opens the extension's `index.html`.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HostedSiteExtensionFrameSessionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Frame session issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HostedSiteExtensionFrameSession"
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed, its `Origin` is not one of the app's origins (code `EXTENSION_ORIGIN_INVALID`: a frame session opens only from a page of the app), or its `path` has a `..` segment and so is not a route inside the extension's own folder (code `EXTENSION_PATH_INVALID`; a path outside the pattern fails request validation).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Consent required (code `EXTENSION_CONSENT_REQUIRED`, with the scope lists `scopes` and `newScopes`), or the caller may not mint a frame session (code `PERMISSION_DENIED`: only the app's own sign-in may, never an API token, an OAuth client or an assumed session). Discriminate on `code`.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/HostedSiteExtensionConsentRequired"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The active deployment declares no such extension (`EXTENSION_NOT_FOUND`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Hosted sites are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/hosted-site/extensions/{extensionId}/consents": {
      "post": {
        "operationId": "hostedSiteExtensionConsentsPost",
        "x-permission": "customization:read",
        "summary": "Agree to the scopes an app extension asks for",
        "description": "Records the viewer's consent to an extension acting with exactly the scopes sent. A set that differs from what the extension declares now is refused, so consent never covers more than the viewer was shown. Call it after a frame session answered `EXTENSION_CONSENT_REQUIRED`. Authoring guide for site authors: the MCP tool `get_hosted_site_authoring_guide` (sign-in, the `/_api` proxy, sessions, what a site may call, deploying), also published as the Custom apps guide on tessule.com.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "extensionId",
            "in": "path",
            "required": true,
            "description": "Id of the extension, as listed by `GET /hosted-site/extensions`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HostedSiteExtensionConsentRequest"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Consent recorded"
          },
          "400": {
            "description": "The request is malformed, or its scopes are not exactly the set the extension declares now (code `EXTENSION_CONSENT_MISMATCH`: fetch the extension again and show its current scopes).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/hosted-site/deployments/archive": {
      "post": {
        "operationId": "hostedSiteDeploymentsArchivePost",
        "x-permission": "hostedSites:manage",
        "summary": "Deploy a custom app build from one archive of its built directory",
        "description": "Unpacks a zip or tar.gz of the built directory server-side, validates it (file count, total and single-file size, paths; links and `..` refused), stores the files and, unless `activate` is false, makes the deployment live. One request does what the manifest, upload and activate operations do in three, for a client with no file uploads of its own; the MCP tool `deploy_site` calls it. Files the site already holds (by SHA-256) are reused. Authoring guide for site authors: the MCP tool `get_hosted_site_authoring_guide` (sign-in, the `/_api` proxy, sessions, what a site may call, deploying), also published as the Custom apps guide on tessule.com.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeployHostedSiteArchiveRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The deployment, `active` (or `ready` when `activate` was false)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HostedSiteDeployment"
                }
              }
            }
          },
          "400": {
            "description": "The archive cannot be deployed: it is not a readable archive of the stated format, is over the archive, file-count, total or single-file size limits, holds a link, an absolute or `..` path, a path the site could not serve, or no `/index.html`; the source archive is unreadable or holds a link, an absolute or `..` path; or the build and its source together are over 2.5 MB (code `INVALID_ARCHIVE`); or the cache rules are invalid (code `INVALID_MANIFEST`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "This workspace has no hosted site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A stored file could not be verified after upload (code `DEPLOYMENT_INCOMPLETE`). The deployment is discarded, with the files it stored, so it does not count against the unfinished-upload cap; send the archive again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Hosted sites are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/hosted-site/deployments/{deploymentId}/activate": {
      "post": {
        "operationId": "hostedSiteDeploymentsDeploymentIdActivatePost",
        "x-permission": "hostedSites:manage",
        "summary": "Make a deployment the one the hosted site serves (deploy or roll back the custom app)",
        "description": "Links every content-addressed file the site holds into the deployment, checks that every file is present at its declared size (on first activation, and again on a rollback), then switches the site to it; the edge serves it within seconds. Activating an earlier deployment is a rollback. Authoring guide for site authors: the MCP tool `get_hosted_site_authoring_guide` (sign-in, the `/_api` proxy, sessions, what a site may call, deploying), also published as the Custom apps guide on tessule.com.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "deploymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The deployment, now active",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HostedSiteDeployment"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such deployment for this workspace's site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Some files have not been uploaded (the message names them)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Hosted sites are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/hosted-site/deployments/{deploymentId}/files": {
      "get": {
        "operationId": "hostedSiteDeploymentsDeploymentIdFilesGet",
        "x-permission": "hostedSites:manage",
        "summary": "Download a custom app deployment's files, and the source it was deployed with",
        "description": "Reads a deployment back: every file it serves, with a short-lived download URL each, the whole build as one zip inline when it is small enough, and the source archive the deployment was made with when its deployer sent one. This is how a site that exists only on the platform (built and deployed from a conversation, with no repository behind it) is retrieved to be changed and deployed again. The MCP tool `download_site` calls it. A deployment still `uploading` has no complete file set to read. Authoring guide for site authors: the MCP tool `get_hosted_site_authoring_guide` (sign-in, the `/_api` proxy, sessions, what a site may call, deploying), also published as the Custom apps guide on tessule.com.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "deploymentId",
            "in": "path",
            "required": true,
            "description": "The deployment to read, as the deployment list gives it.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The deployment's files, its build as a zip when it fits, and its source when held",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HostedSiteDeploymentFiles"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such deployment for this workspace's site, or the workspace has no hosted site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The deployment is still `uploading`, or a file it declares is no longer stored (code `DEPLOYMENT_INCOMPLETE`); read a `ready` or `active` deployment instead",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Hosted sites are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/hosted-site/domains": {
      "get": {
        "operationId": "hostedSiteDomainsGet",
        "x-permission": "hostedSites:manage",
        "summary": "List the hostnames of the workspace's own that its hosted site answers on",
        "description": "Every custom domain attached to the site that has not been removed, each with its status, the CNAME record to create and the last check's detail (docs/CUSTOM_DOMAINS.md). A hostname removed earlier is not listed; it stays reserved to the workspace and can be added again. Site authors read the MCP tool `get_hosted_site_authoring_guide` for what a custom domain changes for a site (nothing: the API stays at `/_api`).",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The site's custom domains, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/HostedSiteDomain"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "This workspace has no hosted site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Custom domains are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "hostedSiteDomainsPost",
        "x-permission": "hostedSites:manage",
        "summary": "Attach a hostname of the workspace's own to its hosted site",
        "description": "Reserves the hostname to the workspace and starts serving the site on it: the answer carries the one CNAME record to create at the DNS provider, and the hostname moves from `pending` to `active` on its own once the record resolves and the certificate is issued (`GET /hosted-site/domains` shows progress). The site's other addresses then redirect to it. The workspace's plan sets how many hostnames the site may have (`hostedSites.customDomains`). The MCP tool `get_hosted_site_authoring_guide` describes the site's addresses.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HostedSiteDomainRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The hostname, reserved and pending",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HostedSiteDomain"
                }
              }
            }
          },
          "400": {
            "description": "The hostname cannot be a custom domain (code `INVALID_HOSTNAME`; the message says why: not a hostname, a bare domain, a Tessule domain)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not permitted, or the site already has as many hostnames as the workspace's plan allows (code `LIMIT_EXCEEDED`; the message names the allowance)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "This workspace has no hosted site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The hostname is held by another workspace (code `HOSTNAME_TAKEN`; a hostname that never served is held for seven days from when it was added, one that once served until an operator releases it), or is already attached to this site (code `HOSTNAME_ATTACHED`; remove it first).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Custom domains are not configured on this deployment (code `CUSTOM_DOMAINS_NOT_CONFIGURED`), or the hostname's previous setup is still being released and the request can be retried in a few minutes (code `HOSTNAME_RELEASING`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/hosted-site/domains/{domainId}": {
      "delete": {
        "operationId": "hostedSiteDomainsDomainIdDelete",
        "x-permission": "hostedSites:manage",
        "summary": "Stop serving the hosted site on one of its custom domains",
        "description": "The site stops answering on the hostname within seconds and its other addresses stop redirecting to it; the certificate is released. The hostname stays reserved to this workspace, so it can be added again later and no other organization can take it over while a stale CNAME still points at Tessule. The MCP tool `get_hosted_site_authoring_guide` describes the site's addresses.",
        "tags": [
          "Hosted Sites"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "domainId",
            "in": "path",
            "required": true,
            "description": "The hostname's `id` from `GET /hosted-site/domains`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The hostname is no longer served"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such hostname on this workspace's site",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Custom domains are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/published-pages": {
      "get": {
        "operationId": "publishedPagesGet",
        "x-permission": "pages:read",
        "summary": "List the published pages the caller can open",
        "description": "The workspace's catalog of published pages: every page shared with the workspace, plus the caller's own drafts. Each carries its title, description, publisher and dates.",
        "tags": [
          "Published Pages"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Only pages whose title or description contains this text (case-insensitive).",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "mine",
            "in": "query",
            "required": false,
            "description": "Only pages the caller published.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The catalog",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishedPageCatalog"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "publishedPagesPost",
        "x-permission": "pages:publish",
        "summary": "Publish a page",
        "description": "Stores one self-contained HTML document as a new page and answers with its shareable link. Audience defaults to `workspace`.",
        "tags": [
          "Published Pages"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePublishedPageRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The page, published",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishedPage"
                }
              }
            }
          },
          "400": {
            "description": "Over the workspace's page, size or storage limit (the message says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The organization has not switched published pages on, or the caller lacks the permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Published pages are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/published-pages/{pageId}": {
      "get": {
        "operationId": "publishedPagesPageIdGet",
        "x-permission": "pages:read",
        "summary": "Open a published page",
        "description": "The page's details and a short-lived signed URL for its content. The caller must be in the page's audience.",
        "tags": [
          "Published Pages"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "pageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The page, with its content URL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishedPageView"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The organization has not switched published pages on, or the caller lacks the permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such page, or not one the caller can open",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Published pages are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "publishedPagesPageIdPatch",
        "x-permission": "pages:publish",
        "summary": "Change a page's title, description or audience",
        "description": "Allowed to the page's publisher and to holders of `pages:manage`.",
        "tags": [
          "Published Pages"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "pageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePublishedPageRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The page, changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishedPage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The organization has not switched published pages on, or the caller lacks the permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such page, or not one the caller can change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Published pages are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "publishedPagesPageIdDelete",
        "x-permission": "pages:publish",
        "summary": "Delete a page and every version of it",
        "description": "Allowed to the page's publisher and to holders of `pages:manage`. The link stops working at once.",
        "tags": [
          "Published Pages"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "pageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Page deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The organization has not switched published pages on, or the caller lacks the permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such page, or not one the caller can delete",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Published pages are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/published-pages/{pageId}/versions": {
      "get": {
        "operationId": "publishedPagesPageIdVersionsGet",
        "x-permission": "pages:publish",
        "summary": "List a page's versions, newest first",
        "description": "Allowed to the page's publisher and to holders of `pages:manage`.",
        "tags": [
          "Published Pages"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "pageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The page's versions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublishedPageVersion"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The organization has not switched published pages on, or the caller lacks the permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such page, or not one the caller can change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Published pages are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "publishedPagesPageIdVersionsPost",
        "x-permission": "pages:publish",
        "summary": "Publish a new version of a page",
        "description": "Stores new HTML for the page and makes it the version the link serves, keeping the link. Allowed to the page's publisher and to holders of `pages:manage`. The newest few versions are kept; older ones are removed.",
        "tags": [
          "Published Pages"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "pageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePublishedPageVersionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The page, now serving the new version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishedPage"
                }
              }
            }
          },
          "400": {
            "description": "Over the workspace's size or storage limit (the message says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The organization has not switched published pages on, or the caller lacks the permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such page, or not one the caller can change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Published pages are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/published-pages/{pageId}/versions/{versionId}/make-current": {
      "post": {
        "operationId": "publishedPagesPageIdVersionsVersionIdMakeCurrentPost",
        "x-permission": "pages:publish",
        "summary": "Make an earlier version the one the page serves",
        "description": "A rollback. Allowed to the page's publisher and to holders of `pages:manage`.",
        "tags": [
          "Published Pages"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "pageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "versionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The page, now serving that version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishedPage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The organization has not switched published pages on, or the caller lacks the permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "No such page or version, or not one the caller can change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "Published pages are not configured on this deployment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/workspace": {
      "get": {
        "operationId": "workspaceGet",
        "x-permission": "tables:read",
        "summary": "The current workspace",
        "description": "The workspace the caller's token is bound to — its id, name and environment. An agent reads this to learn whether the workspace is a sandbox (whose record writes accept `occurredAt` and whose stage history may be seeded) before planning demo data.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The current workspace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceInfo"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/sandbox/shift-dates": {
      "post": {
        "operationId": "workspaceSandboxShiftDatesPost",
        "x-permission": "schema:apply",
        "summary": "Shift every date in the workspace by a number of days (sandbox workspaces only)",
        "description": "Move a demo workspace's clock. Every `date` and `datetime` field of every table, each record's `created_at`/`updated_at` (and `deleted_at`), and the `created_at` of every stage transition are moved by the same number of days, in one transaction, so relative- time content (\"arrivals in the next 7 days\", \"month-to-date\") stays live as real time passes. Give the shift as `days`, or let the server work it out from an anchor: `anchorField` (`table.field`, or `table.created_at`) is the field whose LATEST value should land on `anchorTo` (today, in the workspace time zone, when omitted). With `alignWeeks` (the default for an anchor) the computed shift is rounded to whole weeks, so a Friday stays a Friday and a weekly rota keeps its shape; an explicit `days` is taken as given (a 400 if `alignWeeks` is set and it is not a multiple of 7). `excludeFields` names the dates that must stay fixed — start dates, purchase dates, founding dates. Formula fields are never written (they recompute); `time` fields, comments and the audit log are not moved. Unique and no-overlap constraints hold throughout: rows move together, so their relative positions are unchanged. `dryRun` returns the computed shift and the tables, fields and row counts it would touch without writing. Stage values are the residual: a shifted \"confirmed\" booking now in the past is still \"confirmed\", so shift first, then fix statuses with an ordinary bulk update. Refused on a production workspace (400 `SANDBOX_ONLY`).",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SandboxDateShiftRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The shift applied (or, for a dry run, the shift that would be)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SandboxDateShiftResult"
                }
              }
            }
          },
          "400": {
            "description": "Not a sandbox (`SANDBOX_ONLY`); neither or both of `days` and `anchorField`; an anchor or excluded field that is not a date field of an active table, or an anchor with no value to land (`DATE_SHIFT_INVALID`, `DATE_SHIFT_ANCHOR_EMPTY`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/settings": {
      "get": {
        "operationId": "workspaceSettingsGet",
        "x-permission": "customization:read",
        "summary": "Get the current workspace's UI settings (branding)",
        "description": "Returns the workspace's configured branding. Always 200 — a workspace with nothing configured returns empty branding (the stock look).",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current workspace settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceSettings"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "workspaceSettingsPut",
        "x-permission": "customization:manage",
        "summary": "Replace the current workspace's UI settings (branding)",
        "description": "Full replace — omitted fields are cleared back to defaults. logoKey must be a key issued by POST /workspace/settings/logo for this workspace.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWorkspaceSettingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated workspace settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceSettings"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (bad colour or foreign logo key)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/address": {
      "put": {
        "operationId": "workspaceAddressPut",
        "x-permission": "customization:manage",
        "summary": "Claim an address for the workspace's own origin",
        "description": "Gives the current workspace a chosen address, so it opens on its own origin (`https://<address>.app.tessule.com`) as well as on the app's — useful for staying signed in to several workspaces, as different users, on one device, or for installing one workspace as its own app. The address also names the workspace's hosted site (`https://<address>.tessule.dev`); its earlier address and its id redirect there. Addresses are unique across the platform; the workspace's previous address, and every one it held before, stays reserved to it and may be claimed back; a workspace holds at most 10 addresses in all. Claiming the address the workspace already holds is a no-op. A workspace can always be opened under its id without an address.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkspaceAddressRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The address the workspace now holds",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceAddress"
                }
              }
            }
          },
          "400": {
            "description": "Not a valid address (`WORKSPACE_ADDRESS_INVALID`: wrong shape or length, or shaped like a workspace id), a reserved name (`WORKSPACE_ADDRESS_RESERVED`), or a new address for a workspace that has already held the most it may (`WORKSPACE_ADDRESS_LIMIT`: 10, current and earlier together, since every one stays reserved to it; one it held before can still be claimed back).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "Another workspace holds the address; the body suggests a free one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceAddressTakenResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "workspaceAddressDelete",
        "x-permission": "customization:manage",
        "summary": "Give up the workspace's address",
        "description": "Stops the workspace answering on its chosen address. The address stays reserved to this workspace (it may claim it back later); the workspace still opens on the app's origin and on its id-labelled origin. A workspace with no address gets 204 as well.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "The workspace has no address"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/settings/logo": {
      "post": {
        "operationId": "workspaceSettingsLogoPost",
        "x-permission": "customization:manage",
        "summary": "Start a workspace logo upload",
        "description": "Returns a presigned single-PUT upload for the workspace logo (png/jpeg/webp, max 1 MB). After uploading, pass the returned s3Key as logoKey in PUT /workspace/settings.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkspaceLogoUploadRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Presigned upload created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceLogoUpload"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request (type or size not allowed)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/homepage": {
      "get": {
        "operationId": "workspaceHomepageGet",
        "x-permission": "customization:read",
        "summary": "Get the home page this caller lands on",
        "description": "With no parameters, returns the home page RESOLVED for the caller: their own document if one existed, else their active group's, else the workspace's (see `CustomizationTargetScope`). `ownerScope` on the response names which one answered.\n\nAlways 200 — a workspace with nothing configured returns `configured: false` and an empty tile list, and the client renders its built-in default rather than an error. A role lacking customization:read degrades the same way (403 → default).\n\nPassing `ownerScope` addresses ONE document instead of resolving, which is what the editor does: `ownerScope=workspace` for the page everyone inherits, `ownerScope=group` with `ownerGroupId` for a group's own. `configured: false` then means that group has no page of its own and inherits.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ownerScope",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/CustomizationTargetScope"
            },
            "description": "Address one document rather than resolving for the caller."
          },
          {
            "name": "ownerGroupId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "Required with `ownerScope=group`."
          },
          {
            "name": "viewAsGroupId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "Resolve as a member of this group would see it (M8.6b \"View as\"), instead of for the caller's own active group. Needs `customization:manage`, and the group must be an active group of this workspace; membership is not required, matching the rule for WRITING a group's document.\n\nDistinct from `ownerScope`/`ownerGroupId` above, which ADDRESS one stored document and report `configured: false` when that audience has none. This RESOLVES: the group's document if it has one, the workspace's otherwise — what a member actually sees. The caller's own `user`-tier document is deliberately left out of that resolution, since it is not something the group would ever see.\n\nPresentation only. It changes which customization document is returned and nothing else: no permission, no row or field visibility, and no write is affected by it, exactly as the caller's own active group is never an authorization input. The app shows a banner while it is in force so it cannot be mistaken for acting as that group."
          }
        ],
        "responses": {
          "200": {
            "description": "The resolved (or addressed) home page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Homepage"
                }
              }
            }
          },
          "400": {
            "description": "ownerScope=group without a valid ownerGroupId",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "workspaceHomepagePut",
        "x-permission": "customization:manage",
        "summary": "Replace a home page",
        "description": "Full replace of the tile list. Tiles are validated on write (unknown tile kinds and malformed per-kind config are rejected) and stamped with a schema version so the stored shape can be migrated on read later. A `page` quick link must name a published page of this workspace, and a `hostedSite` link's `path` must be site-relative; either way the link is refused with 400.\n\nThe body is the config itself (`{ tiles, … }`) or, additively, the wrapped `{ config: { tiles, … } }` shape `GET /workspace/homepage` returns, so a read-modify-write can send the answer straight back; the wrapper's other fields are ignored.\n\nWrites the workspace's own page unless `ownerScope: group` targets a group's, which is an independent document — replacing one never touches the other, and a member of no targeted group keeps seeing the workspace's.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateHomepageRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated home page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Homepage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid tile configuration, or an unusable group target",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "workspaceHomepageDelete",
        "x-permission": "customization:manage",
        "summary": "Discard a home page",
        "description": "Discards the workspace's page (reverting to the client's built-in default), or a group's when `ownerScope=group` is given — after which that group inherits whatever the workspace has. Idempotent — 204 whether or not a configuration existed.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ownerScope",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/CustomizationTargetScope"
            },
            "description": "Which document to discard. Defaults to `workspace`."
          },
          {
            "name": "ownerGroupId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "Required with `ownerScope=group`."
          }
        ],
        "responses": {
          "204": {
            "description": "Configuration discarded"
          },
          "400": {
            "description": "ownerScope=group without a valid ownerGroupId",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/homepage/mine": {
      "put": {
        "operationId": "workspaceHomepageMinePut",
        "x-permission": "customization:read",
        "summary": "Replace my own home page",
        "description": "Writes the caller's PERSONAL home page — the tier above their group's, so from now on this is what they land on. Takes the same body as `PUT /workspace/homepage` minus the targeting: the bare tile list, or the wrapped `{ config }` shape the GET returns.\n\nA separate path rather than an `ownerScope` on the shared write, because the two are different acts with different rules. Arranging your own page is an ordinary end-user act and needs only `customization:read`; writing the page a team or the whole workspace inherits is configuration and needs `customization:manage`. Keeping them apart means this endpoint has no way to name a shared document even by mistake — the owner is the authenticated caller, full stop.\n\nThere is deliberately no way to write ANOTHER user's personal page. Composing for an audience is what the group tier is for.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMyHomepageRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated personal home page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Homepage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid tile configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "workspaceHomepageMineDelete",
        "x-permission": "customization:read",
        "summary": "Discard my own home page",
        "description": "\"Reset to my team's\": discards the caller's personal page, after which they resolve to their active group's page, or the workspace's. Touches no shared document and nobody else's. Idempotent — 204 whether or not a personal page existed.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "Personal home page discarded"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/homepage/targets": {
      "get": {
        "operationId": "workspaceHomepageTargetsGet",
        "x-permission": "customization:manage",
        "summary": "Which home pages exist, and which groups can be targeted",
        "description": "The editor's target picker: the documents already configured (so an admin can tell a group with its own page from one that inherits) and the groups available to target. Manage-gated because it is the composition surface, not the reading one.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Configured home pages and targetable groups",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomizationTargets"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/navigation": {
      "get": {
        "operationId": "workspaceNavigationGet",
        "x-permission": "customization:read",
        "summary": "Get the navigation this caller sees",
        "description": "The main-navigation document RESOLVED for the caller — their active group's if one exists, else the workspace's — or, with `ownerScope`, ONE addressed document for the editor. Always 200: nothing configured (or a role lacking customization:read, which 403s and degrades the same way) means the client renders its built-in navigation. Same resolution and addressing rules as `/workspace/homepage`.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ownerScope",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/CustomizationTargetScope"
            },
            "description": "Address one document rather than resolving for the caller."
          },
          {
            "name": "ownerGroupId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "Required with `ownerScope=group`."
          },
          {
            "name": "viewAsGroupId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "Resolve as a member of this group would see it (M8.6b \"View as\"), instead of for the caller's own active group. Needs `customization:manage`, and the group must be an active group of this workspace; membership is not required, matching the rule for WRITING a group's document.\n\nDistinct from `ownerScope`/`ownerGroupId` above, which ADDRESS one stored document and report `configured: false` when that audience has none. This RESOLVES: the group's document if it has one, the workspace's otherwise — what a member actually sees. The caller's own `user`-tier document is deliberately left out of that resolution, since it is not something the group would ever see.\n\nPresentation only. It changes which customization document is returned and nothing else: no permission, no row or field visibility, and no write is affected by it, exactly as the caller's own active group is never an authorization input. The app shows a banner while it is in force so it cannot be mistaken for acting as that group."
          }
        ],
        "responses": {
          "200": {
            "description": "The resolved (or addressed) navigation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Navigation"
                }
              }
            }
          },
          "400": {
            "description": "ownerScope=group without a valid ownerGroupId",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "workspaceNavigationPut",
        "x-permission": "customization:manage",
        "summary": "Replace a navigation",
        "description": "Full replace of the item list. Items are validated on write (a target kind this build does not know, or one missing the id its kind needs, is rejected) and stamped with a schema version. Writes the workspace's navigation unless `ownerScope: group` targets a group's, which is an independent document.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateNavigationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated navigation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Navigation"
                }
              }
            }
          },
          "400": {
            "description": "Invalid item configuration, or an unusable group target",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "workspaceNavigationDelete",
        "x-permission": "customization:manage",
        "summary": "Discard a navigation",
        "description": "Discards the workspace's navigation (reverting to the built-in one), or a group's when `ownerScope=group` is given — after which that group inherits whatever the workspace has. Idempotent.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ownerScope",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/CustomizationTargetScope"
            },
            "description": "Which document to discard. Defaults to `workspace`."
          },
          {
            "name": "ownerGroupId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 12,
              "pattern": "^[0-9a-f]{12}$"
            },
            "description": "Required with `ownerScope=group`."
          }
        ],
        "responses": {
          "204": {
            "description": "Configuration discarded"
          },
          "400": {
            "description": "ownerScope=group without a valid ownerGroupId",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/navigation/targets": {
      "get": {
        "operationId": "workspaceNavigationTargetsGet",
        "x-permission": "customization:manage",
        "summary": "Which navigations exist, and which groups can be targeted",
        "description": "The editor's target picker for the navigation surface — the same shape and gate as `/workspace/homepage/targets`.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Configured navigations and targetable groups",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomizationTargets"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/openapi": {
      "get": {
        "operationId": "workspaceOpenApiGet",
        "x-permission": "tables:read",
        "summary": "Get the workspace OpenAPI specification document",
        "description": "Returns the OpenAPI 3.1 document the API validates this workspace's requests against: every table as typed REST endpoints, with the schema of each table's items derived from its fields, plus (by default) every workspace-wide resource — dashboards, flows, saved queries, members and the rest. It is the codegen input for typed clients, so a build can generate its types from it (openapi-typescript, or the Tessule CLI's pull command) instead of re-describing the API by hand. Use the complete document, as a file: it is large (a megabyte or more, most of it the workspace-wide resources), so fetch it over HTTP into a file with a bearer token, from a hosted site's own pages, or through the MCP tool get_openapi_document, which answers with a short-lived download URL for exactly this document rather than its text; an MCP tool result is cut at its size budget and a document assembled from pieces is more likely to arrive malformed than one fetched whole. `scope=tables` leaves the workspace-wide resources out; it remains available, but the complete document is the recommended input. `audience=site` is the document as a hosted site calls the API: only the operations a site's `/_api` proxy forwards, with paths relative to `/_api`. The platform specification alone, without any workspace's tables, is public at `/api/openapi/v1/openapi.json`. Its info.version ends in a digest of the document served, which changes whenever the schema does. Without a credential the answer is 401 with code `AUTHENTICATION_REQUIRED` and a `WWW-Authenticate: Bearer` challenge, distinct from the 404 an unknown path gets.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/WorkspaceOpenApiScope"
            },
            "description": "`full` (the default) is the whole workspace API: this workspace's tables plus every workspace-wide resource. `tables` is the workspace-specific part alone — the per-table schemas and record endpoints, and the system-entity schemas they reference. The complete document is the recommended codegen input; `tables` is for a client that deliberately wants only the records surface, or a tool that cannot take a file. `table` is one table's operations alone, with the schemas they use (the records it refers to among them): the smallest form, for a tool working on one table. It needs `table`."
          },
          {
            "name": "audience",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/WorkspaceOpenApiAudience"
            },
            "description": "`api` (the default) is the document as a client of the API host reads it: paths carry the `/api` prefix and `servers` names the API base URL. `site` is the document as a hosted site's pages call the API: only the operations the site's `/_api` proxy forwards (the exclusions the hosted-site authoring guide lists are left out), paths relative to `/_api` with the `/api` prefix removed, `servers` set to `/_api`, and no bearer security (the site session is the credential). `tessule pull --audience site` fetches it."
          },
          {
            "name": "table",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 63
            },
            "description": "The table a scope `table` document covers, by its id or its name. Required with scope `table` and refused with any other scope (400); a name or id no table of the workspace holds is 404."
          }
        ],
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 document for this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/openapi/documents": {
      "get": {
        "operationId": "workspaceOpenApiDocumentsGet",
        "x-permission": "tables:read",
        "summary": "List the workspace's OpenAPI documents",
        "description": "Every form of this workspace's OpenAPI document — one per audience and scope — with its current version, revision digest and size in bytes, without the documents themselves. What the MCP server lists as resources, and what a build checks before deciding whether to fetch the document again: the version changes whenever the document does.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The workspace's OpenAPI documents, described.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceOpenApiDocumentList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/openapi/download-links": {
      "post": {
        "operationId": "workspaceOpenApiDownloadLinksPost",
        "x-permission": "tables:read",
        "x-replica-reads": true,
        "summary": "Create a short-lived download link for the workspace OpenAPI document",
        "description": "Answers a URL from which this workspace's OpenAPI document can be fetched as a file with no credential header — by curl, a build step or a code generator — plus the document's version, revision digest and size, never the document itself. This is what the MCP tool get_openapi_document returns. The link is valid for ten minutes, is bound to this workspace and to the caller's own access (the download re-checks that the caller is still a member who may read the schema, under the same API token or OAuth grant the link was created with), can be fetched more than once within its lifetime, and reaches this one document and nothing else. Nothing is stored: the link is a signed token. A principal whose access is a session the link could not re-check — a hosted site's session, an administrator's assumed session, an install job — cannot create one (403, code `DOWNLOAD_LINK_NOT_AVAILABLE`, or `SITE_ROUTE_NOT_EXPOSED` from a site); it fetches `GET /workspace/openapi` directly.",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkspaceOpenApiDownloadLinkRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The download link, with the document it reaches described.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceOpenApiDownloadLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/sdk/download-links": {
      "post": {
        "operationId": "workspaceSdkDownloadLinksPost",
        "x-permission": "tables:read",
        "x-replica-reads": true,
        "summary": "Create a short-lived download link for the workspace's generated client archive",
        "description": "Answers a URL from which this workspace's typed client can be downloaded as one archive, with no package registry and no credential header: the zero-dependency `@tessule/client` build plus the workspace's OpenAPI types and per-table accessor module (`createWorkspace`), exactly what `tessule pull` writes, generated from the workspace's current OpenAPI document for the chosen audience. This is what the MCP tool get_workspace_sdk returns. The answer states the archive's version (the document's, with its `+ws.<revision>`), the client build inside it, and the archive's SHA-256 and size, so a caller verifies the download before unpacking it. The link is valid for ten minutes, can be fetched more than once within it, and reaches this one archive and nothing else; it carries nothing the caller cannot already read through `GET /workspace/openapi`. Archives are made once per workspace schema revision, audience and client build, so a repeat call only signs a new link. Who may create one is who may create an OpenAPI document download link: a hosted site's session, an administrator's assumed session or an install job cannot (403, code `DOWNLOAD_LINK_NOT_AVAILABLE`, or `SITE_ROUTE_NOT_EXPOSED` from a site).",
        "tags": [
          "Workspace"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkspaceSdkDownloadLinkRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The download link, with the archive it reaches described.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceSdkDownloadLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/workspace/openapi/file": {
      "get": {
        "operationId": "workspaceOpenApiFileGet",
        "summary": "Download the workspace OpenAPI document with a download link",
        "description": "The target of a link from `POST /workspace/openapi/download-links`: the workspace's OpenAPI document as a JSON file, served with `Content-Disposition: attachment` and no caching. The `token` query parameter is the credential; no header is needed. The token names the workspace, the audience and scope, and the caller it was created for, and the answer is refused (403, code `DOWNLOAD_LINK_INVALID`) once it has expired, if it was not signed by this server, or if that caller may no longer read the workspace's schema.",
        "tags": [
          "Workspace"
        ],
        "security": [],
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The signed download token from the link's URL, as the link carries it."
          }
        ],
        "responses": {
          "200": {
            "description": "The workspace's OpenAPI document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "An OpenAPI 3.1 document (`openapi`, `info`, `servers`, `paths`, `components`).",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "description": "The link is not usable: expired, not signed by this server, or its caller may no longer read this workspace's schema. Create a new link. `code` is `DOWNLOAD_LINK_INVALID`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "The workspace is briefly unavailable for maintenance. The link is still good: retry the same link shortly. `code` is `WORKSPACE_MAINTENANCE`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/calendar-feeds": {
      "get": {
        "operationId": "calendarFeedsGet",
        "x-permission": "records:read",
        "summary": "List your calendar feeds",
        "description": "The caller's own calendar feeds in this workspace, newest first, each with whether it currently reads (`problem`). Never the feeds' addresses.",
        "tags": [
          "Calendar feeds"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The caller's calendar feeds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CalendarFeed"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "calendarFeedsPost",
        "x-permission": "records:read",
        "summary": "Create a calendar feed",
        "description": "Publish a table's or SQL view's rows as a calendar a calendar app can subscribe to. The feed reads as the caller, so it can only ever show what the caller can see, and its address is returned once.\n\nOnly a member signed in as themselves may create one: a request made with an API token, an OAuth or agent grant, a hosted site's session or an administrator's assumed session is refused with 403 `CALENDAR_FEED_PERSON_ONLY`, because the feed outlives that credential and reads with the member's full access. Where the organization has switched calendar feeds off (`OrganizationFeatures.calendarFeedsEnabled`) it is 403 `CALENDAR_FEEDS_DISABLED`. A field the source names that does not exist, is not readable by the caller or has the wrong type is a 400.",
        "tags": [
          "Calendar feeds"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CalendarFeedCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The feed and its address, shown this once.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarFeedLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/calendar-feeds/{feedId}": {
      "delete": {
        "operationId": "calendarFeedsFeedIdDelete",
        "x-permission": "records:read",
        "summary": "Delete a calendar feed",
        "description": "Delete one of the caller's feeds. Its address stops working at once; calendars subscribed to it keep the events they last fetched until the subscription is removed there.",
        "tags": [
          "Calendar feeds"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "feedId",
            "in": "path",
            "required": true,
            "description": "The feed to delete.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The feed was deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/calendar-feeds/{feedId}/reset-link": {
      "post": {
        "operationId": "calendarFeedsFeedIdResetLinkPost",
        "x-permission": "records:read",
        "summary": "Reset a calendar feed's address",
        "description": "Issue a new address for one of the caller's feeds and retire the old one, for an address that was shared too widely. Calendars subscribed to the old address stop updating. Refused with 403 `CALENDAR_FEED_PERSON_ONLY` for the same callers creation refuses, and with 403 `CALENDAR_FEEDS_DISABLED` while the organization has calendar feeds switched off.",
        "tags": [
          "Calendar feeds"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "feedId",
            "in": "path",
            "required": true,
            "description": "The feed whose address to reset.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The feed and its new address, shown this once.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarFeedLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/feeds/calendar/{feedId}/{token}/feed.ics": {
      "get": {
        "operationId": "feedsCalendarFeedIdTokenFeedIcsGet",
        "summary": "Fetch a calendar feed",
        "description": "The address a calendar app subscribes to: the feed's events as an iCalendar (RFC 5545) document. The token in the path is the credential; no header is needed. Every mismatch (an unknown feed, a wrong or retired token, an owner who has left the workspace) is the same 404, as is every address while the organization has calendar feeds switched off. The events are read with the owner's permissions as they are at the moment of the fetch. `ETag` and `If-None-Match` are honoured, so an unchanged calendar costs a 304.",
        "tags": [
          "Calendar feeds"
        ],
        "security": [],
        "parameters": [
          {
            "name": "feedId",
            "in": "path",
            "required": true,
            "description": "The feed.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "token",
            "in": "path",
            "required": true,
            "description": "The feed's secret token, as its address carries it.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The calendar.",
            "content": {
              "text/calendar": {
                "schema": {
                  "type": "string",
                  "description": "The iCalendar document (UTF-8, CRLF line endings)."
                }
              }
            }
          },
          "304": {
            "description": "The calendar is unchanged since the `ETag` the request named."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "The workspace is briefly unavailable for maintenance. The address is still good; calendar apps retry on their own schedule.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api-tokens/{tokenId}": {
      "delete": {
        "operationId": "apiTokensTokenIdDelete",
        "x-permission": "tokens:manage",
        "summary": "Revoke an API token",
        "tags": [
          "API Tokens"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tokenId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Token revoked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Token not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/oauth/authorize/info": {
      "get": {
        "operationId": "oauthAuthorizeInfo",
        "summary": "Get OAuth authorization details for the consent screen",
        "description": "Returns details about a pending OAuth authorization request so the frontend\ncan render a consent screen. Requires the user to be authenticated.\n",
        "tags": [
          "OAuth"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": true,
            "description": "The oauth_state token from the /authorize redirect",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authorization details for consent screen",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthAuthorizeInfo"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or expired state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Not authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/schema-assistant/status": {
      "get": {
        "operationId": "schemaAssistantStatusGet",
        "summary": "Whether the AI schema assistant is available",
        "tags": [
          "Schema Assistant"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Feature availability",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "enabled"
                  ],
                  "properties": {
                    "enabled": {
                      "type": "boolean",
                      "description": "True when an API key is configured and the assistant can be used."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/dashboard-assistant/status": {
      "get": {
        "operationId": "dashboardAssistantStatusGet",
        "summary": "Whether the AI dashboard assistant is available",
        "tags": [
          "Dashboard Assistant"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Feature availability",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "enabled"
                  ],
                  "properties": {
                    "enabled": {
                      "type": "boolean",
                      "description": "True when an API key is configured and the assistant can be used."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/query-assistant/status": {
      "get": {
        "operationId": "queryAssistantStatusGet",
        "summary": "Whether the AI query assistant is available",
        "tags": [
          "Query Assistant"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Feature availability",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "enabled"
                  ],
                  "properties": {
                    "enabled": {
                      "type": "boolean",
                      "description": "True when an API key is configured and the assistant can be used."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/captures/status": {
      "get": {
        "operationId": "capturesStatusGet",
        "summary": "Whether capture-from-image (photograph a business card into a record) is available",
        "description": "Feature-availability probe for our own UI. True when a model API key is configured; the per-organization AI token budget and the daily capture quota are enforced on the extract call itself.\n",
        "tags": [
          "Capture"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Feature availability",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "enabled"
                  ],
                  "properties": {
                    "enabled": {
                      "type": "boolean",
                      "description": "True when an API key is configured and images can be read."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/captures/extract": {
      "post": {
        "operationId": "capturesExtractPost",
        "x-permission": "records:create",
        "x-rate-limit": {
          "measure": "capture.extractions"
        },
        "summary": "Read a photographed business card, leaflet or sign, or the pages of a PDF, into a record proposal",
        "description": "Sends one image — or the selected pages of one PDF document — to the\nvision model together with the target table's field catalogue (names,\nlabels, types, picklist options) and returns a **proposal**: candidate\nvalues per field with confidence and the source text each came from,\ntext that could be read but not placed, and existing records in the\ntable that match an extracted email, phone number or name. Nothing is\nwritten — the client shows the proposal in the create form and the\nuser confirms it with the ordinary `POST /tables/{tableId}/items`.\n\nThe source is either `image` (inline, a photograph or a PDF of at most\n2.5MB) or `attachment` (a file already held by an attachment field of\na record in the table, read in place — a PDF of up to 20MB); exactly\none of the two. For a PDF, `pages` picks up to five pages, extracted\nserver-side and sent as one document, so a capture always yields one\nproposal; the proposal's `document` says how many pages the file has\nand which were read.\n\nValues are coerced into each field's wire shape and validated against\nthe field's own rules before they are returned; picklist values are\nmatched to existing options only, and a reference field is proposed\nonly when the printed name resolves to exactly one record in the\nreferenced table (under the caller's own read scope). Attachment,\nformula, lookup, rollup, autonumber and geolocation fields are never\nproposed.\n\nCost controls: every call is metered to the organization's AI usage\nledger (feature `capture_from_image`); a call is refused with 429\n`AI_BUDGET_EXCEEDED` when the organization is over its monthly token\nbudget, and the workspace's daily capture quota applies on top.\n",
        "tags": [
          "Capture"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CaptureExtractRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The proposal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaptureProposal"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request: no source or both sources; an image that is not base64, empty or over the size cap (`CAPTURE_INVALID_IMAGE`); a PDF that cannot be read, is encrypted, or whose requested page lies beyond its page count (`CAPTURE_INVALID_DOCUMENT`); an attachment of a type capture does not read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Table not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "The organization's AI token budget or the workspace's daily capture quota is exhausted (`code` says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "The model did not return a usable reading (`code` CAPTURE_MODEL_FAILED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Capture is not enabled on this deployment (`code` CAPTURE_DISABLED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "tags": []
}