{
  "openapi": "3.0.3",
  "info": {
    "title": "Buildora API",
    "version": "1.0.0",
    "description": "The Buildora REST API lets a workspace automate what it can already do from the dashboard: manage websites, leads, forms, blog content, media, business-module data, comments and outbound webhooks.\n\n## Authentication\n\nEvery request (except the docs spec itself) requires a personal API token as a Bearer credential:\n\n```\nAuthorization: Bearer <token>\n```\n\nCreate a token from **Settings → Account → API tokens** (or via `POST /account/api-tokens` using an existing session or token). A token has the same access as the user who created it and is shown in full only once, at creation time. Revoke a compromised token with `DELETE /account/api-tokens/{id}`.\n\n## Workspace context\n\nAlmost every endpoint operates on data scoped to a single workspace. Buildora resolves which workspace a request applies to in this order:\n\n1. The `X-Workspace-Id` request header, if present.\n2. The `?workspace=` query parameter, if present.\n3. The user's last-active workspace.\n4. The user's first workspace, as a fallback.\n\nIf the resolved workspace exists but the token owner is not a member of it, the API responds `403`. Scripts that talk to more than one workspace should always send `X-Workspace-Id` explicitly rather than relying on the fallback.\n\n## Response shapes\n\n- A single resource is returned as `{ \"data\": { ... } }`.\n- A plain collection (no pagination) is returned as `{ \"data\": [ ... ] }`.\n- A paginated list (see each endpoint's `page` / `per_page` parameters) is returned as `{ \"data\": [ ... ], \"links\": { \"first\", \"last\", \"prev\", \"next\" }, \"meta\": { \"current_page\", \"from\", \"last_page\", \"path\", \"per_page\", \"to\", \"total\" } }`.\n- Actions with no resource to return (e.g. delete) respond `{ \"message\": \"...\" }`.\n\n## Errors\n\n- `401` — missing or invalid bearer token.\n- `403` — authenticated, but missing the workspace permission or plan feature the action requires (message explains which). Also returned when the resolved workspace does not belong to the token owner.\n- `404` — the resource does not exist, or belongs to a different workspace (Buildora never distinguishes the two, to avoid leaking cross-tenant existence).\n- `422` — validation failed: `{ \"message\": \"...\", \"errors\": { \"field\": [\"...\"] } }`.\n\n## Scope of this document\n\nThis spec curates the endpoints a workspace's own API token is meant to call from external scripts and integrations. It intentionally omits SaaS-admin-only routes, mobile-app-specific auth flows, payment-gateway webhook receivers, and dashboard-only workspace/team/billing administration (members, roles, invitations, activity log, plan, credits) — those are documented in the internal `docs/*.md` contracts instead.",
    "contact": {
      "name": "Buildora"
    }
  },
  "servers": [
    {
      "url": "https://{host}/api/v1",
      "description": "Your Buildora instance",
      "variables": {
        "host": {
          "default": "your-domain.com",
          "description": "The domain your Buildora backend is deployed on."
        }
      }
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Me",
      "description": "Identity and workspace context for the current token."
    },
    {
      "name": "API Tokens",
      "description": "Manage your own personal API tokens."
    },
    {
      "name": "Websites",
      "description": "Create, read, update and delete websites."
    },
    {
      "name": "Leads",
      "description": "The built-in lightweight CRM."
    },
    {
      "name": "Forms",
      "description": "Form definitions and their submissions."
    },
    {
      "name": "Blog",
      "description": "Blog posts, categories, tags and settings."
    },
    {
      "name": "Media",
      "description": "The media library (files and folders)."
    },
    {
      "name": "Modules",
      "description": "Business-module data (menus, listings, packages, etc.) per website."
    },
    {
      "name": "Comments",
      "description": "Collaboration comment threads on a website."
    },
    {
      "name": "Webhooks",
      "description": "Outbound webhook subscriptions for workspace events."
    },
    {
      "name": "Data store",
      "description": "Per-website database (sqlite / managed MySQL / external MySQL) with custom collections and a CRUD API. Requires the `data_store` plan feature; writes need `content.edit`."
    },
    {
      "name": "SEO",
      "description": "Site SEO defaults, tracking, custom code, per-page SEO and the redirect manager."
    },
    {
      "name": "Ecommerce",
      "description": "Storefront for published sites (product_grid, product_detail, cart, checkout, cart_button blocks): public shop API plus store settings and coupons."
    },
    {
      "name": "Collaboration",
      "description": "Builder presence and edit-conflict protection (optimistic concurrency via page revisions)."
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "tags": [
          "Me"
        ],
        "summary": "Get the current user, workspaces and permissions",
        "description": "Returns the authenticated user, every workspace they belong to, the currently-resolved workspace (see the workspace-context rules above), the token owner's permissions within it, and a plan/credits summary. Useful as a first call to confirm a token works and to discover available workspace IDs.",
        "operationId": "getMe",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Me"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/account/api-tokens": {
      "get": {
        "tags": [
          "API Tokens"
        ],
        "summary": "List your API tokens",
        "description": "Never returns the plaintext token value — only the `id`, `name`, abilities and usage metadata. Newest first.",
        "operationId": "listApiTokens",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiToken"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "API Tokens"
        ],
        "summary": "Create an API token",
        "description": "The response's `token` field is the only time the plaintext value is ever shown — store it immediately. A user may have at most 10 tokens at once; revoke an old one first if you hit the limit.",
        "operationId": "createApiToken",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 100,
                    "example": "CI deploy script"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string",
                      "description": "Plaintext token — shown only once.",
                      "example": "1|AbCdEf123..."
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiToken"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/account/api-tokens/{id}": {
      "delete": {
        "tags": [
          "API Tokens"
        ],
        "summary": "Revoke an API token",
        "description": "Immediately invalidates the token. Anything still using it loses API access right away. Note: a token can revoke itself.",
        "operationId": "deleteApiToken",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/websites": {
      "get": {
        "tags": [
          "Websites"
        ],
        "summary": "List websites in the current workspace",
        "operationId": "listWebsites",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Matches name or subdomain."
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "published",
                "maintenance",
                "unpublished"
              ]
            }
          },
          {
            "name": "website_type",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 15,
              "maximum": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedWebsites"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "Websites"
        ],
        "summary": "Create a website",
        "description": "Omit `template_id` to have Buildora generate the site with AI (consumes AI credits); the response's `generation_id` can then be polled elsewhere in the dashboard API. Requires the `website.create` permission.",
        "operationId": "createWebsite",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebsiteCreateInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WebsiteDetailed"
                    },
                    "generation_id": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}": {
      "get": {
        "tags": [
          "Websites"
        ],
        "summary": "Get a website",
        "operationId": "getWebsite",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WebsiteDetailed"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "tags": [
          "Websites"
        ],
        "summary": "Update a website",
        "description": "Brand kit / navigation / settings edits accept `base_revision` (= `data.design_revision`). Stale saves are three-way merged by token key / navigation item id (`merged:true`), true conflicts answer 409 with `conflicts` (resolve via `resolutions`). Without `base_revision` the write is last-write-wins as before.",
        "operationId": "updateWebsite",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebsiteUpdateInput",
                "properties": {
                  "base_revision": {
                    "type": "integer"
                  },
                  "resolutions": {
                    "$ref": "#/components/schemas/Resolutions"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WebsiteDetailed"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "409": {
            "description": "Edit conflict that could not be merged automatically",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "example": "edit_conflict"
                    },
                    "scope": {
                      "type": "string",
                      "enum": [
                        "page",
                        "website"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "current_revision": {
                      "type": "integer"
                    },
                    "updated_by": {
                      "type": "object",
                      "nullable": true
                    },
                    "updated_at": {
                      "type": "string",
                      "nullable": true
                    },
                    "mergeable": {
                      "type": "boolean",
                      "description": "false when the base snapshot is gone (only whole-save choices remain)"
                    },
                    "conflicts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/EditConflictItem"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Websites"
        ],
        "summary": "Delete a website",
        "description": "Requires the `website.delete` permission. Irreversible.",
        "operationId": "deleteWebsite",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/websites/{website}/duplicate": {
      "post": {
        "tags": [
          "Websites"
        ],
        "summary": "Duplicate a website",
        "description": "Requires the `website.create` permission.",
        "operationId": "duplicateWebsite",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WebsiteDetailed"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/leads": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "List leads",
        "description": "Requires the `leads.view` permission.",
        "operationId": "listLeads",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "website_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "form_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "stage",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "new",
                "contacted",
                "qualified",
                "converted",
                "closed"
              ]
            }
          },
          {
            "name": "assigned_to",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 25,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedLeads"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "tags": [
          "Leads"
        ],
        "summary": "Create a lead",
        "description": "Requires the `leads.manage` permission. At least one of `name`, `email` or `phone` is required.",
        "operationId": "createLead",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadCreateInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Lead"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/leads/stats": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Lead funnel statistics",
        "description": "Requires the `leads.view` permission.",
        "operationId": "getLeadStats",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "website_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/LeadStats"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/leads/export": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Export leads as CSV",
        "description": "Requires the `leads.view` permission. Accepts the same filters as the list endpoint. Streams a UTF-8 CSV file (with BOM) with columns: id, created_at, name, email, phone, stage, assigned_to, website, form, source, tags, referrer, utm_source, utm_medium, utm_campaign, data.",
        "operationId": "exportLeads",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "website_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "form_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "stage",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "CSV file",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/leads/bulk": {
      "post": {
        "tags": [
          "Leads"
        ],
        "summary": "Bulk update or delete leads",
        "description": "Requires the `leads.manage` permission. Applies `action` to up to 500 leads at once.",
        "operationId": "bulkLeads",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadBulkInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/leads/{lead}": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Get a lead",
        "description": "Requires the `leads.view` permission. Includes notes, activity timeline and the originating form submission.",
        "operationId": "getLead",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/LeadIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/LeadDetailed"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "tags": [
          "Leads"
        ],
        "summary": "Update a lead",
        "description": "Requires the `leads.manage` permission.",
        "operationId": "updateLead",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/LeadIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadUpdateInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Lead"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Leads"
        ],
        "summary": "Delete a lead",
        "description": "Requires the `leads.manage` permission.",
        "operationId": "deleteLead",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/LeadIdPath"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/leads/{lead}/notes": {
      "post": {
        "tags": [
          "Leads"
        ],
        "summary": "Add a note to a lead",
        "description": "Requires the `leads.manage` permission.",
        "operationId": "addLeadNote",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/LeadIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "body"
                ],
                "properties": {
                  "body": {
                    "type": "string",
                    "maxLength": 5000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/LeadNote"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/forms": {
      "get": {
        "tags": [
          "Forms"
        ],
        "summary": "List forms on a website",
        "description": "Returns every form definition for the website (not paginated).",
        "operationId": "listForms",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Form"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "post": {
        "tags": [
          "Forms"
        ],
        "summary": "Create a form",
        "description": "Requires the `forms.manage` permission.",
        "operationId": "createForm",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FormCreateInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Form"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/forms/{form}": {
      "get": {
        "tags": [
          "Forms"
        ],
        "summary": "Get a form",
        "operationId": "getForm",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/FormIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Form"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "tags": [
          "Forms"
        ],
        "summary": "Update a form",
        "description": "Requires the `forms.manage` permission.",
        "operationId": "updateForm",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/FormIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FormUpdateInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Form"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Forms"
        ],
        "summary": "Delete a form",
        "description": "Requires the `forms.manage` permission.",
        "operationId": "deleteForm",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/FormIdPath"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/forms/{form}/duplicate": {
      "post": {
        "tags": [
          "Forms"
        ],
        "summary": "Duplicate a form",
        "description": "Requires the `forms.manage` permission.",
        "operationId": "duplicateForm",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/FormIdPath"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 120,
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Form"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/forms/{form}/submissions": {
      "get": {
        "tags": [
          "Forms"
        ],
        "summary": "List a form's submissions",
        "description": "Requires the `leads.view` permission (submissions feed the CRM).",
        "operationId": "listFormSubmissions",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/FormIdPath"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 25,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedFormSubmissions"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/forms/{form}/submissions/export": {
      "get": {
        "tags": [
          "Forms"
        ],
        "summary": "Export a form's submissions as CSV",
        "description": "Requires the `leads.view` permission.",
        "operationId": "exportFormSubmissions",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/FormIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "CSV file",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/websites/{website}/blog/posts": {
      "get": {
        "tags": [
          "Blog"
        ],
        "summary": "List blog posts",
        "operationId": "listBlogPosts",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "published",
                "scheduled"
              ]
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedBlogPosts"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "post": {
        "tags": [
          "Blog"
        ],
        "summary": "Create a blog post",
        "description": "Requires the `blog.manage` permission and the workspace plan to include the `blog` feature.",
        "operationId": "createBlogPost",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BlogPostCreateInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogPostFull"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/blog/posts/{post}": {
      "get": {
        "tags": [
          "Blog"
        ],
        "summary": "Get a blog post",
        "description": "Includes full `content` and `translations`, unlike the list endpoint.",
        "operationId": "getBlogPost",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/PostIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogPostFull"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "tags": [
          "Blog"
        ],
        "summary": "Update a blog post",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "updateBlogPost",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/PostIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BlogPostUpdateInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogPostFull"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Blog"
        ],
        "summary": "Delete a blog post",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "deleteBlogPost",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/PostIdPath"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/blog/posts/{post}/publish": {
      "post": {
        "tags": [
          "Blog"
        ],
        "summary": "Publish a blog post",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "publishBlogPost",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/PostIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogPostFull"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/blog/posts/{post}/unpublish": {
      "post": {
        "tags": [
          "Blog"
        ],
        "summary": "Unpublish a blog post",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "unpublishBlogPost",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/PostIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogPostFull"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/blog/posts/{post}/duplicate": {
      "post": {
        "tags": [
          "Blog"
        ],
        "summary": "Duplicate a blog post",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "duplicateBlogPost",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/PostIdPath"
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogPostFull"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/websites/{website}/blog/categories": {
      "get": {
        "tags": [
          "Blog"
        ],
        "summary": "List blog categories",
        "operationId": "listBlogCategories",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BlogCategory"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "post": {
        "tags": [
          "Blog"
        ],
        "summary": "Create a blog category",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "createBlogCategory",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BlogCategoryInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogCategory"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/blog/categories/{category}": {
      "patch": {
        "tags": [
          "Blog"
        ],
        "summary": "Update a blog category",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "updateBlogCategory",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "category",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BlogCategoryInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogCategory"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Blog"
        ],
        "summary": "Delete a blog category",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "deleteBlogCategory",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "category",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/websites/{website}/blog/tags": {
      "get": {
        "tags": [
          "Blog"
        ],
        "summary": "List blog tags",
        "operationId": "listBlogTags",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BlogTag"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "post": {
        "tags": [
          "Blog"
        ],
        "summary": "Create a blog tag",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "createBlogTag",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BlogTagInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogTag"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/blog/tags/{tag}": {
      "patch": {
        "tags": [
          "Blog"
        ],
        "summary": "Update a blog tag",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "updateBlogTag",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "tag",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BlogTagInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogTag"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Blog"
        ],
        "summary": "Delete a blog tag",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "deleteBlogTag",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "tag",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/websites/{website}/blog/settings": {
      "get": {
        "tags": [
          "Blog"
        ],
        "summary": "Get blog settings",
        "operationId": "getBlogSettings",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogSettings"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "tags": [
          "Blog"
        ],
        "summary": "Update blog settings",
        "description": "Requires the `blog.manage` permission and the `blog` plan feature.",
        "operationId": "updateBlogSettings",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BlogSettingsUpdateInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogSettings"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/blog/stats": {
      "get": {
        "tags": [
          "Blog"
        ],
        "summary": "Blog statistics",
        "operationId": "getBlogStats",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BlogStats"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/media": {
      "get": {
        "tags": [
          "Media"
        ],
        "summary": "List media files",
        "operationId": "listMedia",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "folder_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "image",
                "video",
                "svg",
                "document"
              ]
            }
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "upload",
                "stock",
                "ai"
              ]
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedMedia"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "Media"
        ],
        "summary": "Upload a media file",
        "description": "Requires the `media.manage` permission.",
        "operationId": "uploadMedia",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "folder_id": {
                    "type": "integer",
                    "nullable": true
                  },
                  "alt": {
                    "type": "string",
                    "maxLength": 500,
                    "nullable": true
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 40
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Media"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/media/from-url": {
      "post": {
        "tags": [
          "Media"
        ],
        "summary": "Import a media file from a URL",
        "description": "Requires the `media.manage` permission. Useful for pulling in stock photos or AI-generated images by URL without a multipart upload.",
        "operationId": "importMediaFromUrl",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MediaFromUrlInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Media"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/media/{media}": {
      "get": {
        "tags": [
          "Media"
        ],
        "summary": "Get a media file",
        "operationId": "getMedia",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/MediaIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Media"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "tags": [
          "Media"
        ],
        "summary": "Update media metadata",
        "description": "Requires the `media.manage` permission.",
        "operationId": "updateMedia",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/MediaIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MediaUpdateInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Media"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Media"
        ],
        "summary": "Delete a media file",
        "description": "Requires the `media.manage` permission.",
        "operationId": "deleteMedia",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/MediaIdPath"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/media/{media}/replace": {
      "post": {
        "tags": [
          "Media"
        ],
        "summary": "Replace a media file's contents",
        "description": "Requires the `media.manage` permission. Keeps the same media record/id and URL, replacing the underlying file.",
        "operationId": "replaceMedia",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/MediaIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Media"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/media/{media}/crop": {
      "post": {
        "tags": [
          "Media"
        ],
        "summary": "Crop an image",
        "description": "Requires the `media.manage` permission. Coordinates and dimensions are in pixels of the original image.",
        "operationId": "cropMedia",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/MediaIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MediaCropInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Media"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/media/folders": {
      "get": {
        "tags": [
          "Media"
        ],
        "summary": "List media folders as a tree",
        "description": "Returns the full folder tree (not paginated); each node includes nested `children`.",
        "operationId": "listMediaFolders",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MediaFolderTreeNode"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "Media"
        ],
        "summary": "Create a media folder",
        "description": "Requires the `media.manage` permission.",
        "operationId": "createMediaFolder",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MediaFolderInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/MediaFolder"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/media/folders/{folder}": {
      "patch": {
        "tags": [
          "Media"
        ],
        "summary": "Rename or move a media folder",
        "description": "Requires the `media.manage` permission.",
        "operationId": "updateMediaFolder",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "folder",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MediaFolderInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/MediaFolder"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Media"
        ],
        "summary": "Delete a media folder",
        "description": "Requires the `media.manage` permission.",
        "operationId": "deleteMediaFolder",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "folder",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/websites/{website}/modules": {
      "get": {
        "tags": [
          "Modules"
        ],
        "summary": "Get a website's module registry and settings",
        "description": "Returns every available module, which are enabled, which are suggested for the site's `website_type`, their per-module settings, item counts, and whether the plan includes the `business_modules` feature.",
        "operationId": "getModules",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ModuleOverview"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "tags": [
          "Modules"
        ],
        "summary": "Update enabled modules and their settings",
        "description": "Requires the `content.edit` permission and the `business_modules` plan feature.",
        "operationId": "updateModules",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ModulesUpdateInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ModuleOverview"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/modules/{module}/enable": {
      "post": {
        "tags": [
          "Modules"
        ],
        "summary": "Enable a module",
        "description": "Requires the `content.edit` permission and the `business_modules` plan feature.",
        "operationId": "enableModule",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/ModuleKeyPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ModuleOverview"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Website not found, or unknown module key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/websites/{website}/modules/{module}/disable": {
      "post": {
        "tags": [
          "Modules"
        ],
        "summary": "Disable a module",
        "description": "Requires the `content.edit` permission and the `business_modules` plan feature.",
        "operationId": "disableModule",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/ModuleKeyPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ModuleOverview"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Website not found, or unknown module key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/websites/{website}/modules/render-data": {
      "get": {
        "tags": [
          "Modules"
        ],
        "summary": "Get the render payload for enabled modules",
        "description": "The same `{modules, module_settings}` payload the published site's renderer consumes — a shortcut to read all enabled modules' data without walking each entity's items endpoint individually.",
        "operationId": "getModuleRenderData",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/websites/{website}/modules/{module}/{entity}/items": {
      "get": {
        "tags": [
          "Modules"
        ],
        "summary": "List a module entity's items",
        "description": "E.g. `module=restaurant`, `entity=dish` lists menu items; `module=real_estate`, `entity=property` lists listings. Available modules/entities are discovered via `GET /websites/{website}/modules`.",
        "operationId": "listModuleItems",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/ModuleKeyPath"
          },
          {
            "$ref": "#/components/parameters/EntityKeyPath"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "featured",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedModuleItems"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "post": {
        "tags": [
          "Modules"
        ],
        "summary": "Create a module entity item",
        "description": "Requires the `content.edit` permission and the `business_modules` plan feature. Field validation is generated per entity from the module registry; `data` holds the entity-specific fields (see `GET /websites/{website}/modules` for the registry, or an existing item's `data` shape).",
        "operationId": "createModuleItem",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/ModuleKeyPath"
          },
          {
            "$ref": "#/components/parameters/EntityKeyPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ModuleItemInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ModuleItem"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/modules/{module}/{entity}/reorder": {
      "post": {
        "tags": [
          "Modules"
        ],
        "summary": "Reorder a module entity's items",
        "description": "Requires the `content.edit` permission and the `business_modules` plan feature.",
        "operationId": "reorderModuleItems",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/ModuleKeyPath"
          },
          {
            "$ref": "#/components/parameters/EntityKeyPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ids"
                ],
                "properties": {
                  "ids": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "description": "Item ids in the desired display order."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/module-items/{item}": {
      "get": {
        "tags": [
          "Modules"
        ],
        "summary": "Get a module item",
        "operationId": "getModuleItem",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/ModuleItemIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ModuleItem"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "tags": [
          "Modules"
        ],
        "summary": "Update a module item",
        "description": "Requires the `content.edit` permission and the `business_modules` plan feature.",
        "operationId": "updateModuleItem",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/ModuleItemIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ModuleItemInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ModuleItem"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Modules"
        ],
        "summary": "Delete a module item",
        "description": "Requires the `content.edit` permission and the `business_modules` plan feature.",
        "operationId": "deleteModuleItem",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/ModuleItemIdPath"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/module-items/{item}/duplicate": {
      "post": {
        "tags": [
          "Modules"
        ],
        "summary": "Duplicate a module item",
        "description": "Requires the `content.edit` permission and the `business_modules` plan feature.",
        "operationId": "duplicateModuleItem",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/ModuleItemIdPath"
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ModuleItem"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/websites/{website}/comments/summary": {
      "get": {
        "tags": [
          "Comments"
        ],
        "summary": "Comment counts summary",
        "description": "Requires read access to the website (any member the comment service considers able to access it).",
        "operationId": "getCommentsSummary",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "name": "page_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CommentsSummary"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/websites/{website}/comments": {
      "get": {
        "tags": [
          "Comments"
        ],
        "summary": "List comment threads on a website",
        "operationId": "listComments",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "name": "page_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "block_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resolved",
            "in": "query",
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ]
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedComments"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "tags": [
          "Comments"
        ],
        "summary": "Post a comment",
        "description": "Any member with access to the website may comment. Omit `page_id`/`block_id` for a website-level comment.",
        "operationId": "createComment",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommentCreateInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Comment"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/comments/{comment}": {
      "patch": {
        "tags": [
          "Comments"
        ],
        "summary": "Edit a comment",
        "description": "Only the comment's author may edit it.",
        "operationId": "updateComment",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/CommentIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "body"
                ],
                "properties": {
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 5000
                  },
                  "mentions": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "maxItems": 20
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Comment"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not the comment's author.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Comments"
        ],
        "summary": "Delete a comment",
        "description": "The comment's author, or a member with the `team.manage` permission, may delete it.",
        "operationId": "deleteComment",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/CommentIdPath"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/comments/{comment}/resolve": {
      "post": {
        "tags": [
          "Comments"
        ],
        "summary": "Resolve a comment thread",
        "description": "Requires the `page.edit` or `content.edit` permission.",
        "operationId": "resolveComment",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/CommentIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Comment"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/comments/{comment}/unresolve": {
      "post": {
        "tags": [
          "Comments"
        ],
        "summary": "Reopen a resolved comment thread",
        "description": "Requires the `page.edit` or `content.edit` permission.",
        "operationId": "unresolveComment",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/CommentIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Comment"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/workspace/webhooks": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhook subscriptions",
        "description": "Requires the `settings.manage` permission and the `webhooks` plan feature.",
        "operationId": "listWebhooks",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Webhook"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Create a webhook subscription",
        "description": "Requires the `settings.manage` permission and the `webhooks` plan feature. A signing secret (`whsec_...`) is generated automatically; use it to verify the `X-Buildora-Signature` header on deliveries.",
        "operationId": "createWebhook",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookCreateInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Webhook"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/workspace/webhooks/{webhook}": {
      "patch": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Update a webhook subscription",
        "description": "Requires the `settings.manage` permission and the `webhooks` plan feature.",
        "operationId": "updateWebhook",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookUpdateInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Webhook"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete a webhook subscription",
        "description": "Requires the `settings.manage` permission and the `webhooks` plan feature.",
        "operationId": "deleteWebhook",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookIdPath"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/workspace/webhooks/{webhook}/test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Send a test event",
        "description": "Requires the `settings.manage` permission and the `webhooks` plan feature. Sends a synthetic `test` event immediately (synchronously) and records the attempt in the delivery log.",
        "operationId": "testWebhook",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/workspace/webhooks/{webhook}/deliveries": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List recent delivery attempts",
        "description": "Requires the `settings.manage` permission and the `webhooks` plan feature. Returns the most recent 50 deliveries, newest first (not paginated).",
        "operationId": "listWebhookDeliveries",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookDelivery"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/websites/{website}/data": {
      "get": {
        "tags": [
          "Data store"
        ],
        "summary": "Get the data store",
        "operationId": "getDataStore",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "description": "`data` is null when not enabled.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DataStore"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Data store"
        ],
        "summary": "Disable the data store",
        "operationId": "disableDataStore",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "confirm"
                ],
                "properties": {
                  "confirm": {
                    "type": "string",
                    "description": "The website name."
                  },
                  "drop": {
                    "type": "boolean",
                    "description": "Also delete the sqlite file / managed MySQL database. Required (422 drop_required) for managed MySQL."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/data/enable": {
      "post": {
        "tags": [
          "Data store"
        ],
        "summary": "Enable the data store",
        "operationId": "enableDataStore",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataStoreInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DataStore"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/data/test-connection": {
      "post": {
        "tags": [
          "Data store"
        ],
        "summary": "Test an external MySQL connection",
        "operationId": "testDataConnection",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataStoreInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "ok": {
                          "type": "boolean"
                        },
                        "error": {
                          "type": "string"
                        },
                        "server_version": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/data/migrate": {
      "post": {
        "tags": [
          "Data store"
        ],
        "summary": "Migrate to another engine",
        "operationId": "migrateDataStore",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "description": "Copies every collection and record to the new engine, then swaps.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataStoreInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DataStore"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/data/collections": {
      "get": {
        "tags": [
          "Data store"
        ],
        "summary": "List collections",
        "operationId": "listDataCollections",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DataCollection"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "post": {
        "tags": [
          "Data store"
        ],
        "summary": "Create a collection",
        "operationId": "createDataCollection",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataCollectionInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DataCollection"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/data/collections/{slug}": {
      "get": {
        "tags": [
          "Data store"
        ],
        "summary": "Get a collection",
        "operationId": "getDataCollection",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/CollectionSlugPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DataCollection"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "patch": {
        "tags": [
          "Data store"
        ],
        "summary": "Update a collection / alter fields",
        "operationId": "updateDataCollection",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/CollectionSlugPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataCollectionInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DataCollection"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Data store"
        ],
        "summary": "Delete a collection",
        "operationId": "deleteDataCollection",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/CollectionSlugPath"
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/data/collections/{slug}/records": {
      "get": {
        "tags": [
          "Data store"
        ],
        "summary": "List records",
        "operationId": "listDataRecords",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/CollectionSlugPath"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "description": "Filter with `filter[field]=value`. per_page max 100.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DataRecord"
                      }
                    },
                    "meta": {
                      "type": "object"
                    },
                    "links": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "post": {
        "tags": [
          "Data store"
        ],
        "summary": "Create a record",
        "operationId": "createDataRecord",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/CollectionSlugPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DataRecord"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/data/collections/{slug}/records/{id}": {
      "get": {
        "tags": [
          "Data store"
        ],
        "summary": "Get a record",
        "operationId": "getDataRecord",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/CollectionSlugPath"
          },
          {
            "$ref": "#/components/parameters/RecordIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DataRecord"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "patch": {
        "tags": [
          "Data store"
        ],
        "summary": "Update a record",
        "operationId": "updateDataRecord",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/CollectionSlugPath"
          },
          {
            "$ref": "#/components/parameters/RecordIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DataRecord"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "Data store"
        ],
        "summary": "Delete a record",
        "operationId": "deleteDataRecord",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/CollectionSlugPath"
          },
          {
            "$ref": "#/components/parameters/RecordIdPath"
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/data/collections/{slug}/records/bulk-delete": {
      "post": {
        "tags": [
          "Data store"
        ],
        "summary": "Bulk delete records",
        "operationId": "bulkDeleteDataRecords",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/CollectionSlugPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ids": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "deleted": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/data/collections/{slug}/import": {
      "post": {
        "tags": [
          "Data store"
        ],
        "summary": "Import records (CSV / JSON)",
        "operationId": "importDataRecords",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/CollectionSlugPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "imported": {
                          "type": "integer"
                        },
                        "skipped": {
                          "type": "integer"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "append",
                      "replace"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/websites/{website}/data/collections/{slug}/export": {
      "get": {
        "tags": [
          "Data store"
        ],
        "summary": "Export records",
        "operationId": "exportDataRecords",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "$ref": "#/components/parameters/CollectionSlugPath"
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "csv",
                "json"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Plan does not include the data store (code plan_feature_unavailable) or the store is suspended (code data_store_suspended)."
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/public/data/{website}/{slug}/records": {
      "get": {
        "tags": [
          "Data store"
        ],
        "summary": "Public: list records",
        "operationId": "publicListDataRecords",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Case-insensitive contains over the non-hidden text columns (wildcards are literal)",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "filter",
            "in": "query",
            "style": "deepObject",
            "explode": true,
            "description": "filter[field]=value (equality) or filter[field][]=a&filter[field][]=b (IN) or filter[field]=null. Only non-hidden scalar fields (not json / long_text) plus id / created_at / updated_at; unknown or hidden fields are ignored (indistinguishable). Max 10 filters, 20 IN values, 255 chars per value.",
            "schema": {
              "type": "object",
              "additionalProperties": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                ]
              }
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Comma list of non-hidden field keys / id / created_at / updated_at, prefix - for descending (max 3). Hidden or unknown keys fall back to the default order (-id).",
            "schema": {
              "type": "string",
              "example": "-created_at,price"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "description": "Page size (max 50)",
            "schema": {
              "type": "integer",
              "maximum": 50,
              "default": 25
            }
          }
        ],
        "description": "No authentication. Only for collections with access.read=public; hidden fields are never returned and cannot be searched, filtered or sorted by (no value oracle). Permissive CORS, throttled. Used by the data_list block's search / filters / sort / pagination on published sites.",
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Collection not public / store unavailable or suspended"
          },
          "429": {
            "description": "Too many requests"
          }
        }
      },
      "post": {
        "tags": [
          "Data store"
        ],
        "summary": "Public: create record",
        "operationId": "publicCreateDataRecord",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "description": "No authentication. Only for collections with access.create=public. Throttled 30/min/IP.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "data": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "404": {
            "description": "Collection not public / store unavailable or suspended"
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Too many requests"
          }
        }
      }
    },
    "/public/data/{website}/{slug}/records/{id}": {
      "get": {
        "tags": [
          "Data store"
        ],
        "summary": "Public: get one record",
        "operationId": "publicShowDataRecord",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/websites/{website}/redirects": {
      "get": {
        "tags": [
          "SEO"
        ],
        "summary": "List redirects",
        "operationId": "listRedirects",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Redirect"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "post": {
        "tags": [
          "SEO"
        ],
        "summary": "Create a redirect",
        "description": "Requires `settings.manage`. Applied immediately on the published site (exact matches first, then the longest wildcard).",
        "operationId": "createRedirect",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RedirectInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Redirect"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/websites/{website}/redirects/{redirect}": {
      "patch": {
        "tags": [
          "SEO"
        ],
        "summary": "Update a redirect",
        "operationId": "updateRedirect",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "name": "redirect",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RedirectInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Redirect"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "delete": {
        "tags": [
          "SEO"
        ],
        "summary": "Delete a redirect",
        "operationId": "deleteRedirect",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "name": "redirect",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/public/shop/{website}/config": {
      "get": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Public: shop settings",
        "operationId": "publicShopConfig",
        "description": "Currency, flat shipping, free-shipping threshold, tax rate, cash-on-delivery switch/instructions. `payment_methods` lists the enabled, configured methods in display order (online gateways only when the plan has `online_payments` and the shop currency is supported).",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Website id (published, workspace plan includes ecommerce — anything else is a uniform 404)"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/public/shop/{website}/products": {
      "get": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Public: list products",
        "operationId": "publicShopProducts",
        "description": "Active products of the website's workspace. No SKU / exact stock is exposed (only in_stock, low_stock, max_qty). Throttled 240/min/IP. CORS `*`.",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Website id (published, workspace plan includes ecommerce — anything else is a uniform 404)"
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "newest",
                "price_asc",
                "price_desc",
                "name"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 50
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Error"
          }
        }
      }
    },
    "/public/shop/{website}/products/{slug}": {
      "get": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Public: show product",
        "operationId": "publicShopProduct",
        "description": "One active product by slug (404 for draft / archived / other workspaces). Variant products add `has_variants`, `price` = lowest active variant price, `price_to`, `options[{name,values,swatches}]` and `variants[{id,options,label,price,compare_at_price,in_stock,low_stock,max_qty,image}]` (active variants only; never sku / exact stock).",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Website id (published, workspace plan includes ecommerce — anything else is a uniform 404)"
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Error"
          }
        }
      }
    },
    "/public/shop/{website}/cart/validate": {
      "post": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Public: price a cart",
        "operationId": "publicShopCartValidate",
        "description": "Authoritative cart: lines, quantities clamped to stock, subtotal, discount, shipping, tax, total, `issues[]` (unavailable / out_of_stock / stock_adjusted). Throttled 60/min/IP. Variant lines (`variant_id`) are priced from the variant (price override, per-variant stock); issues add `variant_required`. Lines carry `variant_id` and `variant_label`.",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Website id (published, workspace plan includes ecommerce — anything else is a uniform 404)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "items"
                ],
                "properties": {
                  "items": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "type": "object",
                      "required": [
                        "product_id",
                        "quantity"
                      ],
                      "properties": {
                        "product_id": {
                          "type": "integer"
                        },
                        "quantity": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 99
                        },
                        "variant_id": {
                          "type": "integer",
                          "nullable": true,
                          "description": "Required for products that have variants (the chosen variant id); must be omitted for plain products. Unknown, inactive or foreign variant ids are rejected as `unavailable`."
                        }
                      }
                    },
                    "description": "Only ids and quantities are read. Any price/name/total sent is ignored — the server prices every line from the database."
                  },
                  "coupon": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 50
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Error"
          },
          "422": {
            "description": "Error"
          }
        }
      }
    },
    "/public/shop/{website}/coupon": {
      "post": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Public: apply a coupon",
        "operationId": "publicShopCoupon",
        "description": "Prices the cart with the coupon; 422 with the reason when the code is unknown, expired, exhausted or below its minimum subtotal.",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Website id (published, workspace plan includes ecommerce — anything else is a uniform 404)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "items",
                  "code"
                ],
                "properties": {
                  "items": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "type": "object",
                      "required": [
                        "product_id",
                        "quantity"
                      ],
                      "properties": {
                        "product_id": {
                          "type": "integer"
                        },
                        "quantity": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 99
                        },
                        "variant_id": {
                          "type": "integer",
                          "nullable": true,
                          "description": "Required for products that have variants (the chosen variant id); must be omitted for plain products. Unknown, inactive or foreign variant ids are rejected as `unavailable`."
                        }
                      }
                    },
                    "description": "Only ids and quantities are read. Any price/name/total sent is ignored — the server prices every line from the database."
                  },
                  "code": {
                    "type": "string",
                    "maxLength": 50
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Error"
          },
          "422": {
            "description": "Error"
          }
        }
      }
    },
    "/public/shop/{website}/orders": {
      "post": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Public: place an order",
        "operationId": "publicShopOrderCreate",
        "description": "Re-prices the cart in a transaction (row locks) and refuses overselling and exhausted coupons (422 with a fresh `cart`). `payment_method` must be one of the methods listed by `GET config` → `payment_methods`: `cod` (stock reserved, status `pending`), `bank_transfer` (stock reserved, status `pending_payment` until the owner marks it paid; instructions returned) or an online gateway `stripe|paypal|sslcommerz|bkash` (status `pending_payment`, stock NOT touched until the provider confirms the exact total; response carries `redirect_url` to send the customer to; unpaid orders expire and release everything). Returns the order number and a secret `token` for the status endpoint. 502 when the provider cannot be reached (the order is closed again). Throttled 10/min/IP. Honeypot field `_hp`.",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Website id (published, workspace plan includes ecommerce — anything else is a uniform 404)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "items",
                  "customer",
                  "shipping_address",
                  "payment_method"
                ],
                "properties": {
                  "items": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "type": "object",
                      "required": [
                        "product_id",
                        "quantity"
                      ],
                      "properties": {
                        "product_id": {
                          "type": "integer"
                        },
                        "quantity": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 99
                        },
                        "variant_id": {
                          "type": "integer",
                          "nullable": true,
                          "description": "Required for products that have variants (the chosen variant id); must be omitted for plain products. Unknown, inactive or foreign variant ids are rejected as `unavailable`."
                        }
                      }
                    },
                    "description": "Only ids and quantities are read. Any price/name/total sent is ignored — the server prices every line from the database."
                  },
                  "coupon": {
                    "type": "string",
                    "nullable": true
                  },
                  "payment_method": {
                    "type": "string",
                    "enum": [
                      "cod",
                      "bank_transfer",
                      "stripe",
                      "paypal",
                      "sslcommerz",
                      "bkash"
                    ]
                  },
                  "customer": {
                    "type": "object",
                    "required": [
                      "name",
                      "email"
                    ],
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string",
                        "format": "email"
                      },
                      "phone": {
                        "type": "string"
                      }
                    }
                  },
                  "shipping_address": {
                    "type": "object",
                    "required": [
                      "line1",
                      "city",
                      "country"
                    ],
                    "properties": {
                      "line1": {
                        "type": "string"
                      },
                      "line2": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "state": {
                        "type": "string"
                      },
                      "postal_code": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      }
                    }
                  },
                  "notes": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "return_url": {
                    "type": "string",
                    "description": "The checkout page URL the customer should come back to (online gateways). Only the website's own hosts are honoured; anything else falls back to /checkout."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK"
          },
          "404": {
            "description": "Error"
          },
          "422": {
            "description": "Error"
          },
          "429": {
            "description": "Error"
          }
        }
      }
    },
    "/public/shop/{website}/orders/{number}": {
      "get": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Public: order status",
        "operationId": "publicShopOrderShow",
        "description": "Status, lines and totals of an order. Requires the `token` returned at creation; unknown number, wrong token and orders of other websites are the same 404. No email / address is returned. Also returns `payment_status` (unpaid | awaiting_payment | paid | failed | expired | refunded | partially_refunded), `payment_label`, `payment_instructions` (COD / bank transfer) and `can_retry_payment`.",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Website id (published, workspace plan includes ecommerce — anything else is a uniform 404)"
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "token",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Secret order token"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Error"
          }
        }
      }
    },
    "/ecommerce/storefront": {
      "get": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Storefront summary",
        "operationId": "ecommerceStorefront",
        "description": "Plan flag `enabled`, currency, active product count, categories (used by the builder inspectors).",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/ecommerce/settings": {
      "get": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Get store settings",
        "operationId": "ecommerceSettingsShow",
        "description": "Currency, shipping, tax, cash on delivery, payment order and expiry windows (credentials live in /ecommerce/payment-methods and are never returned).",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Update store settings",
        "operationId": "ecommerceSettingsUpdate",
        "description": "Needs leads.manage.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "currency": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 3
                  },
                  "shipping_flat": {
                    "type": "number"
                  },
                  "free_shipping_over": {
                    "type": "number",
                    "nullable": true
                  },
                  "tax_rate": {
                    "type": "number",
                    "description": "percent"
                  },
                  "cod_enabled": {
                    "type": "boolean"
                  },
                  "cod_instructions": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/ecommerce/coupons": {
      "get": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "List shop coupons",
        "operationId": "ecommerceCouponsIndex",
        "description": "Paginated `{data, meta}`.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Create a shop coupon",
        "operationId": "ecommerceCouponsStore",
        "description": "percent or fixed; optional min_subtotal, max_redemptions, expires_at.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code",
                  "type",
                  "value"
                ],
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "percent",
                      "fixed"
                    ]
                  },
                  "value": {
                    "type": "number"
                  },
                  "min_subtotal": {
                    "type": "number"
                  },
                  "max_redemptions": {
                    "type": "integer",
                    "nullable": true
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK"
          },
          "422": {
            "description": "Error"
          }
        }
      }
    },
    "/ecommerce/coupons/{coupon}": {
      "patch": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Update a shop coupon",
        "operationId": "ecommerceCouponsUpdate",
        "description": "Partial update.",
        "parameters": [
          {
            "name": "coupon",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Delete a shop coupon",
        "operationId": "ecommerceCouponsDestroy",
        "description": "",
        "parameters": [
          {
            "name": "coupon",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/websites/{website}/presence": {
      "post": {
        "tags": [
          "Collaboration"
        ],
        "summary": "Presence heartbeat",
        "description": "Send every 15s when alone, ~1.5s while another collaborator is active on the same page (optionally with a `cursor`). Cache-backed (presence TTL 40s, cursor TTL 10s). Pass `leave: true` to drop presence. Rate limited (100/min).",
        "operationId": "presenceHeartbeat",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "page_id": {
                    "type": "integer",
                    "nullable": true
                  },
                  "block_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "edit",
                      "view"
                    ]
                  },
                  "leave": {
                    "type": "boolean"
                  },
                  "editing_block_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "panel": {
                    "type": "string",
                    "nullable": true
                  },
                  "cursor": {
                    "type": "object",
                    "nullable": true,
                    "required": [
                      "x"
                    ],
                    "properties": {
                      "x": {
                        "type": "number",
                        "description": "percent 0-100 (clamped)"
                      },
                      "anchor": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 64
                      },
                      "dy": {
                        "type": "number",
                        "description": "-2000..20000 (clamped)"
                      },
                      "device": {
                        "type": "string",
                        "enum": [
                          "desktop",
                          "tablet",
                          "mobile"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Active collaborators (excluding the caller); entries expire 40s after their last heartbeat",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PresenceEntry"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "get": {
        "tags": [
          "Collaboration"
        ],
        "summary": "List active collaborators",
        "operationId": "listPresence",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          },
          {
            "name": "page_id",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Include cursors of people on this page"
          }
        ],
        "responses": {
          "200": {
            "description": "Active collaborators (excluding the caller); entries expire 40s after their last heartbeat",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PresenceEntry"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/pages/{page}/revision": {
      "get": {
        "tags": [
          "Collaboration"
        ],
        "summary": "Page revision (poll)",
        "description": "Cheap endpoint with an ETag; send `If-None-Match` to receive 304 while nothing changed.",
        "operationId": "getPageRevision",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "page",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "page_id": {
                          "type": "integer"
                        },
                        "revision": {
                          "type": "integer"
                        },
                        "updated_by": {
                          "allOf": [
                            {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "integer"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "avatar": {
                                  "type": "string"
                                }
                              }
                            }
                          ],
                          "nullable": true
                        },
                        "updated_at": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/pages/{page}": {
      "patch": {
        "tags": [
          "Collaboration"
        ],
        "summary": "Save a page (autosave) with conflict protection",
        "description": "Send `base_revision`. If the page changed since, the server three-way merges your change against the stored snapshot of that revision: non-overlapping changes (different blocks, different fields, sibling add/remove/reorder) are merged and saved - the response then carries `merged:true`, `merged_with` and the merged `data.draft_blocks`. True conflicts answer **409** with a `conflicts` list; resend with `resolutions` to finish. Omit `base_revision` to save unconditionally.",
        "operationId": "updatePage",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "page",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "base_revision": {
                    "type": "integer"
                  },
                  "draft_blocks": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "name": {
                    "type": "string"
                  },
                  "slug": {
                    "type": "string"
                  },
                  "seo": {
                    "type": "object"
                  },
                  "translations": {
                    "type": "object"
                  },
                  "resolutions": {
                    "$ref": "#/components/schemas/Resolutions"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved (`data.revision` is the new revision). With `merged:true` the body also has `merged_with` and the merged tree."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Edit conflict that could not be merged automatically",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "example": "edit_conflict"
                    },
                    "scope": {
                      "type": "string",
                      "enum": [
                        "page",
                        "website"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "current_revision": {
                      "type": "integer"
                    },
                    "updated_by": {
                      "type": "object",
                      "nullable": true
                    },
                    "updated_at": {
                      "type": "string",
                      "nullable": true
                    },
                    "mergeable": {
                      "type": "boolean",
                      "description": "false when the base snapshot is gone (only whole-save choices remain)"
                    },
                    "conflicts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/EditConflictItem"
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/public/shop/{website}/webhooks/{gateway}": {
      "post": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Public: payment webhook / IPN",
        "operationId": "publicShopWebhook",
        "description": "Called by the payment provider (Stripe `Stripe-Signature`, PayPal `PAYPAL-*` headers verified through verify-webhook-signature, SSLCommerz IPN `verify_sign` + Validation API). Unauthenticated by design, authenticated by the signature using THIS website's own credentials; 400 on a bad/missing/stale signature, 404 for unknown/unconfigured gateways (bKash has no webhook), 422 when the paid amount/currency differs from the order total, 200 `duplicate` on a replay (events are recorded per gateway+event id). Throttled 240/min per website+IP. Provider-side calls are NOT verified against the real services in this repository (faked in tests).",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Website id (published, workspace plan includes ecommerce — anything else is a uniform 404)"
          },
          {
            "name": "gateway",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "stripe",
                "paypal",
                "sslcommerz"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK — status: paid | duplicate | failed | refunded | ignored | unknown_order"
          },
          "400": {
            "description": "Invalid signature"
          },
          "404": {
            "description": "Unknown website / gateway"
          },
          "422": {
            "description": "Amount or currency mismatch (order untouched)"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Could not verify right now — provider retries"
          }
        }
      }
    },
    "/public/shop/{website}/return/{gateway}/{number}/{token}": {
      "get": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Public: customer returns from the payment page",
        "operationId": "publicShopPaymentReturn",
        "description": "The provider sends the customer's browser here (GET, or POST for SSLCommerz). The query string is NOT trusted: the provider is asked to confirm server-side (Stripe session lookup, PayPal capture, SSLCommerz Validation API, bKash Execute). Redirects (302) to the shop's checkout page with `?order=&t=&payment=paid|pending|failed|cancelled`. `outcome=success|failed|cancel` is set by the URLs we hand to the provider.",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Website id (published, workspace plan includes ecommerce — anything else is a uniform 404)"
          },
          {
            "name": "gateway",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "bank_transfer",
                "stripe",
                "paypal",
                "sslcommerz",
                "bkash",
                "cod"
              ]
            }
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Order access token"
          },
          {
            "name": "outcome",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "success",
                "failed",
                "cancel"
              ]
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the shop"
          },
          "404": {
            "description": "Unknown order / token / website"
          }
        }
      }
    },
    "/public/shop/{website}/orders/{number}/pay": {
      "post": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Public: retry payment of an unpaid order",
        "operationId": "publicShopOrderPay",
        "description": "Creates a fresh provider payment for an order in `pending_payment` whose payment failed or was abandoned. Needs the order `token` (body).",
        "security": [],
        "parameters": [
          {
            "name": "website",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Website id (published, workspace plan includes ecommerce — anything else is a uniform 404)"
          },
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "type": "string"
                  },
                  "return_url": {
                    "type": "string",
                    "description": "Checkout page URL; only the shop's own hosts are honoured"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ data: { redirect_url } }"
          },
          "404": {
            "description": "Unknown order / wrong token"
          },
          "422": {
            "description": "Order cannot be paid online any more"
          },
          "502": {
            "description": "Payment provider unreachable"
          }
        }
      }
    },
    "/ecommerce/payment-methods": {
      "get": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "List payment methods",
        "operationId": "ecommercePaymentMethods",
        "description": "Every method in checkout order with `configured` flags (never credentials), `online_allowed` (plan feature `online_payments`), shop currency, expiry windows and the store's websites (`api_base` → webhook URL `{api_base}/webhooks/{gateway}`). With `website_id` the response has `scope`, `overrides` ({payment_order, expiry}) and each method carries `source` (`custom` | `default`), `override_exists` and, for gateways with a webhook, that site's `webhook_url`; fields still expose only `configured` flags, never values.",
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "plan_feature_unavailable (online_payments) or missing permission"
          },
          "422": {
            "description": "Validation error"
          }
        },
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Scope: omit for the workspace DEFAULT; a website id of this workspace for that website's OVERRIDE (404 for a site of another workspace). Resolution at checkout: the website's complete override, else the workspace default."
          }
        ]
      }
    },
    "/ecommerce/payment-methods/{gateway}": {
      "put": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Update a payment method",
        "operationId": "ecommercePaymentMethodUpdate",
        "description": "Enable/disable, mode, bank-transfer/COD instructions and gateway credentials (write-only). Online gateways need the `online_payments` plan feature (403 `plan_feature_unavailable`); a method cannot be enabled without all required credentials / instructions. Needs settings.manage (credentials are secrets).",
        "parameters": [
          {
            "name": "gateway",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "bank_transfer",
                "stripe",
                "paypal",
                "sslcommerz",
                "bkash",
                "cod"
              ]
            }
          },
          {
            "name": "website_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Scope: omit for the workspace DEFAULT; a website id of this workspace for that website's OVERRIDE (404 for a site of another workspace). Resolution at checkout: the website's complete override, else the workspace default."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "test",
                      "live"
                    ]
                  },
                  "config": {
                    "type": "object",
                    "properties": {
                      "instructions": {
                        "type": "string",
                        "nullable": true
                      }
                    }
                  },
                  "credentials": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string",
                      "nullable": true
                    },
                    "description": "WRITE-ONLY. Non-empty string = set, null = clear that field, omitted = keep. Never returned by any endpoint — responses only carry per-field `configured` flags."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "plan_feature_unavailable (online_payments) or missing permission"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/ecommerce/payment-methods/{gateway}/credentials": {
      "delete": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Remove saved credentials",
        "operationId": "ecommercePaymentMethodClear",
        "description": "Forgets every stored credential of the gateway and switches it off. Needs settings.manage (credentials are secrets).",
        "parameters": [
          {
            "name": "gateway",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "bank_transfer",
                "stripe",
                "paypal",
                "sslcommerz",
                "bkash",
                "cod"
              ]
            }
          },
          {
            "name": "website_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Scope: omit for the workspace DEFAULT; a website id of this workspace for that website's OVERRIDE (404 for a site of another workspace). Resolution at checkout: the website's complete override, else the workspace default."
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "plan_feature_unavailable (online_payments) or missing permission"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/ecommerce/payment-methods/{gateway}/test": {
      "post": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Test gateway connection",
        "operationId": "ecommercePaymentMethodTest",
        "description": "Authenticates against the provider with the saved credentials where the API allows it (Stripe /balance, PayPal OAuth, bKash grant token). Throttled 10/min. Returns { ok, message }. Needs settings.manage (credentials are secrets).",
        "parameters": [
          {
            "name": "gateway",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "bank_transfer",
                "stripe",
                "paypal",
                "sslcommerz",
                "bkash",
                "cod"
              ]
            }
          },
          {
            "name": "website_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Scope: omit for the workspace DEFAULT; a website id of this workspace for that website's OVERRIDE (404 for a site of another workspace). Resolution at checkout: the website's complete override, else the workspace default."
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "plan_feature_unavailable (online_payments) or missing permission"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/ecommerce/payment-methods/order": {
      "put": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Reorder payment methods",
        "operationId": "ecommercePaymentMethodsOrder",
        "description": "Display order of the checkout list. Needs settings.manage (credentials are secrets).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "order"
                ],
                "properties": {
                  "order": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "plan_feature_unavailable (online_payments) or missing permission"
          },
          "422": {
            "description": "Validation error"
          }
        },
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Scope: omit for the workspace DEFAULT; a website id of this workspace for that website's OVERRIDE (404 for a site of another workspace). Resolution at checkout: the website's complete override, else the workspace default."
          }
        ]
      }
    },
    "/ecommerce/payment-methods/expiry": {
      "put": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Set unpaid-order expiry",
        "operationId": "ecommercePaymentMethodsExpiry",
        "description": "`unpaid_expiry_minutes` (30–1440, online gateways) and `bank_transfer_expiry_hours` (0–720, 0 = never). Unpaid orders are cancelled by `shop:expire-unpaid-orders` (every 5 min) and their stock released. Needs settings.manage (credentials are secrets).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "unpaid_expiry_minutes": {
                    "type": "integer"
                  },
                  "bank_transfer_expiry_hours": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "plan_feature_unavailable (online_payments) or missing permission"
          },
          "422": {
            "description": "Validation error"
          }
        },
        "parameters": [
          {
            "name": "website_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Scope: omit for the workspace DEFAULT; a website id of this workspace for that website's OVERRIDE (404 for a site of another workspace). Resolution at checkout: the website's complete override, else the workspace default."
          }
        ]
      }
    },
    "/ecommerce/orders/{order}/mark-paid": {
      "post": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Mark an offline order as paid",
        "operationId": "ecommerceOrderMarkPaid",
        "description": "Bank transfer / cash on delivery only (online-gateway orders are confirmed by the provider). Takes stock if it was not reserved yet, records payment state, adds a timeline event.",
        "parameters": [
          {
            "name": "order",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "note": {
                    "type": "string",
                    "maxLength": 300
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "plan_feature_unavailable (online_payments) or missing permission"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/ecommerce/orders/{order}/refund": {
      "post": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Refund through the payment provider",
        "operationId": "ecommerceOrderRefund",
        "description": "Stripe, PayPal, SSLCommerz and bKash (adapter `refund`). Full when `amount` is omitted; the amount must not exceed what is left. Throttled 20/min. Always uses the credentials the payment was started with (order `payment_credential_id` snapshot: the website override or the workspace default), even if settings changed since.",
        "parameters": [
          {
            "name": "order",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "plan_feature_unavailable (online_payments) or missing permission"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    },
    "/ecommerce/payment-methods/{gateway}/override": {
      "delete": {
        "tags": [
          "Ecommerce"
        ],
        "summary": "Use workspace default (reset a website override)",
        "operationId": "ecommercePaymentMethodResetOverride",
        "description": "Removes a website's own setting so it follows the workspace default again. `gateway` is a method key (`cod`, `bank_transfer`, `stripe`, …) or `order` / `expiry` for the display order / expiry windows. `website_id` is required (422 without). A credential row that past payments were made with is retired (kept, unused, never offered) so refunds keep using the credentials of the original payment. Needs settings.manage.",
        "parameters": [
          {
            "name": "gateway",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "cod",
                "bank_transfer",
                "stripe",
                "paypal",
                "sslcommerz",
                "bkash",
                "order",
                "expiry"
              ]
            }
          },
          {
            "name": "website_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Scope: omit for the workspace DEFAULT; a website id of this workspace for that website's OVERRIDE (404 for a site of another workspace). Resolution at checkout: the website's complete override, else the workspace default."
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "403": {
            "description": "missing permission"
          },
          "404": {
            "description": "unknown website / method"
          },
          "422": {
            "description": "website_id missing"
          }
        }
      }
    },
    "/websites/{website}/design-revision": {
      "get": {
        "tags": [
          "Collaboration"
        ],
        "summary": "Brand kit / navigation / settings revision (poll)",
        "description": "ETag + `If-None-Match` -> 304 while unchanged. Throttled 120/min.",
        "operationId": "getDesignRevision",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WebsiteIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "{data:{website_id,revision,updated_by,updated_at}}"
          },
          "304": {
            "description": "Unchanged"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Sanctum personal access token",
        "description": "A personal API token created from Settings → Account → API tokens, or via POST /account/api-tokens."
      }
    },
    "parameters": {
      "WorkspaceHeader": {
        "name": "X-Workspace-Id",
        "in": "header",
        "required": false,
        "schema": {
          "type": "integer"
        },
        "description": "The workspace this request applies to. Falls back to the `?workspace=` query parameter, then the user's last-active workspace, then their first workspace. Required in practice for any token owner who belongs to more than one workspace."
      },
      "WebsiteIdPath": {
        "name": "website",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "LeadIdPath": {
        "name": "lead",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "FormIdPath": {
        "name": "form",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "PostIdPath": {
        "name": "post",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "MediaIdPath": {
        "name": "media",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "CommentIdPath": {
        "name": "comment",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "WebhookIdPath": {
        "name": "webhook",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "ModuleItemIdPath": {
        "name": "item",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer"
        }
      },
      "ModuleKeyPath": {
        "name": "module",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$"
        },
        "description": "A module key from the registry, e.g. `restaurant`, `real_estate`."
      },
      "EntityKeyPath": {
        "name": "entity",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$"
        },
        "description": "An entity key within the module, e.g. `dish`, `property`."
      },
      "CollectionSlugPath": {
        "name": "slug",
        "in": "path",
        "required": true,
        "description": "Collection slug (^[a-z][a-z0-9_]{0,39}$).",
        "schema": {
          "type": "string"
        }
      },
      "RecordIdPath": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid bearer token.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "message": "Unauthenticated."
            }
          }
        }
      },
      "Forbidden": {
        "description": "Authenticated, but missing the required permission or plan feature, or not a member of the resolved workspace.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found, or belongs to a different workspace.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ValidationError": {
        "description": "Validation failed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ValidationErrorResponse"
            }
          }
        }
      },
      "Deleted": {
        "description": "OK",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Message"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message"
        ]
      },
      "Message": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message"
        ]
      },
      "ValidationErrorResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      },
      "PaginationLinks": {
        "type": "object",
        "properties": {
          "first": {
            "type": "string",
            "nullable": true
          },
          "last": {
            "type": "string",
            "nullable": true
          },
          "prev": {
            "type": "string",
            "nullable": true
          },
          "next": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PaginationMeta": {
        "type": "object",
        "properties": {
          "current_page": {
            "type": "integer"
          },
          "from": {
            "type": "integer",
            "nullable": true
          },
          "last_page": {
            "type": "integer"
          },
          "path": {
            "type": "string"
          },
          "per_page": {
            "type": "integer"
          },
          "to": {
            "type": "integer",
            "nullable": true
          },
          "total": {
            "type": "integer"
          }
        }
      },
      "ApiToken": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "abilities": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "*"
            ]
          },
          "last_used_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "avatar": {
            "type": "string",
            "nullable": true
          },
          "avatar_url": {
            "type": "string",
            "nullable": true
          },
          "locale": {
            "type": "string",
            "nullable": true
          },
          "timezone": {
            "type": "string",
            "nullable": true
          },
          "is_super_admin": {
            "type": "boolean"
          },
          "email_verified_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "two_factor_enabled": {
            "type": "boolean"
          },
          "google_connected": {
            "type": "boolean"
          },
          "current_workspace_id": {
            "type": "integer",
            "nullable": true
          },
          "last_login_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Workspace": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "logo": {
            "type": "string",
            "nullable": true
          },
          "owner_id": {
            "type": "integer"
          },
          "is_owner": {
            "type": "boolean"
          },
          "settings": {
            "type": "object",
            "additionalProperties": true
          },
          "suspended_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "members_count": {
            "type": "integer",
            "nullable": true
          },
          "websites_count": {
            "type": "integer",
            "nullable": true
          },
          "plan": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Me": {
        "type": "object",
        "properties": {
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "workspaces": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Workspace"
            }
          },
          "current_workspace": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Workspace"
              }
            ],
            "nullable": true
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "website.create",
              "leads.manage"
            ]
          },
          "plan": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "credits": {
            "type": "object",
            "nullable": true,
            "properties": {
              "balance": {
                "type": "number"
              },
              "wallet": {
                "type": "object",
                "properties": {
                  "subscription_credits": {
                    "type": "number"
                  },
                  "purchased_credits": {
                    "type": "number"
                  },
                  "period_resets_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "WebsiteBase": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "workspace_id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "subdomain": {
            "type": "string"
          },
          "website_type": {
            "type": "string",
            "nullable": true
          },
          "business_description": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "published",
              "maintenance",
              "unpublished"
            ]
          },
          "default_locale": {
            "type": "string"
          },
          "locales": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "template_id": {
            "type": "integer",
            "nullable": true
          },
          "client_id": {
            "type": "integer",
            "nullable": true
          },
          "client": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "has_unpublished_changes": {
            "type": "boolean"
          },
          "thumbnail": {
            "type": "string",
            "nullable": true
          },
          "urls": {
            "type": "object",
            "properties": {
              "live": {
                "type": "string"
              },
              "subdomain": {
                "type": "string"
              },
              "preview": {
                "type": "string"
              }
            }
          },
          "preview_protected": {
            "type": "boolean"
          },
          "published_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "last_edited_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "pages_count": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "WebsiteDetailed": {
        "description": "The shape returned by show/store/update/duplicate. The list endpoint returns WebsiteBase without brand_kit/navigation/settings/blueprint/pages/domains.",
        "allOf": [
          {
            "$ref": "#/components/schemas/WebsiteBase"
          },
          {
            "type": "object",
            "properties": {
              "brand_kit": {
                "type": "object",
                "nullable": true,
                "additionalProperties": true
              },
              "navigation": {
                "type": "object",
                "nullable": true,
                "additionalProperties": true
              },
              "settings": {
                "type": "object",
                "nullable": true,
                "additionalProperties": true
              },
              "blueprint": {
                "type": "object",
                "nullable": true,
                "additionalProperties": true
              },
              "pages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "domains": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "domain": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "ssl_status": {
                      "type": "string"
                    },
                    "is_primary": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        ]
      },
      "PaginatedWebsites": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebsiteBase"
            }
          },
          "links": {
            "$ref": "#/components/schemas/PaginationLinks"
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "WebsiteCreateInput": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "website_type": {
            "type": "string",
            "maxLength": 40,
            "nullable": true
          },
          "template_id": {
            "type": "integer",
            "nullable": true,
            "description": "Omit to have Buildora AI-generate the site instead of starting from a template."
          },
          "business_description": {
            "type": "string",
            "maxLength": 5000,
            "nullable": true
          },
          "default_locale": {
            "type": "string",
            "maxLength": 10,
            "nullable": true
          }
        }
      },
      "WebsiteUpdateInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "brand_kit": {
            "type": "object",
            "additionalProperties": true,
            "description": "Partial merge; recognised keys include radius (none|sm|md|lg|full), mode (light|dark), spacing (compact|normal|relaxed)."
          },
          "navigation": {
            "type": "object",
            "additionalProperties": true
          },
          "settings": {
            "type": "object",
            "additionalProperties": true,
            "description": "Top-level keys are replaced as a whole. SEO / tracking / custom-code / 404 keys are documented in `SiteSeoSettings`."
          },
          "default_locale": {
            "type": "string",
            "maxLength": 10
          },
          "locales": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 10
            },
            "maxItems": 20
          }
        }
      },
      "Lead": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "website_id": {
            "type": "integer",
            "nullable": true
          },
          "form_id": {
            "type": "integer",
            "nullable": true
          },
          "source": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "stage": {
            "type": "string",
            "enum": [
              "new",
              "contacted",
              "qualified",
              "converted",
              "closed"
            ]
          },
          "assigned_to": {
            "type": "integer",
            "nullable": true
          },
          "assignee": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "avatar": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "website": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "form": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "submitted_data": {
            "type": "object",
            "additionalProperties": true
          },
          "utm": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "referrer": {
            "type": "string",
            "nullable": true
          },
          "notes_count": {
            "type": "integer"
          },
          "last_activity_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "LeadDetailed": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Lead"
          },
          {
            "type": "object",
            "properties": {
              "notes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/LeadNote"
                }
              },
              "activities": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/LeadActivity"
                }
              },
              "submission": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/FormSubmission"
                  }
                ],
                "nullable": true
              }
            }
          }
        ]
      },
      "PaginatedLeads": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Lead"
            }
          },
          "links": {
            "$ref": "#/components/schemas/PaginationLinks"
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "LeadNote": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "lead_id": {
            "type": "integer"
          },
          "body": {
            "type": "string"
          },
          "user": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "avatar": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "user_id": {
            "type": "integer",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "LeadActivity": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "type": {
            "type": "string"
          },
          "meta": {
            "type": "object",
            "additionalProperties": true
          },
          "user": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "user_id": {
            "type": "integer",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "LeadCreateInput": {
        "type": "object",
        "description": "At least one of name, email or phone is required.",
        "properties": {
          "website_id": {
            "type": "integer",
            "nullable": true
          },
          "name": {
            "type": "string",
            "maxLength": 200,
            "nullable": true
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 255,
            "nullable": true
          },
          "phone": {
            "type": "string",
            "maxLength": 60,
            "nullable": true
          },
          "stage": {
            "type": "string",
            "enum": [
              "new",
              "contacted",
              "qualified",
              "converted",
              "closed"
            ],
            "nullable": true
          },
          "assigned_to": {
            "type": "integer",
            "nullable": true
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 40
            },
            "maxItems": 30
          },
          "data": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          }
        }
      },
      "LeadUpdateInput": {
        "type": "object",
        "properties": {
          "stage": {
            "type": "string",
            "enum": [
              "new",
              "contacted",
              "qualified",
              "converted",
              "closed"
            ]
          },
          "assigned_to": {
            "type": "integer",
            "nullable": true
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 40
            },
            "maxItems": 30,
            "nullable": true
          },
          "name": {
            "type": "string",
            "maxLength": 200,
            "nullable": true
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 255,
            "nullable": true
          },
          "phone": {
            "type": "string",
            "maxLength": 60,
            "nullable": true
          }
        }
      },
      "LeadBulkInput": {
        "type": "object",
        "required": [
          "ids",
          "action"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "minItems": 1,
            "maxItems": 500
          },
          "action": {
            "type": "string",
            "enum": [
              "stage",
              "assign",
              "tag",
              "delete"
            ]
          },
          "stage": {
            "type": "string",
            "enum": [
              "new",
              "contacted",
              "qualified",
              "converted",
              "closed"
            ],
            "description": "Required when action=stage."
          },
          "assigned_to": {
            "type": "integer",
            "nullable": true,
            "description": "Used when action=assign."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 40
            },
            "description": "Required when action=tag."
          }
        }
      },
      "LeadStats": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer"
          },
          "stages": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            },
            "example": {
              "new": 12,
              "contacted": 5,
              "qualified": 3,
              "converted": 8,
              "closed": 2
            }
          },
          "new_this_week": {
            "type": "integer"
          },
          "new_last_week": {
            "type": "integer"
          },
          "conversion_rate": {
            "type": "number",
            "description": "Percentage of all leads that reached `converted`."
          },
          "win_rate": {
            "type": "number",
            "description": "Percentage of decided leads (converted + closed) that were `converted`."
          },
          "unassigned": {
            "type": "integer"
          }
        }
      },
      "Form": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "website_id": {
            "type": "integer"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "settings": {
            "type": "object",
            "additionalProperties": true
          },
          "submissions_count": {
            "type": "integer"
          },
          "action": {
            "type": "string",
            "description": "The absolute submit URL for the public form endpoint."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FormCreateInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120,
            "nullable": true
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "maxItems": 100,
            "nullable": true
          },
          "settings": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          }
        }
      },
      "FormUpdateInput": {
        "$ref": "#/components/schemas/FormCreateInput"
      },
      "FormSubmission": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "form_id": {
            "type": "integer"
          },
          "website_id": {
            "type": "integer"
          },
          "lead_id": {
            "type": "integer",
            "nullable": true
          },
          "page_path": {
            "type": "string",
            "nullable": true
          },
          "submitted_data": {
            "type": "object",
            "additionalProperties": true
          },
          "files": {
            "type": "object",
            "additionalProperties": true
          },
          "referrer": {
            "type": "string",
            "nullable": true
          },
          "utm": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "user_agent": {
            "type": "string",
            "nullable": true
          },
          "lead": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "stage": {
                "type": "string"
              },
              "name": {
                "type": "string",
                "nullable": true
              },
              "email": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PaginatedFormSubmissions": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FormSubmission"
            }
          },
          "links": {
            "$ref": "#/components/schemas/PaginationLinks"
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "BlogPostBase": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "website_id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "excerpt": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "published",
              "scheduled"
            ]
          },
          "published_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "is_scheduled": {
            "type": "boolean"
          },
          "featured_image": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "url": {
                "type": "string"
              },
              "alt": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "author": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "avatar_url": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer"
                },
                "name": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                }
              }
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer"
                },
                "name": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                }
              }
            }
          },
          "seo": {
            "type": "object",
            "additionalProperties": true
          },
          "locale": {
            "type": "string",
            "nullable": true
          },
          "reading_time": {
            "type": "integer"
          },
          "word_count": {
            "type": "integer"
          },
          "view_count": {
            "type": "integer"
          },
          "url": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BlogPostFull": {
        "description": "Returned by show/store/update/publish/unpublish/duplicate. The list endpoint returns BlogPostBase without content/translations.",
        "allOf": [
          {
            "$ref": "#/components/schemas/BlogPostBase"
          },
          {
            "type": "object",
            "properties": {
              "content": {
                "type": "string"
              },
              "translations": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        ]
      },
      "PaginatedBlogPosts": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlogPostBase"
            }
          },
          "links": {
            "$ref": "#/components/schemas/PaginationLinks"
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "BlogPostCreateInput": {
        "type": "object",
        "required": [
          "title"
        ],
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 200
          },
          "slug": {
            "type": "string",
            "maxLength": 200,
            "nullable": true
          },
          "content": {
            "type": "string",
            "maxLength": 300000,
            "nullable": true
          },
          "excerpt": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "featured_image_id": {
            "type": "integer",
            "nullable": true,
            "description": "Must reference an existing media item."
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "published",
              "scheduled"
            ],
            "nullable": true
          },
          "published_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Required to be in the future when status=scheduled."
          },
          "category_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "maxItems": 20
          },
          "tag_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "maxItems": 30
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 60
            },
            "maxItems": 30,
            "description": "Tag names; new tags are created as needed."
          },
          "seo": {
            "type": "object",
            "nullable": true,
            "properties": {
              "title": {
                "type": "string",
                "maxLength": 120,
                "nullable": true
              },
              "description": {
                "type": "string",
                "maxLength": 320,
                "nullable": true
              },
              "og_image": {
                "type": "string",
                "maxLength": 2048,
                "nullable": true
              },
              "canonical": {
                "type": "string",
                "maxLength": 2048,
                "nullable": true
              },
              "noindex": {
                "type": "boolean",
                "nullable": true
              }
            }
          },
          "author_id": {
            "type": "integer",
            "nullable": true
          },
          "locale": {
            "type": "string",
            "maxLength": 10,
            "nullable": true
          },
          "translations": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true,
            "description": "Per-locale overrides, e.g. { \"es\": { \"title\": \"...\", \"content\": \"...\", \"excerpt\": \"...\", \"seo\": {...} } }."
          }
        }
      },
      "BlogPostUpdateInput": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BlogPostCreateInput"
          }
        ],
        "description": "Same fields as create, but every field (including title) is optional."
      },
      "BlogCategory": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "parent_id": {
            "type": "integer",
            "nullable": true
          },
          "sort_order": {
            "type": "integer"
          },
          "post_count": {
            "type": "integer"
          }
        }
      },
      "BlogCategoryInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120,
            "description": "Required when creating."
          },
          "slug": {
            "type": "string",
            "maxLength": 120,
            "nullable": true
          },
          "description": {
            "type": "string",
            "maxLength": 2000,
            "nullable": true
          },
          "parent_id": {
            "type": "integer",
            "nullable": true
          },
          "sort_order": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000,
            "nullable": true
          }
        }
      },
      "BlogTag": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "post_count": {
            "type": "integer"
          }
        }
      },
      "BlogTagInput": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 60
          }
        }
      },
      "BlogSettings": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "base_path": {
            "type": "string",
            "enum": [
              "blog",
              "news",
              "articles",
              "journal",
              "insights",
              "posts",
              "stories",
              "updates",
              "magazine",
              "resources",
              "press"
            ]
          },
          "posts_per_page": {
            "type": "integer"
          },
          "show_author": {
            "type": "boolean"
          },
          "show_dates": {
            "type": "boolean"
          },
          "show_reading_time": {
            "type": "boolean"
          },
          "list_layout": {
            "type": "string",
            "enum": [
              "grid-2",
              "grid-3",
              "grid-4",
              "list"
            ]
          },
          "public_url": {
            "type": "string"
          },
          "base_path_options": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "list_layout_options": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "BlogSettingsUpdateInput": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "base_path": {
            "type": "string",
            "enum": [
              "blog",
              "news",
              "articles",
              "journal",
              "insights",
              "posts",
              "stories",
              "updates",
              "magazine",
              "resources",
              "press"
            ]
          },
          "posts_per_page": {
            "type": "integer",
            "minimum": 1,
            "maximum": 50
          },
          "show_author": {
            "type": "boolean"
          },
          "show_dates": {
            "type": "boolean"
          },
          "show_reading_time": {
            "type": "boolean"
          },
          "list_layout": {
            "type": "string",
            "enum": [
              "grid-2",
              "grid-3",
              "grid-4",
              "list"
            ]
          }
        }
      },
      "BlogStats": {
        "type": "object",
        "properties": {
          "posts": {
            "type": "integer"
          },
          "published": {
            "type": "integer"
          },
          "drafts": {
            "type": "integer"
          },
          "scheduled": {
            "type": "integer"
          },
          "views": {
            "type": "integer"
          }
        }
      },
      "Media": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "folder_id": {
            "type": "integer",
            "nullable": true
          },
          "filename": {
            "type": "string"
          },
          "mime": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "image",
              "video",
              "svg",
              "document"
            ]
          },
          "size": {
            "type": "integer",
            "description": "Bytes."
          },
          "width": {
            "type": "integer",
            "nullable": true
          },
          "height": {
            "type": "integer",
            "nullable": true
          },
          "alt": {
            "type": "string",
            "nullable": true
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "stock",
              "ai"
            ],
            "nullable": true
          },
          "disk": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "variants": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Map of variant key (e.g. w400, webp) to URL."
          },
          "srcset": {
            "type": "string",
            "nullable": true
          },
          "uploaded_by": {
            "type": "integer",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PaginatedMedia": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Media"
            }
          },
          "links": {
            "$ref": "#/components/schemas/PaginationLinks"
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "MediaFromUrlInput": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "filename": {
            "type": "string",
            "maxLength": 200,
            "nullable": true
          },
          "folder_id": {
            "type": "integer",
            "nullable": true
          },
          "alt": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 40
            }
          },
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "stock",
              "ai"
            ],
            "nullable": true
          }
        }
      },
      "MediaUpdateInput": {
        "type": "object",
        "properties": {
          "alt": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "filename": {
            "type": "string",
            "maxLength": 200
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 40
            },
            "nullable": true
          },
          "folder_id": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "MediaCropInput": {
        "type": "object",
        "required": [
          "x",
          "y",
          "w",
          "h"
        ],
        "properties": {
          "x": {
            "type": "integer",
            "minimum": 0,
            "description": "Crop origin X, in pixels of the original image."
          },
          "y": {
            "type": "integer",
            "minimum": 0,
            "description": "Crop origin Y, in pixels of the original image."
          },
          "w": {
            "type": "integer",
            "minimum": 1,
            "description": "Crop width in pixels."
          },
          "h": {
            "type": "integer",
            "minimum": 1,
            "description": "Crop height in pixels."
          }
        }
      },
      "MediaFolder": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "parent_id": {
            "type": "integer",
            "nullable": true
          },
          "media_count": {
            "type": "integer",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MediaFolderTreeNode": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "parent_id": {
            "type": "integer",
            "nullable": true
          },
          "media_count": {
            "type": "integer"
          },
          "children": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MediaFolderTreeNode"
            }
          }
        }
      },
      "MediaFolderInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "description": "Required when creating."
          },
          "parent_id": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "ModuleOverview": {
        "type": "object",
        "properties": {
          "modules": {
            "type": "object",
            "additionalProperties": true,
            "description": "The full module/entity registry (keys, labels, field schemas)."
          },
          "enabled": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "suggested": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Modules suggested for this site's website_type, not yet enabled."
          },
          "settings": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "Per-module settings, keyed by module key."
          },
          "counts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            },
            "description": "Item counts keyed by \"module.entity\", e.g. { \"restaurant.dish\": 12 }."
          },
          "plan_enabled": {
            "type": "boolean",
            "description": "Whether the workspace's plan includes the business_modules feature."
          }
        }
      },
      "ModulesUpdateInput": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Full replacement list of enabled module keys."
          },
          "settings": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": {
                "type": [
                  "string",
                  "number",
                  "boolean",
                  "null"
                ]
              }
            },
            "description": "Per-module settings; each value must be a simple scalar."
          }
        }
      },
      "ModuleItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "website_id": {
            "type": "integer"
          },
          "module": {
            "type": "string"
          },
          "entity": {
            "type": "string"
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "slug": {
            "type": "string",
            "nullable": true
          },
          "path": {
            "type": "string",
            "nullable": true,
            "description": "The public site path this item renders at, if any."
          },
          "url": {
            "type": "string",
            "nullable": true
          },
          "data": {
            "type": "object",
            "additionalProperties": true,
            "description": "Entity-specific fields, defined by the module's schema in config/modules.php."
          },
          "locale": {
            "type": "string",
            "nullable": true
          },
          "translations": {
            "type": "object",
            "additionalProperties": true
          },
          "status": {
            "type": "string"
          },
          "featured": {
            "type": "boolean"
          },
          "sort_order": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PaginatedModuleItems": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ModuleItem"
            }
          },
          "links": {
            "$ref": "#/components/schemas/PaginationLinks"
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "ModuleItemInput": {
        "type": "object",
        "description": "Field rules are generated per entity from config/modules.php. Common fields shown; the entity-specific payload lives under `data`.",
        "properties": {
          "data": {
            "type": "object",
            "additionalProperties": true,
            "description": "Entity-specific field values — see the entity's schema under GET /websites/{website}/modules, or an existing item's `data`."
          },
          "status": {
            "type": "string"
          },
          "featured": {
            "type": "boolean"
          },
          "sort_order": {
            "type": "integer"
          },
          "locale": {
            "type": "string",
            "maxLength": 10,
            "nullable": true
          },
          "translations": {
            "type": "object",
            "nullable": true,
            "additionalProperties": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string",
                  "maxLength": 255,
                  "nullable": true
                },
                "data": {
                  "type": "object",
                  "additionalProperties": true,
                  "nullable": true
                }
              }
            }
          }
        }
      },
      "Comment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "website_id": {
            "type": "integer"
          },
          "page_id": {
            "type": "integer",
            "nullable": true
          },
          "page_name": {
            "type": "string",
            "nullable": true
          },
          "block_id": {
            "type": "string",
            "nullable": true
          },
          "parent_id": {
            "type": "integer",
            "nullable": true
          },
          "body": {
            "type": "string"
          },
          "mentions": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "user": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "avatar_url": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "user_id": {
            "type": "integer",
            "nullable": true
          },
          "resolved": {
            "type": "boolean"
          },
          "resolved_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "resolved_by": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "replies_count": {
            "type": "integer",
            "nullable": true
          },
          "replies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Comment"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PaginatedComments": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Comment"
            }
          },
          "links": {
            "$ref": "#/components/schemas/PaginationLinks"
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "CommentCreateInput": {
        "type": "object",
        "required": [
          "body"
        ],
        "properties": {
          "page_id": {
            "type": "integer",
            "nullable": true
          },
          "block_id": {
            "type": "string",
            "maxLength": 64,
            "nullable": true,
            "description": "Pattern: ^[\\w\\-:.]+$"
          },
          "parent_id": {
            "type": "integer",
            "nullable": true,
            "description": "Set to reply within an existing thread."
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 5000
          },
          "mentions": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "maxItems": 20,
            "description": "User ids mentioned in the comment."
          }
        }
      },
      "CommentsSummary": {
        "type": "object",
        "properties": {
          "open": {
            "type": "integer"
          },
          "resolved": {
            "type": "integer"
          },
          "by_page": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            },
            "description": "Open comment count keyed by page id (as a string)."
          },
          "by_block": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            },
            "description": "Open comment count keyed by block id."
          }
        }
      },
      "Webhook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "url": {
            "type": "string"
          },
          "secret": {
            "type": "string",
            "example": "whsec_ab12...",
            "description": "Used to verify delivery signatures."
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "lead.created",
                "form.submitted",
                "website.published"
              ]
            }
          },
          "active": {
            "type": "boolean"
          },
          "last_triggered_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookCreateInput": {
        "type": "object",
        "required": [
          "url",
          "events"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "enum": [
                "lead.created",
                "form.submitted",
                "website.published"
              ]
            }
          }
        }
      },
      "WebhookUpdateInput": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "enum": [
                "lead.created",
                "form.submitted",
                "website.published"
              ]
            }
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "WebhookDelivery": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "event": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "response_code": {
            "type": "integer",
            "nullable": true
          },
          "response_body": {
            "type": "string",
            "nullable": true
          },
          "error": {
            "type": "string",
            "nullable": true
          },
          "duration_ms": {
            "type": "integer",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DataStore": {
        "type": "object",
        "description": "Password is never returned. host/port/database/username are null for sqlite.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "engine": {
            "type": "string",
            "enum": [
              "sqlite",
              "mysql"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "managed",
              "external"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "active",
              "failed",
              "suspended"
            ]
          },
          "last_error": {
            "type": "string",
            "nullable": true
          },
          "host": {
            "type": "string",
            "nullable": true
          },
          "port": {
            "type": "integer",
            "nullable": true
          },
          "database": {
            "type": "string",
            "nullable": true
          },
          "username": {
            "type": "string",
            "nullable": true
          },
          "size_bytes": {
            "type": "integer"
          },
          "collections_count": {
            "type": "integer"
          },
          "limits": {
            "type": "object",
            "description": "-1 = unlimited",
            "properties": {
              "collections": {
                "type": "integer"
              },
              "records": {
                "type": "integer"
              },
              "storage_mb": {
                "type": "integer"
              }
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "collections": {
                "type": "integer"
              },
              "records": {
                "type": "integer"
              },
              "storage_mb": {
                "type": "number"
              }
            }
          },
          "public_base_url": {
            "type": "string"
          }
        }
      },
      "DataStoreInput": {
        "type": "object",
        "required": [
          "engine"
        ],
        "properties": {
          "engine": {
            "type": "string",
            "enum": [
              "sqlite",
              "mysql"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "managed",
              "external"
            ],
            "default": "managed"
          },
          "host": {
            "type": "string"
          },
          "port": {
            "type": "integer"
          },
          "database": {
            "type": "string"
          },
          "username": {
            "type": "string"
          },
          "password": {
            "type": "string"
          }
        }
      },
      "DataField": {
        "type": "object",
        "required": [
          "key",
          "type"
        ],
        "properties": {
          "key": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "long_text",
              "integer",
              "number",
              "boolean",
              "date",
              "datetime",
              "email",
              "url",
              "select",
              "json",
              "image"
            ]
          },
          "required": {
            "type": "boolean"
          },
          "unique": {
            "type": "boolean"
          },
          "default": {},
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "min": {
            "type": "number"
          },
          "max": {
            "type": "number"
          },
          "hidden": {
            "type": "boolean"
          }
        }
      },
      "DataCollection": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataField"
            }
          },
          "access": {
            "type": "object",
            "properties": {
              "read": {
                "type": "string",
                "enum": [
                  "private",
                  "public"
                ]
              },
              "create": {
                "type": "string",
                "enum": [
                  "private",
                  "public"
                ]
              }
            }
          },
          "records_count": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "detail_page": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DataDetailPage"
              }
            ],
            "nullable": true
          }
        }
      },
      "DataCollectionInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataField"
            }
          },
          "access": {
            "$ref": "#/components/schemas/DataCollection/properties/access"
          },
          "detail_page": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DataDetailPage"
              }
            ],
            "nullable": true
          }
        }
      },
      "DataRecord": {
        "type": "object",
        "additionalProperties": true,
        "description": "Flat record: id, one typed property per field, created_at, updated_at.",
        "properties": {
          "id": {
            "type": "integer"
          }
        }
      },
      "DataDetailPage": {
        "type": "object",
        "description": "Dynamic detail pages: published sites serve /{url_prefix}/{slug} from a record. Hidden fields are never rendered.",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "slug_field": {
            "type": "string",
            "nullable": true,
            "description": "Visible text field marked unique"
          },
          "url_prefix": {
            "type": "string",
            "description": "default = collection slug (underscores -> dashes); not a reserved word or module prefix"
          },
          "title_field": {
            "type": "string",
            "nullable": true
          },
          "description_field": {
            "type": "string",
            "nullable": true
          },
          "image_field": {
            "type": "string",
            "nullable": true
          },
          "template_page_id": {
            "type": "integer",
            "nullable": true,
            "description": "A page of the website whose published blocks (containing a data_detail block) are the template"
          },
          "template": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "object"
            },
            "description": "Alternative: a block tree; data_detail blocks inside are pointed at the record"
          }
        }
      },
      "SiteSeoSettings": {
        "type": "object",
        "description": "`settings.seo`, `settings.schema`, `settings.integrations`, `settings.custom_code`, `settings.not_found` of PATCH /websites/{website}. Top-level settings keys are replaced as a whole, so send the full sub-object.",
        "properties": {
          "seo": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "maxLength": 160,
                "description": "Home page title fallback."
              },
              "title_template": {
                "type": "string",
                "maxLength": 160,
                "example": "{page} | {site}"
              },
              "description": {
                "type": "string",
                "maxLength": 400
              },
              "ogImage": {
                "type": "string",
                "description": "Default Open Graph image (http(s) URL or /path)."
              },
              "noindex": {
                "type": "boolean",
                "description": "Noindex meta, `Disallow: /` robots.txt and an empty sitemap."
              },
              "robots": {
                "type": "string",
                "maxLength": 5000,
                "description": "Custom robots.txt body (the Sitemap line is appended)."
              },
              "twitter_site": {
                "type": "string",
                "example": "@acme"
              }
            }
          },
          "schema": {
            "type": "object",
            "description": "Organization / LocalBusiness JSON-LD.",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "Organization",
                  "LocalBusiness",
                  "Restaurant",
                  "Store",
                  "ProfessionalService",
                  "Person"
                ]
              },
              "name": {
                "type": "string"
              },
              "phone": {
                "type": "string"
              },
              "email": {
                "type": "string",
                "format": "email"
              },
              "price_range": {
                "type": "string"
              },
              "address": {
                "type": "object",
                "properties": {
                  "street": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string"
                  },
                  "region": {
                    "type": "string"
                  },
                  "postal_code": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  }
                }
              },
              "same_as": {
                "type": "array",
                "maxItems": 12,
                "items": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          },
          "integrations": {
            "type": "object",
            "description": "Tracking IDs are validated by regex; unknown formats are rejected with 422.",
            "properties": {
              "ga4": {
                "type": "string",
                "example": "G-ABCD1234"
              },
              "gtm": {
                "type": "string",
                "example": "GTM-ABC123"
              },
              "meta_pixel": {
                "type": "string",
                "example": "1234567890"
              },
              "tiktok_pixel": {
                "type": "string"
              },
              "hotjar": {
                "type": "string",
                "example": "123456"
              },
              "clarity": {
                "type": "string"
              },
              "google_site_verification": {
                "type": "string"
              },
              "bing_site_verification": {
                "type": "string"
              },
              "consent": {
                "type": "object",
                "description": "When enabled, no tracker loads until the visitor clicks Accept.",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "message": {
                    "type": "string",
                    "maxLength": 400
                  },
                  "accept_label": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "reject_label": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "policy_label": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "policy_url": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "custom_code": {
            "$ref": "#/components/schemas/CustomCode"
          },
          "not_found": {
            "type": "object",
            "properties": {
              "page_id": {
                "type": "integer",
                "nullable": true,
                "description": "Published page rendered (HTTP 404, noindex) for unknown URLs."
              },
              "title": {
                "type": "string",
                "maxLength": 120
              },
              "message": {
                "type": "string",
                "maxLength": 300
              }
            }
          }
        }
      },
      "CustomCode": {
        "type": "object",
        "description": "Raw code injected on published sites. Changing it needs the `custom_code` plan feature AND the `code.custom` permission (422 / 403 otherwise).",
        "properties": {
          "head": {
            "type": "string",
            "maxLength": 50000
          },
          "body_start": {
            "type": "string",
            "maxLength": 50000
          },
          "body_end": {
            "type": "string",
            "maxLength": 50000
          },
          "css": {
            "type": "string",
            "maxLength": 50000
          },
          "js": {
            "type": "string",
            "maxLength": 50000
          }
        }
      },
      "PageSeo": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 160
          },
          "description": {
            "type": "string",
            "maxLength": 400
          },
          "keywords": {
            "type": "string"
          },
          "canonical": {
            "type": "string",
            "description": "http(s) URL or /path"
          },
          "ogTitle": {
            "type": "string",
            "maxLength": 160
          },
          "ogDescription": {
            "type": "string",
            "maxLength": 400
          },
          "ogImage": {
            "type": "string"
          },
          "twitterCard": {
            "type": "string",
            "enum": [
              "summary",
              "summary_large_image"
            ]
          },
          "noindex": {
            "type": "boolean"
          },
          "nofollow": {
            "type": "boolean"
          }
        }
      },
      "PageSeoInput": {
        "type": "object",
        "description": "PATCH /pages/{page} body fields added by the SEO module (all optional).",
        "properties": {
          "seo": {
            "$ref": "#/components/schemas/PageSeo"
          },
          "custom_code": {
            "$ref": "#/components/schemas/CustomCode"
          }
        }
      },
      "Redirect": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "website_id": {
            "type": "integer"
          },
          "source": {
            "type": "string",
            "example": "/old-page"
          },
          "target": {
            "type": "string",
            "example": "/new-page"
          },
          "status_code": {
            "type": "integer",
            "enum": [
              301,
              302,
              307,
              308
            ]
          },
          "is_wildcard": {
            "type": "boolean"
          },
          "is_active": {
            "type": "boolean"
          },
          "hits": {
            "type": "integer"
          },
          "last_hit_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RedirectInput": {
        "type": "object",
        "required": [
          "source",
          "target"
        ],
        "properties": {
          "source": {
            "type": "string",
            "maxLength": 500,
            "description": "Site path, optionally ending in `/*` (wildcard)."
          },
          "target": {
            "type": "string",
            "maxLength": 2000,
            "description": "A path starting with a single `/` (wildcards may use `*`) or an absolute http(s) URL. javascript:, data:, `//host` and loops are rejected."
          },
          "status_code": {
            "type": "integer",
            "enum": [
              301,
              302,
              307,
              308
            ],
            "default": 301
          },
          "is_active": {
            "type": "boolean"
          }
        }
      },
      "PresenceEntry": {
        "type": "object",
        "properties": {
          "user_id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "avatar": {
            "type": "string"
          },
          "page_id": {
            "type": "integer",
            "nullable": true
          },
          "selected_block_id": {
            "type": "string",
            "nullable": true
          },
          "mode": {
            "type": "string",
            "enum": [
              "edit",
              "view"
            ]
          },
          "color": {
            "type": "string"
          },
          "last_seen": {
            "type": "string",
            "format": "date-time"
          },
          "editing_block_id": {
            "type": "string",
            "nullable": true
          },
          "panel": {
            "type": "string",
            "nullable": true,
            "description": "Design-tab section the user has open (brand_kit, navigation)"
          },
          "cursor": {
            "type": "object",
            "nullable": true,
            "description": "Pointer sample, only for people on the page_id the caller sent; null once older than 10s",
            "properties": {
              "x": {
                "type": "number",
                "description": "percent of canvas content width 0-100"
              },
              "anchor": {
                "type": "string",
                "nullable": true
              },
              "dy": {
                "type": "number",
                "description": "px from the anchor block top"
              },
              "device": {
                "type": "string",
                "enum": [
                  "desktop",
                  "tablet",
                  "mobile"
                ]
              },
              "age": {
                "type": "integer",
                "description": "seconds since sampled"
              }
            }
          }
        }
      },
      "EditConflictItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "block_id": {
            "type": "string",
            "nullable": true
          },
          "block_type": {
            "type": "string",
            "nullable": true
          },
          "kind": {
            "type": "string",
            "enum": [
              "field",
              "block",
              "order"
            ]
          },
          "label": {
            "type": "string"
          },
          "theirs": {},
          "mine": {},
          "theirs_summary": {
            "type": "string"
          },
          "mine_summary": {
            "type": "string"
          }
        }
      },
      "Resolutions": {
        "type": "array",
        "maxItems": 200,
        "items": {
          "type": "object",
          "required": [
            "path",
            "use"
          ],
          "properties": {
            "path": {
              "type": "string"
            },
            "use": {
              "type": "string",
              "enum": [
                "theirs",
                "mine"
              ]
            }
          }
        },
        "description": "Per-conflict choices; send with the same base_revision and payload that produced the 409"
      }
    }
  }
}
