openapi: 3.1.0
info:
  title: Wakato Space API
  version: 1.0.0
  description: |
    The **Wakato Space API** lets an external agent or tool (Claude Code, Cursor,
    Zapier, a partner integration, your own scripts) operate a single Wakato
    **Space** using a scoped Bearer token (a *Space API key*, `wks_live_…`).

    The **same token** works two ways:
    - **REST** — the endpoints documented here (`/functions/v1/space-api/…`).
    - **MCP** — a Model Context Protocol server at `/functions/v1/space-mcp`
      that exposes the same operations as tools to MCP clients. MCP clients
      self-discover the tools via `tools/list`; see the Quickstart to connect.

    ### Authentication
    Send the key as a Bearer token: `Authorization: Bearer wks_live_…`.
    A key is locked to exactly one Space and cannot read or write any other
    Space, the wallet (beyond read), member permissions, or other users.

    ### Scopes
    Every key grants per-domain scopes with up to three actions:
    - `read` — list / inspect
    - `write` — create / edit
    - `run` — the *consequential* action (publish a page, send an SMS, post
      socially, run an automation). Public/billable actions are deliberately
      split into `run` so you grant them explicitly.

    Each operation below notes its required scope via `x-required-scope`.
    A call without the scope returns `403`.

    ### Safety model
    - Wallet, Finance, Integrations are **read-only**. Money is never moved.
    - Secrets returns **names only** — values are never exposed.
    - Social posts and ad campaigns default to **drafts**; going live requires
      the `run` scope. Connecting new OAuth accounts is never done by a key.
servers:
  - url: https://api.wakato.io/functions/v1/space-api
    description: Production
  - url: https://pnwxrleocjbcvrrwrycq.supabase.co/functions/v1/space-api
    description: Development
security:
  - bearerAuth: []
tags:
  - name: Contacts
    description: >-
      People and companies in your space — the foundation everything else attaches to. Segment and target your contacts
      with **Audiences** and **Tags**, both managed under Contacts.
  - name: Audiences
    description: >-
      Saved segments (lists) of your **Contacts**, used to target campaigns and messages across any channel. Audiences
      are part of Contacts (managed at `/spaces/:spaceId/contacts/audiences`) — not a separate system. Each audience is
      simply a named group of contacts.
  - name: Tables
  - name: Automations
  - name: Pages
  - name: Blog
  - name: Forms
  - name: Booking Pages
  - name: Bookings
  - name: Calendar
  - name: Tasks
  - name: Assets
  - name: Social
  - name: Messaging
  - name: Documents
  - name: Whiteboards
  - name: Meet
  - name: Phone
  - name: Ads
  - name: Cloud Agents
  - name: Finance
  - name: Wallet
  - name: Integrations
  - name: Secrets
  - name: Agent Mail
  - name: Apps
paths:
  /contacts:
    get:
      tags:
        - Contacts
      summary: List contacts
      x-required-scope: contacts:read
      parameters:
        - in: query
          name: limit
          schema:
            type: integer
            default: 50
            maximum: 200
        - in: query
          name: offset
          schema:
            type: integer
            default: 0
        - in: query
          name: search
          schema:
            type: string
          description: Match name/email/company
      responses:
        '200':
          $ref: '#/components/responses/Ok'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
      description: '**Required scope:** `contacts:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/contacts" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Contacts
      summary: Create a contact
      x-required-scope: contacts:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - email
              properties:
                name:
                  type: string
                email:
                  type: string
                phone:
                  type: string
                company:
                  type: string
                line_of_work:
                  type: string
                location:
                  type: string
                bio:
                  type: string
                custom_fields:
                  type: object
      responses:
        '201':
          $ref: '#/components/responses/Created'
        '403':
          $ref: '#/components/responses/Forbidden'
      description: '**Required scope:** `contacts:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/contacts" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan",
              "email": "ada@example.io"
            }'
  /tables:
    get:
      tags:
        - Tables
      summary: List tables (record types)
      x-required-scope: tables:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/tables" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Tables
      summary: Create a table (optionally with initial columns)
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  description: Plural label
                  e.g. Invoices: null
                singular_label:
                  type: string
                slug:
                  type: string
                  description: Auto-generated and de-duplicated when omitted
                icon:
                  type: string
                color:
                  type: string
                description:
                  type: string
                title_field_key:
                  type: string
                columns:
                  type: array
                  description: Initial schema — same shape as POST /tables/{tableId}/columns
                  items:
                    type: object
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/tables" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan"
            }'
  /tables/{tableId}:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
    get:
      tags:
        - Tables
      summary: Get a table's full definition (meta + columns + views + row count)
      x-required-scope: tables:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    patch:
      tags:
        - Tables
      summary: Update table metadata (labels/icon/description; archived true/false)
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                plural_label:
                  type: string
                singular_label:
                  type: string
                slug:
                  type: string
                icon:
                  type: string
                color:
                  type: string
                description:
                  type: string
                title_field_key:
                  type: string
                archived:
                  type: boolean
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X PATCH "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
    delete:
      tags:
        - Tables
      summary: Archive a table (default) or permanently delete with ?hard=true
      x-required-scope: tables:write
      parameters:
        - in: query
          name: hard
          schema:
            type: boolean
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X DELETE "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /tables/{tableId}/rows:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
    get:
      tags:
        - Tables
      summary: List/query rows of a table
      x-required-scope: tables:read
      parameters:
        - in: query
          name: limit
          schema:
            type: integer
        - in: query
          name: offset
          schema:
            type: integer
        - in: query
          name: filters
          schema:
            type: string
          description: 'JSON array: [{"column_key","op","value"}] — ops: eq|neq|contains|gt|lt|is_empty|is_not_empty'
        - in: query
          name: sort
          schema:
            type: string
          description: 'JSON array: [{"column_key","direction"}]'
        - in: query
          name: search
          schema:
            type: string
          description: Substring match on the title column
        - in: query
          name: search_column
          schema:
            type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/rows"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Tables
      summary: Create a row
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  description: Map of column key → value
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/rows"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /tables/{tableId}/rows/bulk:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
    post:
      tags:
        - Tables
      summary: Bulk-insert up to 100 rows
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - rows
              properties:
                rows:
                  type: array
                  items:
                    type: object
                  maxItems: 100
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/rows/bulk" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "rows": []
            }'
    patch:
      tags:
        - Tables
      summary: Bulk-update up to 100 rows (merge per row)
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - updates
              properties:
                updates:
                  type: array
                  maxItems: 100
                  items:
                    type: object
                    required:
                      - row_id
                      - data
                    properties:
                      row_id:
                        type: string
                      data:
                        type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/rows/bulk" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "updates": []
            }'
  /tables/{tableId}/rows/bulk-delete:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
    post:
      tags:
        - Tables
      summary: Bulk-delete up to 100 rows by id
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - row_ids
              properties:
                row_ids:
                  type: array
                  items:
                    type: string
                  maxItems: 100
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/rows/bulk-delete"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "row_ids": []
            }'
  /tables/{tableId}/rows/{rowId}:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
      - in: path
        name: rowId
        required: true
        schema:
          type: string
    patch:
      tags:
        - Tables
      summary: Update a row (merge)
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/rows/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
    delete:
      tags:
        - Tables
      summary: Delete a row
      x-required-scope: tables:write
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X DELETE
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/rows/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /tables/{tableId}/columns:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
    get:
      tags:
        - Tables
      summary: List a table's columns (schema)
      x-required-scope: tables:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/columns" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Tables
      summary: Add a column (all field types incl. formula/lookup/rollup via field_config)
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - key
                - label
                - type
              properties:
                key:
                  type: string
                  description: snake_case
                label:
                  type: string
                type:
                  type: string
                options:
                  type: array
                reference_target:
                  type: object
                field_config:
                  type: object
                required:
                  type: boolean
                default_value: {}
                icon:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/columns" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "key": "example",
              "label": "example",
              "type": "example"
            }'
  /tables/{tableId}/columns/{columnId}:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
      - in: path
        name: columnId
        required: true
        schema:
          type: string
    patch:
      tags:
        - Tables
      summary: Update a column
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/columns/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
    delete:
      tags:
        - Tables
      summary: Delete a column (drops its data from all rows)
      x-required-scope: tables:write
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X DELETE
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/columns/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /tables/{tableId}/views:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
    get:
      tags:
        - Tables
      summary: List a table's views
      x-required-scope: tables:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/views"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Tables
      summary: Create a view (grid|kanban|gallery|calendar|dashboard)
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                type:
                  type: string
                  enum:
                    - grid
                    - kanban
                    - gallery
                    - calendar
                    - dashboard
                config:
                  type: object
                is_default:
                  type: boolean
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/views" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan"
            }'
  /tables/{tableId}/views/{viewId}:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
      - in: path
        name: viewId
        required: true
        schema:
          type: string
    get:
      tags:
        - Tables
      summary: Get one view (full config)
      x-required-scope: tables:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/views/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    patch:
      tags:
        - Tables
      summary: Update a view
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/views/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
    delete:
      tags:
        - Tables
      summary: Delete a view
      x-required-scope: tables:write
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X DELETE
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/views/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /tables/{tableId}/share-links:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
    get:
      tags:
        - Tables
      summary: List public view-only share links
      x-required-scope: tables:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/share-links" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Tables
      summary: Create a public view-only share link (returns the URL)
      x-required-scope: tables:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                view_id:
                  type: string
                  description: Share this view; defaults to the table's default view
                name:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/share-links" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /tables/{tableId}/share-links/{linkId}:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
      - in: path
        name: linkId
        required: true
        schema:
          type: string
    delete:
      tags:
        - Tables
      summary: Revoke a share link (URL stops working immediately)
      x-required-scope: tables:write
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X DELETE
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/share-links/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /tables/{tableId}/rows/{rowId}/comments:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
      - in: path
        name: rowId
        required: true
        schema:
          type: string
    get:
      tags:
        - Tables
      summary: List a row's comment thread (oldest first)
      x-required-scope: tables:read
      parameters:
        - in: query
          name: limit
          schema:
            type: integer
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/rows/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/comments"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Tables
      summary: Add a comment to a row (posted as the agent)
      x-required-scope: tables:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - body
              properties:
                body:
                  type: string
                  maxLength: 4000
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/rows/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/comments"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "body": "example"
            }'
  /tables/{tableId}/snapshots:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
    get:
      tags:
        - Tables
      summary: List Time Machine snapshots
      x-required-scope: tables:read
      parameters:
        - in: query
          name: limit
          schema:
            type: integer
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/snapshots" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Tables
      summary: Capture a named save point (schema + rows + views)
      x-required-scope: tables:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                label:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/snapshots" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /tables/{tableId}/snapshots/{snapshotId}/restore:
    parameters:
      - in: path
        name: tableId
        required: true
        schema:
          type: string
      - in: path
        name: snapshotId
        required: true
        schema:
          type: string
    post:
      tags:
        - Tables
      summary: Restore the table to a snapshot (atomic, reversible)
      x-required-scope: tables:write
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tables:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/tables/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/snapshots/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/restore"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /automations:
    get:
      tags:
        - Automations
      summary: List automations
      x-required-scope: automations:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `automations:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/automations" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /automations/{id}/run:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    post:
      tags:
        - Automations
      summary: Run an automation manually (consequential)
      description: |
        **Required scope:** `automations:run`

        Triggers the automation as a `manual` run. The automation must be
        enabled and belong to this Space. Returns `202` — the run executes
        asynchronously via the automation engine.
      x-required-scope: automations:run
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                payload:
                  type: object
                  description: Merge-tag payload available to the automation's actions
      responses:
        '202':
          $ref: '#/components/responses/Accepted'
        '403':
          $ref: '#/components/responses/Forbidden'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/automations/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/run" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /sites:
    get:
      tags:
        - Pages
      summary: List sites
      description: |
        **Required scope:** `pages:read`

        A site groups pages into ONE website with shared, platform-injected
        navigation. List existing sites before creating one to avoid
        duplicates.
      x-required-scope: pages:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/sites" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Pages
      summary: Create a site
      description: |
        **Required scope:** `pages:write`

        Create a site, then pass its `id` as `site_id` on every
        `POST /pages` call that belongs to the same website. Required when
        building a multi-page website/funnel — pages created without
        `site_id` are standalone and not linked together. Idempotent by
        title: an existing same-title site is returned instead of
        duplicated. The first page attached becomes the site's home page.
      x-required-scope: pages:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - title
              properties:
                title:
                  type: string
                  description: Site/brand name
                description:
                  type: string
                nav_layout:
                  type: string
                  enum:
                    - top
                    - sidebar
                    - none
                logo_url:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/sites" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "title": "Launch plan"
            }'
  /pages:
    get:
      tags:
        - Pages
      summary: List pages
      x-required-scope: pages:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/pages" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Pages
      summary: Create a page
      description: |
        **Required scope:** `pages:write`

        Pass `layout_html` (a complete HTML document) to build an AI-designed
        page in one call. Any embedded form/booking page must be a real Space
        resource — references that don't resolve in this space are rejected.

        Building a multi-page website? Create a site first (`POST /sites`)
        and pass `site_id` on every page so they form one linked website —
        omit `site_id` only for an intentionally standalone page.

        **Enforced:** creating a 2nd+ standalone page within a short window
        is rejected with an error — multiple related pages must share a
        site. Pass `standalone: true` to confirm a page is an intentional
        one-off.
      x-required-scope: pages:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - title
              properties:
                title:
                  type: string
                description:
                  type: string
                layout_html:
                  type: string
                site_id:
                  type: string
                  description: Site to attach to (from POST /sites) — required for multi-page websites
                standalone:
                  type: boolean
                  description: Confirm this page is an intentional one-off — required for a 2nd+ standalone page in a short window
      responses:
        '201':
          $ref: '#/components/responses/Created'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/pages" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "title": "Launch plan"
            }'
  /pages/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Pages
      summary: Get a page (incl. layout_html)
      x-required-scope: pages:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/pages/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    patch:
      tags:
        - Pages
      summary: Update a page
      x-required-scope: pages:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                description:
                  type: string
                layout_html:
                  type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X PATCH "https://api.wakato.io/functions/v1/space-api/pages/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /pages/{id}/publish:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    post:
      tags:
        - Pages
      summary: Publish (or unpublish) a page
      x-required-scope: pages:run
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                published_slug:
                  type: string
                publish:
                  type: boolean
                  description: false to unpublish
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:run`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/pages/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/publish" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /forms:
    get:
      tags:
        - Forms
      summary: List forms
      x-required-scope: forms:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `forms:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/forms" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Forms
      summary: Create a form (active immediately)
      x-required-scope: forms:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                description:
                  type: string
                success_message:
                  type: string
                redirect_url:
                  type: string
                template:
                  type: string
                  description: contact | lead_capture | event_rsvp | nps | booking_intake | quiz | job_application
                fields:
                  type: array
                  items:
                    type: object
                    description: '{ key, label, type, required?, placeholder?, options? }'
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `forms:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/forms" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan"
            }'
  /forms/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Forms
      summary: Get a form (incl. fields)
      x-required-scope: forms:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `forms:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/forms/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    patch:
      tags:
        - Forms
      summary: Update a form (fields is a FULL replacement — read, modify, write back)
      x-required-scope: forms:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  type: string
                status:
                  type: string
                  enum:
                    - draft
                    - active
                    - paused
                    - archived
                success_message:
                  type: string
                redirect_url:
                  type: string
                fields:
                  type: array
                  items:
                    type: object
                    description: '{ key, label, type, required?, placeholder?, options? }'
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `forms:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X PATCH "https://api.wakato.io/functions/v1/space-api/forms/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
    delete:
      tags:
        - Forms
      summary: Permanently delete a form (refused while attached to a booking page)
      x-required-scope: forms:write
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `forms:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X DELETE "https://api.wakato.io/functions/v1/space-api/forms/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /forms/{id}/submissions:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Forms
      summary: List a form's submissions (answers in `data`, newest first)
      x-required-scope: forms:read
      parameters:
        - in: query
          name: status
          schema:
            type: string
            enum:
              - pending_confirmation
              - confirmed
              - expired
        - in: query
          name: since
          schema:
            type: string
            description: ISO datetime lower bound
        - in: query
          name: limit
          schema:
            type: integer
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `forms:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/forms/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/submissions" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /forms/{id}/submit:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    post:
      tags:
        - Forms
      summary: >-
        Submit the form via the SAME pipeline as the public /f page (REAL submission — validation, contact capture and
        automations all fire)
      x-required-scope: forms:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - data
              properties:
                data:
                  type: object
                  description: Answer values keyed by field key
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `forms:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/forms/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/submit" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "data": {}
            }'
  /booking-pages:
    get:
      tags:
        - Booking Pages
      summary: List booking pages
      x-required-scope: pages:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/booking-pages" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Booking Pages
      summary: Create a booking page (active immediately)
      x-required-scope: pages:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                description:
                  type: string
                booking_type:
                  type: string
                  enum:
                    - one_on_one
                    - group
                duration_minutes:
                  type: integer
                timezone:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `pages:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/booking-pages" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan"
            }'
  /booking-pages/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Booking Pages
      summary: Get a booking page
      x-required-scope: pages:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/booking-pages/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    patch:
      tags:
        - Booking Pages
      summary: Update a booking page (only the provided keys change)
      x-required-scope: pages:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  type: string
                status:
                  type: string
                  enum:
                    - draft
                    - active
                    - paused
                duration_minutes:
                  type: integer
                timezone:
                  type: string
                buffer_minutes:
                  type: integer
                min_notice_hours:
                  type: integer
                max_advance_days:
                  type: integer
                meeting_location_type:
                  type: string
                  enum:
                    - wakato_meet
                    - in_person
                    - phone_call
                    - custom_link
                meeting_location_value:
                  type: string
                form_id:
                  type: string
                  nullable: true
                  description: Attach a Space form, or null to detach
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/booking-pages/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
    delete:
      tags:
        - Booking Pages
      summary: Permanently delete a booking page (refused while upcoming confirmed bookings exist)
      x-required-scope: pages:write
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X DELETE
            "https://api.wakato.io/functions/v1/space-api/booking-pages/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /booking-pages/{id}/preview:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Booking Pages
      summary: Test the page like a guest — real bookable slots + readiness verdict
      x-required-scope: pages:read
      parameters:
        - in: query
          name: date
          schema:
            type: string
            description: YYYY-MM-DD
        - in: query
          name: days
          schema:
            type: integer
            description: Days to scan when no date given (default 14)
        - in: query
          name: timezone
          schema:
            type: string
            description: IANA zone to render slot labels in
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/booking-pages/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/preview" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /bookings:
    get:
      tags:
        - Bookings
      summary: List booked appointments (guest, start/end, status) across the space or one page
      x-required-scope: pages:read
      parameters:
        - in: query
          name: booking_page_id
          schema:
            type: string
        - in: query
          name: status
          schema:
            type: string
            enum:
              - confirmed
              - cancelled
        - in: query
          name: upcoming_only
          schema:
            type: boolean
        - in: query
          name: from
          schema:
            type: string
            description: ISO datetime
        - in: query
          name: to
          schema:
            type: string
            description: ISO datetime
        - in: query
          name: search
          schema:
            type: string
            description: Guest name or email
        - in: query
          name: limit
          schema:
            type: integer
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/bookings" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /bookings/{id}/cancel:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    post:
      tags:
        - Bookings
      summary: Cancel a booked appointment (guest is NOT auto-notified)
      x-required-scope: pages:write
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                delete_calendar_event:
                  type: boolean
                  description: Also remove the linked calendar event (default false)
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/bookings/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/cancel" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /bookings/{id}/reschedule:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    post:
      tags:
        - Bookings
      summary: Move a confirmed booking to a new slot (validated against real availability; calendar event moves too)
      x-required-scope: pages:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - new_date
                - new_start
              properties:
                new_date:
                  type: string
                  description: YYYY-MM-DD in the page's timezone
                new_start:
                  type: string
                  description: HH:MM in the page's timezone
                new_end:
                  type: string
                  description: HH:MM — derived from duration when omitted
                skip_availability_check:
                  type: boolean
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/bookings/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/reschedule" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "new_date": "2026-06-15T10:00:00Z",
              "new_start": "example"
            }'
  /calendar:
    get:
      tags:
        - Calendar
      summary: List calendar events
      x-required-scope: calendar:read
      parameters:
        - in: query
          name: start_date
          schema:
            type: string
        - in: query
          name: end_date
          schema:
            type: string
        - in: query
          name: category
          schema:
            type: string
            enum:
              - event
              - meeting
              - deadline
              - reminder
              - task
        - in: query
          name: search
          schema:
            type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `calendar:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/calendar" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Calendar
      summary: Create an event
      x-required-scope: calendar:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - title
                - start_at
              properties:
                title:
                  type: string
                start_at:
                  type: string
                  description: ISO 8601
                end_at:
                  type: string
                is_all_day:
                  type: boolean
                timezone:
                  type: string
                description:
                  type: string
                location:
                  type: string
                category:
                  type: string
                  enum:
                    - event
                    - meeting
                    - deadline
                    - reminder
                    - task
                recurrence_rule:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `calendar:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/calendar" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "title": "Launch plan",
              "start_at": "2026-06-15T10:00:00Z"
            }'
  /calendar/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    patch:
      tags:
        - Calendar
      summary: Update an event
      x-required-scope: calendar:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `calendar:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X PATCH "https://api.wakato.io/functions/v1/space-api/calendar/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
    delete:
      tags:
        - Calendar
      summary: Delete an event
      x-required-scope: calendar:write
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `calendar:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X DELETE "https://api.wakato.io/functions/v1/space-api/calendar/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /tasks:
    get:
      tags:
        - Tasks
      summary: List tasks
      x-required-scope: tasks:read
      parameters:
        - in: query
          name: status
          schema:
            type: string
            enum:
              - todo
              - in_progress
              - done
              - cancelled
              - blocked
        - in: query
          name: project_id
          schema:
            type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tasks:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/tasks" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Tasks
      summary: Create a task
      x-required-scope: tasks:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - title
              properties:
                title:
                  type: string
                description:
                  type: string
                priority:
                  type: string
                  enum:
                    - low
                    - normal
                    - high
                    - urgent
                due_at:
                  type: string
                project_id:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `tasks:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/tasks" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "title": "Launch plan"
            }'
  /tasks/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    patch:
      tags:
        - Tasks
      summary: Update a task
      x-required-scope: tasks:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tasks:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X PATCH "https://api.wakato.io/functions/v1/space-api/tasks/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /task-projects:
    get:
      tags:
        - Tasks
      summary: List task projects
      x-required-scope: tasks:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `tasks:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/task-projects" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /assets/voices:
    get:
      tags:
        - Assets
      summary: List voice assets
      x-required-scope: assets:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `assets:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/assets/voices" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /assets/documents:
    get:
      tags:
        - Assets
      summary: List document/image assets
      x-required-scope: assets:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `assets:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/assets/documents" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /assets/characters:
    get:
      tags:
        - Assets
      summary: List characters
      x-required-scope: assets:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `assets:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/assets/characters" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Assets
      summary: Create a character
      x-required-scope: assets:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                description:
                  type: string
                identity_image_url:
                  type: string
                reference_image_urls:
                  type: array
                  items:
                    type: string
                tags:
                  type: array
                  items:
                    type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `assets:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/assets/characters" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan"
            }'
  /assets/characters/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    patch:
      tags:
        - Assets
      summary: Update a character
      x-required-scope: assets:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `assets:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/assets/characters/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /social/accounts:
    get:
      tags:
        - Social
      summary: List connected social accounts
      x-required-scope: social:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `social:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/social/accounts" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /social/planners:
    get:
      tags:
        - Social
      summary: List posting planners
      x-required-scope: social:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `social:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/social/planners" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /social/analytics:
    get:
      tags:
        - Social
      summary: Get social analytics
      x-required-scope: social:read
      parameters:
        - in: query
          name: post_id
          schema:
            type: string
        - in: query
          name: platform
          schema:
            type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `social:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/social/analytics" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /social/drafts:
    post:
      tags:
        - Social
      summary: Create a DRAFT post (does not publish)
      x-required-scope: social:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - text
              properties:
                text:
                  type: string
                platforms:
                  type: array
                  items:
                    type: string
                media_urls:
                  type: array
                  items:
                    type: string
                schedule_time:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `social:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/social/drafts" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "text": "example"
            }'
  /social/publish:
    post:
      tags:
        - Social
      summary: Publish / schedule a post LIVE (consequential)
      x-required-scope: social:run
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - text
                - platforms
              properties:
                text:
                  type: string
                platforms:
                  type: array
                  items:
                    type: object
                    properties:
                      platform:
                        type: string
                      accountId:
                        type: string
                media_urls:
                  type: array
                  items:
                    type: string
                schedule_time:
                  type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `social:run`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/social/publish" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "text": "example",
              "platforms": []
            }'
  /messaging/channels:
    get:
      tags:
        - Messaging
      summary: List messaging channels
      x-required-scope: messaging:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `messaging:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/messaging/channels" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /messaging/threads:
    get:
      tags:
        - Messaging
      summary: List inbox threads
      x-required-scope: messaging:read
      parameters:
        - in: query
          name: channel_id
          schema:
            type: string
        - in: query
          name: platform
          schema:
            type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `messaging:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/messaging/threads" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /messaging/threads/{id}/messages:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Messaging
      summary: Get messages in a thread
      x-required-scope: messaging:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `messaging:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/messaging/threads/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/messages"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /messaging/threads/{id}/reply:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    post:
      tags:
        - Messaging
      summary: Reply / send a message (consequential)
      x-required-scope: messaging:run
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - content
              properties:
                content:
                  type: string
                attachments:
                  type: array
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `messaging:run`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/messaging/threads/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/reply"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "content": "example"
            }'
  /documents:
    get:
      tags:
        - Documents
      summary: List documents
      x-required-scope: documents:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `documents:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/documents" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Documents
      summary: Create a document
      x-required-scope: documents:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                content:
                  type: object
                  description: 'TipTap doc JSON: {type:''doc'',content:[]}'
                parent_id:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `documents:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/documents" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /documents/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Documents
      summary: Get a document
      x-required-scope: documents:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `documents:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/documents/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    patch:
      tags:
        - Documents
      summary: Update a document
      x-required-scope: documents:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `documents:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH "https://api.wakato.io/functions/v1/space-api/documents/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /whiteboards:
    get:
      tags:
        - Whiteboards
      summary: List whiteboards
      x-required-scope: whiteboards:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `whiteboards:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/whiteboards" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Whiteboards
      summary: Create a whiteboard
      x-required-scope: whiteboards:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `whiteboards:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/whiteboards" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /whiteboards/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Whiteboards
      summary: Get a whiteboard
      x-required-scope: whiteboards:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `whiteboards:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/whiteboards/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /meetings:
    get:
      tags:
        - Meet
      summary: List meetings
      x-required-scope: meet:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `meet:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/meetings" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Meet
      summary: Create a meeting (instant or scheduled)
      x-required-scope: meet:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - title
              properties:
                title:
                  type: string
                description:
                  type: string
                scheduled_start:
                  type: string
                  description: ISO; omit for instant
                scheduled_end:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `meet:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/meetings" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "title": "Launch plan"
            }'
  /phone/numbers:
    get:
      tags:
        - Phone
      summary: List phone numbers
      x-required-scope: phone:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `phone:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/phone/numbers" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /phone/calls:
    get:
      tags:
        - Phone
      summary: List call history
      x-required-scope: phone:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `phone:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/phone/calls" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /phone/sms:
    post:
      tags:
        - Phone
      summary: Send an SMS (consequential, billable)
      x-required-scope: phone:run
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - to
                - message
              properties:
                to:
                  type: string
                  description: E.164
                message:
                  type: string
                from:
                  type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `phone:run`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/phone/sms" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "to": "example",
              "message": "example"
            }'
  /phone/campaigns:
    get:
      tags:
        - Phone
      summary: List SMS campaigns
      x-required-scope: phone:read
      parameters:
        - in: query
          name: status
          schema:
            type: string
        - in: query
          name: limit
          schema:
            type: integer
            default: 50
            maximum: 200
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `phone:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/phone/campaigns" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Phone
      summary: Create a DRAFT SMS campaign (broadcast or drip)
      description: >-
        **Required scope:** `phone:write`


        Drafting never requires a connected phone number — the sender defaults to the space's first SMS-capable number
        when one exists, else stays null until set. Sending is a separate run-scoped action.
      x-required-scope: phone:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                campaign_type:
                  type: string
                  enum:
                    - broadcast
                    - drip
                  default: broadcast
                body:
                  type: string
                  description: Broadcast body; supports {{merge_tags}}
                from_phone_number_id:
                  type: string
                audience_id:
                  type: string
                enrollment_mode:
                  type: string
                  enum:
                    - one_shot
                    - continuous
                trigger_audience_id:
                  type: string
                opt_out_footer:
                  type: boolean
                  default: true
                steps:
                  type: array
                  description: Drip steps in order
                  items:
                    type: object
                    required:
                      - body
                    properties:
                      delay_minutes:
                        type: integer
                      body:
                        type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/phone/campaigns" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan"
            }'
  /phone/campaigns/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Phone
      summary: Get an SMS campaign (incl. drip steps)
      x-required-scope: phone:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `phone:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/phone/campaigns/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    patch:
      tags:
        - Phone
      summary: Update a draft/paused/scheduled SMS campaign
      description: |-
        **Required scope:** `phone:write`

        Passing steps REPLACES all drip steps.
      x-required-scope: phone:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/phone/campaigns/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /phone/campaigns/{id}/send:
    post:
      tags:
        - Phone
      summary: Send/start an SMS campaign (consequential, billable)
      description: >-
        **Required scope:** `phone:run`


        Broadcast: schedules the send (scheduled_at defaults to now); the scheduler delivers it. Drip: starts the
        sequence. Requires a sender number, an audience, and message content.
      x-required-scope: phone:run
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                scheduled_at:
                  type: string
                  description: ISO; omit to send ASAP
      responses:
        '202':
          $ref: '#/components/responses/Ok'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/phone/campaigns/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/send" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /phone/templates:
    get:
      tags:
        - Phone
      summary: List SMS templates
      x-required-scope: phone:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `phone:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/phone/templates" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Phone
      summary: Create an SMS template
      x-required-scope: phone:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - body
              properties:
                name:
                  type: string
                body:
                  type: string
                  description: Supports {{merge_tags}}
                variables:
                  type: array
                  items:
                    type: object
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `phone:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/phone/templates" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan",
              "body": "example"
            }'
  /phone/templates/{id}:
    patch:
      tags:
        - Phone
      summary: Update an SMS template
      x-required-scope: phone:write
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `phone:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/phone/templates/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /audiences:
    get:
      tags:
        - Audiences
      summary: List audiences
      x-required-scope: contacts:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `contacts:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/audiences" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Audiences
      summary: Create a static (list) audience
      x-required-scope: contacts:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                description:
                  type: string
                contact_ids:
                  type: array
                  items:
                    type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `contacts:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/audiences" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan"
            }'
  /audiences/{id}:
    patch:
      tags:
        - Audiences
      summary: Rename an audience or add/remove member contacts
      x-required-scope: contacts:write
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  type: string
                add_contact_ids:
                  type: array
                  items:
                    type: string
                remove_contact_ids:
                  type: array
                  items:
                    type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `contacts:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH "https://api.wakato.io/functions/v1/space-api/audiences/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /ads/accounts:
    get:
      tags:
        - Ads
      summary: List ad accounts
      x-required-scope: ads:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `ads:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/ads/accounts" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /ads/campaigns:
    get:
      tags:
        - Ads
      summary: List ad campaigns
      x-required-scope: ads:read
      parameters:
        - in: query
          name: status
          schema:
            type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `ads:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/ads/campaigns" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Ads
      summary: Create a DRAFT ad campaign (no spend)
      description: |-
        **Required scope:** `ads:write`

        Drafts only. Launching real ad spend is done by a human in the Ads Manager.
      x-required-scope: ads:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - ad_account_id
                - name
                - goal
                - budget_amount
              properties:
                ad_account_id:
                  type: string
                name:
                  type: string
                goal:
                  type: string
                  enum:
                    - engagement
                    - traffic
                    - awareness
                    - video_views
                    - lead_generation
                    - conversions
                    - app_promotion
                budget_amount:
                  type: number
                budget_type:
                  type: string
                  enum:
                    - daily
                    - lifetime
      responses:
        '201':
          $ref: '#/components/responses/Created'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/ads/campaigns" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "ad_account_id": "b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c",
              "name": "Launch plan",
              "goal": "engagement",
              "budget_amount": 1
            }'
  /ads/campaign-drafts:
    post:
      tags:
        - Ads
      summary: Design a full campaign into "Ready to launch" (no account needed)
      description: |
        **Required scope:** `ads:write`

        Create a fully-designed draft campaign that appears in Ads Manager →
        Campaigns → "Ready to launch" with a native ad preview, even when no ad
        account is connected. A human reviews and launches it (no spend). Pass
        either `ad_account_id` or `platform`. Each creative's `image_url` may be
        an image or a video URL (set `media_kind` to disambiguate).
      x-required-scope: ads:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - goal
                - budget_amount
              properties:
                name:
                  type: string
                platform:
                  type: string
                  enum:
                    - metaads
                    - googleads
                    - tiktokads
                    - linkedinads
                    - pinterestads
                    - xads
                  description: Required when ad_account_id is omitted
                ad_account_id:
                  type: string
                  description: Optional — pins the platform when supplied
                goal:
                  type: string
                  enum:
                    - engagement
                    - traffic
                    - awareness
                    - video_views
                    - lead_generation
                    - conversions
                    - app_promotion
                objective:
                  type: string
                  description: Optional platform-native objective value
                budget_amount:
                  type: number
                budget_type:
                  type: string
                  enum:
                    - daily
                    - lifetime
                schedule_start:
                  type: string
                schedule_end:
                  type: string
                audience_id:
                  type: string
                targeting:
                  type: object
                  properties:
                    age_min:
                      type: number
                    age_max:
                      type: number
                    genders:
                      type: array
                      items:
                        type: string
                        enum:
                          - male
                          - female
                          - other
                    countries:
                      type: array
                      items:
                        type: string
                      description: Country codes, e.g. ["US","GB"]
                    interests:
                      type: array
                      items:
                        type: object
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                    keywords:
                      type: array
                      items:
                        type: string
                    languages:
                      type: array
                      items:
                        type: string
                creatives:
                  type: array
                  description: One or more ad variations.
                  items:
                    type: object
                    properties:
                      headline:
                        type: string
                      body:
                        type: string
                      destination_url:
                        type: string
                      cta:
                        type: string
                      image_url:
                        type: string
                        description: Hosted image or video URL
                      media_kind:
                        type: string
                        enum:
                          - image
                          - video
      responses:
        '201':
          $ref: '#/components/responses/Created'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/ads/campaign-drafts" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan",
              "goal": "engagement",
              "budget_amount": 1
            }'
  /blog/collections:
    get:
      tags:
        - Blog
      summary: List blogs (collections)
      x-required-scope: pages:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/blog/collections" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Blog
      summary: Create a blog (collection)
      description: |
        **Required scope:** `pages:write`

        Create a blog — the real blog system, not a static page. Pass `site_id`
        (from `POST /sites`) to make it part of one website. The collection holds
        the post layout (`template_html` with `{{title}}` `{{cover_image}}`
        `{{excerpt}}` `{{body}}` `{{author}}` `{{date}}` tokens; a neutral default
        is used if omitted) — reused for every post. Idempotent by `base_slug` per
        space. Then add posts with `POST /blog/posts`.
      x-required-scope: pages:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                site_id:
                  type: string
                  description: Attach to a site so the blog is part of one website
                base_slug:
                  type: string
                  description: URL segment (default "blog")
                  unique per space: null
                template_html:
                  type: string
                  description: Custom post layout with the six tokens (neutral default if omitted)
                index_page_id:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/blog/collections" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /blog/collections/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    patch:
      tags:
        - Blog
      summary: Update a blog (rename, re-theme template, attach/detach a site)
      description: |-
        **Required scope:** `pages:write`

        The `base_slug` is fixed at creation. Pass `null` for `site_id`/`index_page_id` to detach.
      x-required-scope: pages:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                template_html:
                  type: string
                site_id:
                  type:
                    - string
                    - 'null'
                index_page_id:
                  type:
                    - string
                    - 'null'
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/blog/collections/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /blog/posts:
    get:
      tags:
        - Blog
      summary: List blog posts
      x-required-scope: pages:read
      parameters:
        - in: query
          name: collection_id
          schema:
            type: string
        - in: query
          name: status
          schema:
            type: string
            enum:
              - draft
              - published
        - in: query
          name: limit
          schema:
            type: integer
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/blog/posts" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Blog
      summary: Write a blog post
      description: |
        **Required scope:** `pages:write`

        Add a post to a collection. Provide `body_html` (rendered into the blog
        template), plus optional `excerpt`, `cover_image_url`, `author`. Defaults
        to a draft; pass `status: published` to publish immediately (live at
        `/post/<id>`).
      x-required-scope: pages:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - collection_id
                - title
              properties:
                collection_id:
                  type: string
                title:
                  type: string
                body_html:
                  type: string
                  description: Post body as HTML
                excerpt:
                  type: string
                cover_image_url:
                  type: string
                author:
                  type: string
                slug:
                  type: string
                status:
                  type: string
                  enum:
                    - draft
                    - published
      responses:
        '201':
          $ref: '#/components/responses/Created'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/blog/posts" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "collection_id": "b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c",
              "title": "Launch plan"
            }'
  /blog/posts/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    patch:
      tags:
        - Blog
      summary: Edit a blog post
      x-required-scope: pages:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                excerpt:
                  type: string
                cover_image_url:
                  type: string
                body_html:
                  type: string
                author:
                  type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `pages:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH "https://api.wakato.io/functions/v1/space-api/blog/posts/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /blog/posts/{id}/publish:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    post:
      tags:
        - Blog
      summary: Publish or unpublish a blog post
      description: |-
        **Required scope:** `pages:run`

        Publishes the post live at /post/<id>. Pass publish=false to move it back to draft.
      x-required-scope: pages:run
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                publish:
                  type: boolean
                  description: false to unpublish (default true)
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/blog/posts/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/publish" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /cloud-agents:
    get:
      tags:
        - Cloud Agents
      summary: List cloud agents
      x-required-scope: cloud_agents:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `cloud_agents:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/cloud-agents" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Cloud Agents
      summary: Create a cloud agent (draft)
      x-required-scope: cloud_agents:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                instructions:
                  type: string
                greeting_message:
                  type: string
                model:
                  type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `cloud_agents:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/cloud-agents" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan"
            }'
  /cloud-agents/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Cloud Agents
      summary: Get a cloud agent
      x-required-scope: cloud_agents:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `cloud_agents:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/cloud-agents/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    patch:
      tags:
        - Cloud Agents
      summary: Update a cloud agent
      x-required-scope: cloud_agents:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `cloud_agents:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/cloud-agents/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /finance/accounts:
    get:
      tags:
        - Finance
      summary: List bank accounts (read-only)
      x-required-scope: finance:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `finance:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/finance/accounts" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /finance/transactions:
    get:
      tags:
        - Finance
      summary: List bank transactions (read-only)
      x-required-scope: finance:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `finance:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/finance/transactions" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /wallet:
    get:
      tags:
        - Wallet
      summary: Wallet allocation summary (read-only)
      x-required-scope: wallet:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `wallet:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/wallet" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /wallet/transactions:
    get:
      tags:
        - Wallet
      summary: Wallet transactions (read-only)
      x-required-scope: wallet:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `wallet:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/wallet/transactions" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /integrations:
    get:
      tags:
        - Integrations
      summary: List connected integrations (read-only)
      x-required-scope: integrations:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `integrations:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/integrations" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /secrets:
    get:
      tags:
        - Secrets
      summary: List secret NAMES only (values never returned)
      x-required-scope: secrets:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `secrets:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/secrets" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /agent-mail/send:
    post:
      tags:
        - Agent Mail
      summary: Send email from a space agent-mail address
      x-required-scope: agent_mail:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - from_address_id
                - to
                - subject
              properties:
                from_address_id:
                  type: string
                to:
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                subject:
                  type: string
                body_html:
                  type: string
                body_text:
                  type: string
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `agent_mail:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/agent-mail/send" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "from_address_id": "b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c",
              "to": "example",
              "subject": "example"
            }'
  /agent-mail/addresses:
    get:
      tags:
        - Agent Mail
      summary: List email addresses assigned to this space (campaign senders)
      x-required-scope: agent_mail:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `agent_mail:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/agent-mail/addresses" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /agent-mail/campaigns:
    get:
      tags:
        - Agent Mail
      summary: List email campaigns
      x-required-scope: agent_mail:read
      parameters:
        - in: query
          name: status
          schema:
            type: string
        - in: query
          name: limit
          schema:
            type: integer
            default: 50
            maximum: 200
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `agent_mail:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/agent-mail/campaigns" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Agent Mail
      summary: Create a DRAFT email campaign (broadcast or drip)
      description: >-
        **Required scope:** `agent_mail:write`


        Drafting never requires a connected email address — from_address_id is optional and the campaign stays a draft
        until one is set. Sending is a separate run-scoped action. For drips pass ordered steps.
      x-required-scope: agent_mail:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                campaign_type:
                  type: string
                  enum:
                    - broadcast
                    - drip
                  default: broadcast
                subject:
                  type: string
                body_text:
                  type: string
                body_html:
                  type: string
                from_address_id:
                  type: string
                audience_id:
                  type: string
                template_id:
                  type: string
                enrollment_mode:
                  type: string
                  enum:
                    - one_shot
                    - continuous
                trigger_audience_id:
                  type: string
                steps:
                  type: array
                  description: Drip steps in order
                  items:
                    type: object
                    properties:
                      delay_minutes:
                        type: integer
                      subject:
                        type: string
                      body_text:
                        type: string
                      body_html:
                        type: string
                      template_id:
                        type: string
      responses:
        '201':
          $ref: '#/components/responses/Created'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/agent-mail/campaigns" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan"
            }'
  /agent-mail/campaigns/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Agent Mail
      summary: Get an email campaign (incl. drip steps)
      x-required-scope: agent_mail:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `agent_mail:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/agent-mail/campaigns/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    patch:
      tags:
        - Agent Mail
      summary: Update a draft/paused/scheduled email campaign
      description: |-
        **Required scope:** `agent_mail:write`

        Passing steps REPLACES all drip steps.
      x-required-scope: agent_mail:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/agent-mail/campaigns/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /agent-mail/campaigns/{id}/send:
    post:
      tags:
        - Agent Mail
      summary: Send/start an email campaign (consequential)
      description: >-
        **Required scope:** `agent_mail:run`


        Broadcast: schedules the send (scheduled_at defaults to now). Drip: starts the sequence. Requires a sender
        address, an audience, and content on the campaign.
      x-required-scope: agent_mail:run
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                scheduled_at:
                  type: string
                  description: ISO; omit to send ASAP
      responses:
        '202':
          $ref: '#/components/responses/Ok'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/agent-mail/campaigns/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/send"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /agent-mail/templates:
    get:
      tags:
        - Agent Mail
      summary: List email templates
      x-required-scope: agent_mail:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `agent_mail:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/agent-mail/templates" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Agent Mail
      summary: Create an email template (designed HTML or plain text)
      x-required-scope: agent_mail:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                kind:
                  type: string
                  enum:
                    - html
                    - plain_text
                  default: html
                subject:
                  type: string
                body_html:
                  type: string
                  description: Required for kind html
                body_text:
                  type: string
                  description: Required for kind plain_text
                description:
                  type: string
                category:
                  type: string
                variables:
                  type: array
                  items:
                    type: object
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `agent_mail:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/agent-mail/templates" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan"
            }'
  /agent-mail/templates/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Agent Mail
      summary: Get an email template
      x-required-scope: agent_mail:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `agent_mail:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X GET
            "https://api.wakato.io/functions/v1/space-api/agent-mail/templates/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    patch:
      tags:
        - Agent Mail
      summary: Update an email template
      x-required-scope: agent_mail:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `agent_mail:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.wakato.io/functions/v1/space-api/agent-mail/templates/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /apps:
    get:
      tags:
        - Apps
      summary: List apps
      x-required-scope: apps:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `apps:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/apps" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    post:
      tags:
        - Apps
      summary: Create an agent-authored app
      x-required-scope: apps:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                description:
                  type: string
                ui_code:
                  type: string
                  description: Full HTML (Preact+HTM)
                  uses window.wakato.* SDK: null
                app_schema:
                  type: object
      responses:
        '201':
          $ref: '#/components/responses/Created'
      description: '**Required scope:** `apps:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/apps" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
              "name": "Launch plan"
            }'
  /apps/capabilities:
    get:
      tags:
        - Apps
      summary: Discover usable models/services + capability keys
      x-required-scope: apps:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `apps:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/apps/capabilities" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /apps/{id}:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Apps
      summary: Get an app (incl. ui_code)
      x-required-scope: apps:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `apps:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/apps/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
    patch:
      tags:
        - Apps
      summary: Update an app's code/schema
      x-required-scope: apps:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `apps:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X PATCH "https://api.wakato.io/functions/v1/space-api/apps/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /apps/{id}/model:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    post:
      tags:
        - Apps
      summary: Define a data model on the app
      x-required-scope: apps:write
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                model_key:
                  type: string
                fields:
                  type: object
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `apps:write`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST "https://api.wakato.io/functions/v1/space-api/apps/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/model"
            \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{}'
  /apps/{id}/preview:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    post:
      tags:
        - Apps
      summary: Dry-run validate an app
      x-required-scope: apps:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `apps:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/apps/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/preview" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /apps/{id}/logs:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    get:
      tags:
        - Apps
      summary: Read recent app runtime/SDK errors
      x-required-scope: apps:read
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      description: '**Required scope:** `apps:read`'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET "https://api.wakato.io/functions/v1/space-api/apps/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/logs" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
  /apps/{id}/publish:
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
    post:
      tags:
        - Apps
      summary: Publish an app into the space
      description: |-
        **Required scope:** `apps:run`

        Installs the app. It cannot use any capability until a space admin approves the requested permissions.
      x-required-scope: apps:run
      responses:
        '200':
          $ref: '#/components/responses/Ok'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.wakato.io/functions/v1/space-api/apps/b7e4a1c2-9d3f-4e8a-b2c1-5f6d7e8a9b0c/publish" \
              -H "Authorization: Bearer wks_live_YOUR_TOKEN"
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: A Space API key, e.g. `wks_live_…`.
  responses:
    Ok:
      description: Success
      content:
        application/json:
          schema:
            type: object
    Created:
      description: Created
      content:
        application/json:
          schema:
            type: object
    Accepted:
      description: Accepted — the work runs asynchronously
      content:
        application/json:
          schema:
            type: object
    Unauthorized:
      description: Missing or invalid key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The key lacks the required scope for this operation
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
